From: <pa...@us...> - 2011-03-09 04:20:19
|
Revision: 5446 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5446&view=rev Author: patearl Date: 2011-03-09 04:20:13 +0000 (Wed, 09 Mar 2011) Log Message: ----------- SQLite: Avoid the problematic cast function. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs 2011-03-09 03:42:40 UTC (rev 5445) +++ trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs 2011-03-09 04:20:13 UTC (rev 5446) @@ -67,6 +67,13 @@ RegisterFunction("mod", new SQLFunctionTemplate(NHibernateUtil.Int32, "((?1) % (?2))")); RegisterFunction("iif", new SQLFunctionTemplate(null, "case when ?1 then ?2 else ?3 end")); + + // Casting in SQLite is unnecessary since SQLite is essentially typeless. + // String operators can be performed on integers, integer ops on strings, etc. + // For some reason, doing cast('2001-02-03 04:05:06' as datetime) returns 2001. + // In fact, casting to even a type named as a string of garbage returns the same thing. + // Therefore, it's better to avoid the cast function entirely. + RegisterFunction("cast", new SQLFunctionTemplate(null, "(?1)")); } public override Schema.IDataBaseSchema GetDataBaseSchema(DbConnection connection) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |