From: <fab...@us...> - 2009-10-15 18:19:55
|
Revision: 4758 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4758&view=rev Author: fabiomaulo Date: 2009-10-15 18:19:47 +0000 (Thu, 15 Oct 2009) Log Message: ----------- Fix NH-1979 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs branches/2.1.x/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs 2009-10-15 15:56:44 UTC (rev 4757) +++ branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs 2009-10-15 18:19:47 UTC (rev 4758) @@ -397,7 +397,14 @@ public void Parameter() { - args.Add(new SqlString(SqlCommand.Parameter.Placeholder)); + if (argInd == args.Count) + { + args.Add(new SqlString(SqlCommand.Parameter.Placeholder)); + } + else + { + args[argInd] = args[argInd].Append(new SqlString(SqlCommand.Parameter.Placeholder)); + } } public void CommaBetweenParameters(string comma) Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-10-15 15:56:44 UTC (rev 4757) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-10-15 18:19:47 UTC (rev 4758) @@ -736,6 +736,23 @@ } } + [Test] + public void CastNH1979() + { + IgnoreIfNotSupported("cast"); + using (ISession s = OpenSession()) + { + Animal a1 = new Animal("abcdef", 1.3f); + s.Save(a1); + s.Flush(); + } + using (ISession s = OpenSession()) + { + string hql = "select cast(((a.BodyWeight + 50) / :divisor) as int) from Animal a"; + IList l = s.CreateQuery(hql).SetInt32("divisor", 2).List(); + Assert.AreEqual(1, l.Count); + } + } [Test] public void Current_TimeStamp() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |