From: <fab...@us...> - 2009-02-02 22:57:46
|
Revision: 4014 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4014&view=rev Author: fabiomaulo Date: 2009-02-02 22:17:07 +0000 (Mon, 02 Feb 2009) Log Message: ----------- Hql changed in nullif function for Oracle dialects Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-02 21:33:58 UTC (rev 4013) +++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-02 22:17:07 UTC (rev 4014) @@ -18,13 +18,20 @@ static HQLFunctions() { notSupportedStandardFunction.Add("locate", - new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) ,typeof(FirebirdDialect), typeof(PostgreSQLDialect) }); + new[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) ,typeof(FirebirdDialect), typeof(PostgreSQLDialect) }); notSupportedStandardFunction.Add("bit_length", - new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect), typeof(Oracle9Dialect), typeof(OracleDialect), typeof(Oracle8iDialect), typeof(Oracle9iDialect), typeof(Oracle10gDialect) }); + new[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect), typeof(Oracle9Dialect), typeof(OracleDialect), typeof(Oracle8iDialect), typeof(Oracle9iDialect), typeof(Oracle10gDialect) }); notSupportedStandardFunction.Add("extract", - new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) }); + new[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) }); + notSupportedStandardFunction.Add("nullif", + new[] { typeof(OracleDialect), typeof(Oracle8iDialect)}); } + private bool IsOracleDialect() + { + return typeof (Oracle8iDialect).IsInstanceOfType(Dialect); + } + private void IgnoreIfNotSupported(string functionName) { if (notSupportedStandardFunction.ContainsKey(functionName)) @@ -402,14 +409,23 @@ public void Nullif() { IgnoreIfNotSupported("nullif"); + string hql1, hql2; + if(!IsOracleDialect()) + { + hql1 = "select nullif(h.NickName, '1e1') from Human h"; + hql2 = "from Human h where nullif(h.NickName, '1e1') not is null"; + } + else + { + // Oracle need same specific types + hql1 = "select nullif(str(h.NickName), '1e1') from Human h"; + hql2 = "from Human h where nullif(str(h.NickName), '1e1') not is null"; + } // test only the parser and render using (ISession s = OpenSession()) { - string hql = "select nullif(h.NickName, '1e1') from Human h"; - IList result = s.CreateQuery(hql).List(); - - hql = "from Human h where nullif(h.NickName, '1e1') not is null"; - result = s.CreateQuery(hql).List(); + IList result = s.CreateQuery(hql1).List(); + result = s.CreateQuery(hql2).List(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |