|
From: <fab...@us...> - 2008-09-29 19:44:12
|
Revision: 3799
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3799&view=rev
Author: fabiomaulo
Date: 2008-09-29 19:43:50 +0000 (Mon, 29 Sep 2008)
Log Message:
-----------
Fix NH-1446
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs
trunk/nhibernate/src/NHibernate.Test/HQLFunctionTest/HQLFunctions.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs 2008-09-29 17:25:31 UTC (rev 3798)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs 2008-09-29 19:43:50 UTC (rev 3799)
@@ -12,10 +12,6 @@
/// </summary>
public class CastFunction : ISQLFunction, IFunctionGrammar
{
- public CastFunction()
- {
- }
-
#region ISQLFunction Members
public IType ReturnType(IType columnType, IMapping mapping)
@@ -42,7 +38,7 @@
throw new QueryException("cast() requires two arguments");
}
string typeName = args[1].ToString();
- string sqlType = string.Empty;
+ string sqlType;
IType hqlType = TypeFactory.HeuristicType(typeName);
if (hqlType != null)
{
@@ -86,7 +82,7 @@
bool IFunctionGrammar.IsSeparator(string token)
{
- return "as".Equals(token);
+ return "as".Equals(token, StringComparison.InvariantCultureIgnoreCase);
}
bool IFunctionGrammar.IsKnownArgument(string token)
Modified: trunk/nhibernate/src/NHibernate.Test/HQLFunctionTest/HQLFunctions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/HQLFunctionTest/HQLFunctions.cs 2008-09-29 17:25:31 UTC (rev 3798)
+++ trunk/nhibernate/src/NHibernate.Test/HQLFunctionTest/HQLFunctions.cs 2008-09-29 19:43:50 UTC (rev 3799)
@@ -667,6 +667,27 @@
}
[Test]
+ public void CastNH1446()
+ {
+ IgnoreIfNotSupported("cast");
+ using (ISession s = OpenSession())
+ {
+ Animal a1 = new Animal("abcdef", 1.3f);
+ s.Save(a1);
+ s.Flush();
+ }
+ using (ISession s = OpenSession())
+ {
+ // Rendered in SELECT using a property
+ string hql = "select cast(a.BodyWeight As Double) from Animal a";
+ IList l = s.CreateQuery(hql).List();
+ Assert.AreEqual(1, l.Count);
+ Assert.AreEqual(1.3f, l[0]);
+ }
+ }
+
+
+ [Test]
public void Current_TimeStamp()
{
IgnoreIfNotSupported("current_timestamp");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|