From: <fab...@us...> - 2010-08-04 17:30:19
|
Revision: 5108 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5108&view=rev Author: fabiomaulo Date: 2010-08-04 17:30:13 +0000 (Wed, 04 Aug 2010) Log Message: ----------- Minor (Check NH-2089 with strings substitution) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/QuerySubstitutionTest.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/QuerySubstitutionTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/QuerySubstitutionTest.cs 2010-08-04 17:21:44 UTC (rev 5107) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/QuerySubstitutionTest.cs 2010-08-04 17:30:13 UTC (rev 5108) @@ -10,13 +10,13 @@ protected override void Configure(NHibernate.Cfg.Configuration configuration) { base.Configure(configuration); - configuration.SessionFactory().Integrate.CreateCommands.WithHqlToSqlSubstitutions("pizza 1"); + configuration.SessionFactory().Integrate.CreateCommands.WithHqlToSqlSubstitutions("pizza 1, calda 'bobrock'"); } - const string query = "from SimpleClass s where s.IntValue > pizza"; [Test] public void WhenSubstitutionsConfiguredThenUseItInTranslation() { + const string query = "from SimpleClass s where s.IntValue > pizza"; var sql = GetSql(query, new Dictionary<string, string>{{"pizza","1"}}); sql.Should().Not.Contain("pizza"); } @@ -24,6 +24,7 @@ [Test] public void WhenExecutedThroughSessionThenUseSubstitutions() { + const string query = "from SimpleClass s where s.IntValue > pizza"; using (var s = OpenSession()) { using (SqlLogSpy sqlLogSpy = new SqlLogSpy()) @@ -34,5 +35,28 @@ } } } + + [Test] + public void WhenSubstitutionsWithStringConfiguredThenUseItInTranslation() + { + const string query = "from SimpleClass s where s.Description > calda"; + var sql = GetSql(query, new Dictionary<string, string> { { "calda", "'bobrock'" } }); + sql.Should().Not.Contain("pizza").And.Contain("'bobrock'"); + } + + [Test] + public void WhenExecutedThroughSessionThenUseSubstitutionsWithString() + { + const string query = "from SimpleClass s where s.Description > calda"; + using (var s = OpenSession()) + { + using (SqlLogSpy sqlLogSpy = new SqlLogSpy()) + { + s.CreateQuery(query).List(); + string sql = sqlLogSpy.Appender.GetEvents()[0].RenderedMessage; + sql.Should().Not.Contain("pizza").And.Contain("'bobrock'"); + } + } + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |