From: Paul H. <pha...@us...> - 2005-03-01 16:25:33
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate/Dialect Modified Files: DB2Dialect.cs Dialect.cs FirebirdDialect.cs GenericDialect.cs MsSql2000Dialect.cs MySQLDialect.cs Oracle9Dialect.cs PostgreSQLDialect.cs SQLiteDialect.cs Added Files: ISQLFunction.cs NoArgSQLFunction.cs StandardSQLFunction.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: FirebirdDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/FirebirdDialect.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FirebirdDialect.cs 17 Jan 2005 22:31:47 -0000 1.10 --- FirebirdDialect.cs 1 Mar 2005 16:24:44 -0000 1.11 *************** *** 25,52 **** public FirebirdDialect() : base() { ! Register( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! Register( DbType.AnsiStringFixedLength, 8000, "CHAR($1)" ); ! Register( DbType.AnsiString, "VARCHAR(255)" ); ! Register( DbType.AnsiString, 8000, "VARCHAR($1)" ); ! Register( DbType.AnsiString, 2147483647, "BLOB" ); // should use the IType.ClobType ! Register( DbType.Binary, 2147483647, "BLOB SUB_TYPE 0" ); // should use the IType.BlobType ! Register( DbType.Boolean, "SMALLINT" ); ! Register( DbType.Byte, "SMALLINT" ); ! Register( DbType.Currency, "DECIMAL(16,4)" ); ! Register( DbType.Date, "DATE" ); ! Register( DbType.DateTime, "TIMESTAMP" ); ! Register( DbType.Decimal, "DECIMAL(18,0)" ); // NUMERIC(18,0) is equivalent to DECIMAL(18,0) ! Register( DbType.Decimal, 18, "DECIMAL(18, $1)" ); ! Register( DbType.Double, "DOUBLE PRECISION" ); ! Register( DbType.Int16, "SMALLINT" ); ! Register( DbType.Int32, "INTEGER" ); ! Register( DbType.Int64, "BIGINT" ); ! Register( DbType.Single, "FLOAT" ); ! Register( DbType.StringFixedLength, "CHAR(255)" ); ! Register( DbType.StringFixedLength, 4000, "CHAR($1)" ); ! Register( DbType.String, "VARCHAR(255)" ); ! Register( DbType.String, 4000, "VARCHAR($1)" ); ! Register( DbType.String, 1073741823, "BLOB SUB_TYPE 1" ); // should use the IType.ClobType ! Register( DbType.Time, "TIME" ); DefaultProperties[ Environment.ConnectionDriver ] = "NHibernate.Driver.FirebirdDriver"; --- 25,52 ---- public FirebirdDialect() : base() { ! RegisterColumnType( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 8000, "CHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, "VARCHAR(255)" ); ! RegisterColumnType( DbType.AnsiString, 8000, "VARCHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, 2147483647, "BLOB" ); // should use the IType.ClobType ! RegisterColumnType( DbType.Binary, 2147483647, "BLOB SUB_TYPE 0" ); // should use the IType.BlobType ! RegisterColumnType( DbType.Boolean, "SMALLINT" ); ! RegisterColumnType( DbType.Byte, "SMALLINT" ); ! RegisterColumnType( DbType.Currency, "DECIMAL(16,4)" ); ! RegisterColumnType( DbType.Date, "DATE" ); ! RegisterColumnType( DbType.DateTime, "TIMESTAMP" ); ! RegisterColumnType( DbType.Decimal, "DECIMAL(18,0)" ); // NUMERIC(18,0) is equivalent to DECIMAL(18,0) ! RegisterColumnType( DbType.Decimal, 18, "DECIMAL(18, $1)" ); ! RegisterColumnType( DbType.Double, "DOUBLE PRECISION" ); ! RegisterColumnType( DbType.Int16, "SMALLINT" ); ! RegisterColumnType( DbType.Int32, "INTEGER" ); ! RegisterColumnType( DbType.Int64, "BIGINT" ); ! RegisterColumnType( DbType.Single, "FLOAT" ); ! RegisterColumnType( DbType.StringFixedLength, "CHAR(255)" ); ! RegisterColumnType( DbType.StringFixedLength, 4000, "CHAR($1)" ); ! RegisterColumnType( DbType.String, "VARCHAR(255)" ); ! RegisterColumnType( DbType.String, 4000, "VARCHAR($1)" ); ! RegisterColumnType( DbType.String, 1073741823, "BLOB SUB_TYPE 1" ); // should use the IType.ClobType ! RegisterColumnType( DbType.Time, "TIME" ); DefaultProperties[ Environment.ConnectionDriver ] = "NHibernate.Driver.FirebirdDriver"; Index: SQLiteDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SQLiteDialect.cs 14 Feb 2005 03:58:53 -0000 1.1 --- SQLiteDialect.cs 1 Mar 2005 16:24:44 -0000 1.2 *************** *** 14,36 **** public class SQLiteDialect : Dialect { public SQLiteDialect() { ! Register(DbType.Binary, "BLOB"); ! Register(DbType.Byte, "INTEGER"); ! Register(DbType.Int16, "INTEGER"); ! Register(DbType.Int32, "INTEGER"); ! Register(DbType.Int64, "INTEGER"); ! Register(DbType.SByte, "INTEGER"); ! Register(DbType.UInt16, "INTEGER"); ! Register(DbType.UInt32, "INTEGER"); ! Register(DbType.UInt64, "INTEGER"); ! Register(DbType.Currency, "NUMERIC"); ! Register(DbType.Decimal, "NUMERIC"); ! Register(DbType.Double, "NUMERIC"); ! Register(DbType.Single, "NUMERIC"); ! Register(DbType.VarNumeric, "NUMERIC"); ! Register(DbType.String, "TEXT"); } public override string IdentitySelectString { --- 14,42 ---- public class SQLiteDialect : Dialect { + /// <summary> + /// + /// </summary> public SQLiteDialect() { ! RegisterColumnType(DbType.Binary, "BLOB"); ! RegisterColumnType(DbType.Byte, "INTEGER"); ! RegisterColumnType(DbType.Int16, "INTEGER"); ! RegisterColumnType(DbType.Int32, "INTEGER"); ! RegisterColumnType(DbType.Int64, "INTEGER"); ! RegisterColumnType(DbType.SByte, "INTEGER"); ! RegisterColumnType(DbType.UInt16, "INTEGER"); ! RegisterColumnType(DbType.UInt32, "INTEGER"); ! RegisterColumnType(DbType.UInt64, "INTEGER"); ! RegisterColumnType(DbType.Currency, "NUMERIC"); ! RegisterColumnType(DbType.Decimal, "NUMERIC"); ! RegisterColumnType(DbType.Double, "NUMERIC"); ! RegisterColumnType(DbType.Single, "NUMERIC"); ! RegisterColumnType(DbType.VarNumeric, "NUMERIC"); ! RegisterColumnType(DbType.String, "TEXT"); } + /// <summary> + /// + /// </summary> public override string IdentitySelectString { Index: GenericDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/GenericDialect.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** GenericDialect.cs 31 Dec 2004 17:07:24 -0000 1.10 --- GenericDialect.cs 1 Mar 2005 16:24:44 -0000 1.11 *************** *** 11,32 **** public GenericDialect() : base() { ! Register( DbType.AnsiStringFixedLength, "CHAR($1)" ); ! Register( DbType.AnsiString, "VARCHAR($1)" ); ! Register( DbType.Binary, "VARBINARY($1)" ); ! Register( DbType.Boolean, "BIT" ); ! Register( DbType.Byte, "TINYINT" ); ! Register( DbType.Currency, "MONEY" ); ! Register( DbType.Date, "DATE" ); ! Register( DbType.DateTime, "DATETIME" ); ! Register( DbType.Decimal, "DECIMAL(19, $1)" ); ! Register( DbType.Double, "DOUBLE PRECISION" ); ! Register( DbType.Guid, "UNIQUEIDENTIFIER" ); ! Register( DbType.Int16, "SMALLINT" ); ! Register( DbType.Int32, "INT" ); ! Register( DbType.Int64, "BIGINT" ); ! Register( DbType.Single, "REAL" ); ! Register( DbType.StringFixedLength, "NCHAR($1)" ); ! Register( DbType.String, "NVARCHAR($1)" ); ! Register( DbType.Time, "TIME" ); } --- 11,32 ---- public GenericDialect() : base() { ! RegisterColumnType( DbType.AnsiStringFixedLength, "CHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, "VARCHAR($1)" ); ! RegisterColumnType( DbType.Binary, "VARBINARY($1)" ); ! RegisterColumnType( DbType.Boolean, "BIT" ); ! RegisterColumnType( DbType.Byte, "TINYINT" ); ! RegisterColumnType( DbType.Currency, "MONEY" ); ! RegisterColumnType( DbType.Date, "DATE" ); ! RegisterColumnType( DbType.DateTime, "DATETIME" ); ! RegisterColumnType( DbType.Decimal, "DECIMAL(19, $1)" ); ! RegisterColumnType( DbType.Double, "DOUBLE PRECISION" ); ! RegisterColumnType( DbType.Guid, "UNIQUEIDENTIFIER" ); ! RegisterColumnType( DbType.Int16, "SMALLINT" ); ! RegisterColumnType( DbType.Int32, "INT" ); ! RegisterColumnType( DbType.Int64, "BIGINT" ); ! RegisterColumnType( DbType.Single, "REAL" ); ! RegisterColumnType( DbType.StringFixedLength, "NCHAR($1)" ); ! RegisterColumnType( DbType.String, "NVARCHAR($1)" ); ! RegisterColumnType( DbType.Time, "TIME" ); } --- NEW FILE: ISQLFunction.cs --- using NHibernate.Engine; using NHibernate.Hql; using NHibernate.Type; namespace NHibernate.Dialect { /// <summary> /// Provides support routines for the HQL functions as used /// in the various SQL Dialects /// /// Provides an interface for supporting various HQL functions that are /// translated to SQL. The Dialect and its sub-classes use this interface to /// provide details required for processing of the function. /// </summary> public interface ISQLFunction { /// <summary> /// /// </summary> /// <param name="columnType"></param> /// <param name="mapping"></param> /// <returns></returns> IType ReturnType( IType columnType, IMapping mapping ); /// <summary> /// /// </summary> bool HasArguments { get; } /// <summary> /// /// </summary> bool HasParenthesesIfNoArguments { get; } } } Index: MySQLDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/MySQLDialect.cs,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** MySQLDialect.cs 9 Feb 2005 03:09:38 -0000 1.26 --- MySQLDialect.cs 1 Mar 2005 16:24:44 -0000 1.27 *************** *** 34,71 **** public MySQLDialect() : base() { ! Register( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! Register( DbType.AnsiStringFixedLength, 255, "CHAR($1)" ); ! Register( DbType.AnsiStringFixedLength, 65535, "TEXT" ); ! Register( DbType.AnsiStringFixedLength, 16777215, "MEDIUMTEXT" ); ! Register( DbType.AnsiString, "VARCHAR(255)" ); ! Register( DbType.AnsiString, 255, "VARCHAR($1)" ); ! Register( DbType.AnsiString, 65535, "TEXT" ); ! Register( DbType.AnsiString, 16777215, "MEDIUMTEXT" ); ! Register( DbType.Binary, "LONGBLOB" ); ! Register( DbType.Binary, 127, "TINYBLOB" ); ! Register( DbType.Binary, 65535, "BLOB" ); ! Register( DbType.Binary, 16777215, "MEDIUMBLOB" ); ! Register( DbType.Boolean, "TINYINT(1)" ); ! Register( DbType.Byte, "TINYINT UNSIGNED" ); ! Register( DbType.Currency, "MONEY" ); ! Register( DbType.Date, "DATE" ); ! Register( DbType.DateTime, "DATETIME" ); ! Register( DbType.Decimal, "NUMERIC(19,5)" ); ! Register( DbType.Decimal, 19, "NUMERIC(19, $1)" ); ! Register( DbType.Double, "DOUBLE" ); ! Register( DbType.Guid, "VARCHAR(40)" ); ! Register( DbType.Int16, "SMALLINT" ); ! Register( DbType.Int32, "INTEGER" ); ! Register( DbType.Int64, "BIGINT" ); ! Register( DbType.Single, "FLOAT" ); ! Register( DbType.StringFixedLength, "CHAR(255)" ); ! Register( DbType.StringFixedLength, 255, "CHAR($1)" ); ! Register( DbType.StringFixedLength, 65535, "TEXT" ); ! Register( DbType.StringFixedLength, 16777215, "MEDIUMTEXT" ); ! Register( DbType.String, "VARCHAR(255)" ); ! Register( DbType.String, 255, "VARCHAR($1)" ); ! Register( DbType.String, 65535, "TEXT" ); ! Register( DbType.String, 16777215, "MEDIUMTEXT" ); ! Register( DbType.Time, "TIME" ); DefaultProperties[ Environment.OuterJoin ] = "true"; --- 34,71 ---- public MySQLDialect() : base() { ! RegisterColumnType( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 255, "CHAR($1)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 65535, "TEXT" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 16777215, "MEDIUMTEXT" ); ! RegisterColumnType( DbType.AnsiString, "VARCHAR(255)" ); ! RegisterColumnType( DbType.AnsiString, 255, "VARCHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, 65535, "TEXT" ); ! RegisterColumnType( DbType.AnsiString, 16777215, "MEDIUMTEXT" ); ! RegisterColumnType( DbType.Binary, "LONGBLOB" ); ! RegisterColumnType( DbType.Binary, 127, "TINYBLOB" ); ! RegisterColumnType( DbType.Binary, 65535, "BLOB" ); ! RegisterColumnType( DbType.Binary, 16777215, "MEDIUMBLOB" ); ! RegisterColumnType( DbType.Boolean, "TINYINT(1)" ); ! RegisterColumnType( DbType.Byte, "TINYINT UNSIGNED" ); ! RegisterColumnType( DbType.Currency, "MONEY" ); ! RegisterColumnType( DbType.Date, "DATE" ); ! RegisterColumnType( DbType.DateTime, "DATETIME" ); ! RegisterColumnType( DbType.Decimal, "NUMERIC(19,5)" ); ! RegisterColumnType( DbType.Decimal, 19, "NUMERIC(19, $1)" ); ! RegisterColumnType( DbType.Double, "DOUBLE" ); ! RegisterColumnType( DbType.Guid, "VARCHAR(40)" ); ! RegisterColumnType( DbType.Int16, "SMALLINT" ); ! RegisterColumnType( DbType.Int32, "INTEGER" ); ! RegisterColumnType( DbType.Int64, "BIGINT" ); ! RegisterColumnType( DbType.Single, "FLOAT" ); ! RegisterColumnType( DbType.StringFixedLength, "CHAR(255)" ); ! RegisterColumnType( DbType.StringFixedLength, 255, "CHAR($1)" ); ! RegisterColumnType( DbType.StringFixedLength, 65535, "TEXT" ); ! RegisterColumnType( DbType.StringFixedLength, 16777215, "MEDIUMTEXT" ); ! RegisterColumnType( DbType.String, "VARCHAR(255)" ); ! RegisterColumnType( DbType.String, 255, "VARCHAR($1)" ); ! RegisterColumnType( DbType.String, 65535, "TEXT" ); ! RegisterColumnType( DbType.String, 16777215, "MEDIUMTEXT" ); ! RegisterColumnType( DbType.Time, "TIME" ); DefaultProperties[ Environment.OuterJoin ] = "true"; Index: PostgreSQLDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PostgreSQLDialect.cs 30 Jan 2005 19:39:11 -0000 1.15 --- PostgreSQLDialect.cs 1 Mar 2005 16:24:44 -0000 1.16 *************** *** 31,58 **** public PostgreSQLDialect() { ! Register( DbType.AnsiStringFixedLength, "char(255)" ); ! Register( DbType.AnsiStringFixedLength, 8000, "char($1)" ); ! Register( DbType.AnsiString, "varchar(255)" ); ! Register( DbType.AnsiString, 8000, "varchar($1)" ); ! Register( DbType.AnsiString, 2147483647, "text" ); ! Register( DbType.Binary, 2147483647, "bytea" ); ! Register( DbType.Boolean, "boolean" ); ! Register( DbType.Byte, "int2" ); ! Register( DbType.Currency, "decimal(16,4)" ); ! Register( DbType.Date, "date" ); ! Register( DbType.DateTime, "timestamp" ); ! Register( DbType.Decimal, "decimal(19,5)" ); ! Register( DbType.Decimal, 19, "decimal(18, $1)" ); ! Register( DbType.Double, "float8" ); ! Register( DbType.Int16, "int2" ); ! Register( DbType.Int32, "int4" ); ! Register( DbType.Int64, "int8" ); ! Register( DbType.Single, "float4" ); ! Register( DbType.StringFixedLength, "char(255)" ); ! Register( DbType.StringFixedLength, 4000, "char($1)" ); ! Register( DbType.String, "varchar(255)" ); ! Register( DbType.String, 4000, "varchar($1)" ); ! Register( DbType.String, 1073741823, "text" ); // ! Register( DbType.Time, "time" ); DefaultProperties[ Environment.OuterJoin ] = "true"; --- 31,58 ---- public PostgreSQLDialect() { ! RegisterColumnType( DbType.AnsiStringFixedLength, "char(255)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 8000, "char($1)" ); ! RegisterColumnType( DbType.AnsiString, "varchar(255)" ); ! RegisterColumnType( DbType.AnsiString, 8000, "varchar($1)" ); ! RegisterColumnType( DbType.AnsiString, 2147483647, "text" ); ! RegisterColumnType( DbType.Binary, 2147483647, "bytea" ); ! RegisterColumnType( DbType.Boolean, "boolean" ); ! RegisterColumnType( DbType.Byte, "int2" ); ! RegisterColumnType( DbType.Currency, "decimal(16,4)" ); ! RegisterColumnType( DbType.Date, "date" ); ! RegisterColumnType( DbType.DateTime, "timestamp" ); ! RegisterColumnType( DbType.Decimal, "decimal(19,5)" ); ! RegisterColumnType( DbType.Decimal, 19, "decimal(18, $1)" ); ! RegisterColumnType( DbType.Double, "float8" ); ! RegisterColumnType( DbType.Int16, "int2" ); ! RegisterColumnType( DbType.Int32, "int4" ); ! RegisterColumnType( DbType.Int64, "int8" ); ! RegisterColumnType( DbType.Single, "float4" ); ! RegisterColumnType( DbType.StringFixedLength, "char(255)" ); ! RegisterColumnType( DbType.StringFixedLength, 4000, "char($1)" ); ! RegisterColumnType( DbType.String, "varchar(255)" ); ! RegisterColumnType( DbType.String, 4000, "varchar($1)" ); ! RegisterColumnType( DbType.String, 1073741823, "text" ); // ! RegisterColumnType( DbType.Time, "time" ); DefaultProperties[ Environment.OuterJoin ] = "true"; --- NEW FILE: NoArgSQLFunction.cs --- using NHibernate.Engine; using NHibernate.Hql; using NHibernate.Type; namespace NHibernate.Dialect { /// <summary> /// Summary description for NoArgSQLFunction. /// </summary> public class NoArgSQLFunction : ISQLFunction { private IType returnType; private bool hasParenthesesIfNoArguments; /// <summary> /// /// </summary> /// <param name="returnType"></param> public NoArgSQLFunction( IType returnType ) : this( returnType, true ) { } /// <summary> /// /// </summary> /// <param name="returnType"></param> /// <param name="hasParenthesesIfNoArguments"></param> public NoArgSQLFunction( IType returnType, bool hasParenthesesIfNoArguments ) { this.returnType = returnType; this.hasParenthesesIfNoArguments = hasParenthesesIfNoArguments; } #region ISQLFunction Members /// <summary> /// /// </summary> /// <param name="columnType"></param> /// <param name="mapping"></param> /// <returns></returns> public IType ReturnType(IType columnType, IMapping mapping) { return returnType; } /// <summary> /// /// </summary> public bool HasArguments { get { return false; } } /// <summary> /// /// </summary> public bool HasParenthesesIfNoArguments { get { return hasParenthesesIfNoArguments; } } #endregion } } Index: DB2Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/DB2Dialect.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** DB2Dialect.cs 30 Jan 2005 19:39:11 -0000 1.9 --- DB2Dialect.cs 1 Mar 2005 16:24:44 -0000 1.10 *************** *** 32,59 **** public DB2Dialect() { ! Register( DbType.AnsiStringFixedLength, "CHAR(254)" ); ! Register( DbType.AnsiStringFixedLength, 254, "CHAR($1)" ); ! Register( DbType.AnsiString, "VARCHAR(254)" ); ! Register( DbType.AnsiString, 8000, "VARCHAR($1)" ); ! Register( DbType.AnsiString, 2147483647, "CLOB" ); ! Register( DbType.Binary, 2147483647, "BLOB" ); ! Register( DbType.Boolean, "SMALLINT" ); ! Register( DbType.Byte, "SMALLINT" ); ! Register( DbType.Currency, "DECIMAL(16,4)" ); ! Register( DbType.Date, "DATE" ); ! Register( DbType.DateTime, "TIMESTAMP" ); ! Register( DbType.Decimal, "DECIMAL(19,5)" ); ! Register( DbType.Decimal, 19, "DECIMAL(19, $1)" ); ! Register( DbType.Double, "DOUBLE" ); ! Register( DbType.Int16, "SMALLINT" ); ! Register( DbType.Int32, "INTEGER" ); ! Register( DbType.Int64, "BIGINT" ); ! Register( DbType.Single, "REAL" ); ! Register( DbType.StringFixedLength, "CHAR(254)" ); ! Register( DbType.StringFixedLength, 254, "CHAR($1)" ); ! Register( DbType.String, "VARCHAR(254)" ); ! Register( DbType.String, 8000, "VARCHAR($1)" ); ! Register( DbType.String, 2147483647, "CLOB" ); ! Register( DbType.Time, "TIME" ); DefaultProperties[ Environment.OuterJoin ] = "true"; --- 32,129 ---- public DB2Dialect() { ! RegisterColumnType( DbType.AnsiStringFixedLength, "CHAR(254)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 254, "CHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, "VARCHAR(254)" ); ! RegisterColumnType( DbType.AnsiString, 8000, "VARCHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, 2147483647, "CLOB" ); ! RegisterColumnType( DbType.Binary, 2147483647, "BLOB" ); ! RegisterColumnType( DbType.Boolean, "SMALLINT" ); ! RegisterColumnType( DbType.Byte, "SMALLINT" ); ! RegisterColumnType( DbType.Currency, "DECIMAL(16,4)" ); ! RegisterColumnType( DbType.Date, "DATE" ); ! RegisterColumnType( DbType.DateTime, "TIMESTAMP" ); ! RegisterColumnType( DbType.Decimal, "DECIMAL(19,5)" ); ! RegisterColumnType( DbType.Decimal, 19, "DECIMAL(19, $1)" ); ! RegisterColumnType( DbType.Double, "DOUBLE" ); ! RegisterColumnType( DbType.Int16, "SMALLINT" ); ! RegisterColumnType( DbType.Int32, "INTEGER" ); ! RegisterColumnType( DbType.Int64, "BIGINT" ); ! RegisterColumnType( DbType.Single, "REAL" ); ! RegisterColumnType( DbType.StringFixedLength, "CHAR(254)" ); ! RegisterColumnType( DbType.StringFixedLength, 254, "CHAR($1)" ); ! RegisterColumnType( DbType.String, "VARCHAR(254)" ); ! RegisterColumnType( DbType.String, 8000, "VARCHAR($1)" ); ! RegisterColumnType( DbType.String, 2147483647, "CLOB" ); ! RegisterColumnType( DbType.Time, "TIME" ); ! ! RegisterFunction("abs", new StandardSQLFunction() ); ! RegisterFunction("absval", new StandardSQLFunction() ); ! RegisterFunction("sign", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! ! RegisterFunction("ceiling", new StandardSQLFunction() ); ! RegisterFunction("ceil", new StandardSQLFunction() ); ! RegisterFunction("floor", new StandardSQLFunction() ); ! RegisterFunction("round", new StandardSQLFunction() ); ! ! RegisterFunction("acos", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("asin", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("atan", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("cos", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("cot", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("degrees", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("exp", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("float", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("hex", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("ln", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("log", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("log10", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("radians", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("rand", new NoArgSQLFunction( NHibernateUtil.Double )); ! RegisterFunction("sin", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("soundex", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("sqrt", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("stddev", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("tan", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("variance", new StandardSQLFunction( NHibernateUtil.Double ) ); ! ! RegisterFunction("julian_day", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("microsecond", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("midnight_seconds", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("minute", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("month", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("monthname", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("quarter", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("hour", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("second", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("date", new StandardSQLFunction( NHibernateUtil.Date ) ); ! RegisterFunction("day", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("dayname", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("dayofweek", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("dayofweek_iso", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("dayofyear", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("days", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("time", new StandardSQLFunction( NHibernateUtil.Time ) ); ! RegisterFunction("timestamp", new StandardSQLFunction( NHibernateUtil.Timestamp ) ); ! RegisterFunction("timestamp_iso", new StandardSQLFunction( NHibernateUtil.Timestamp ) ); ! RegisterFunction("week", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("week_iso", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("year", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! ! RegisterFunction("double", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("varchar", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("real", new StandardSQLFunction( NHibernateUtil.Single ) ); ! RegisterFunction("bigint", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("char", new StandardSQLFunction( NHibernateUtil.Character ) ); ! RegisterFunction("integer", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("smallint", new StandardSQLFunction( NHibernateUtil.Int16 ) ); ! ! RegisterFunction("digits", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("chr", new StandardSQLFunction( NHibernateUtil.Character ) ); ! RegisterFunction("upper", new StandardSQLFunction() ); ! RegisterFunction("ucase", new StandardSQLFunction() ); ! RegisterFunction("lcase", new StandardSQLFunction() ); ! RegisterFunction("lower", new StandardSQLFunction() ); ! RegisterFunction("length", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("ltrim", new StandardSQLFunction() ); DefaultProperties[ Environment.OuterJoin ] = "true"; --- NEW FILE: StandardSQLFunction.cs --- using NHibernate.Engine; using NHibernate.Hql; using NHibernate.Type; namespace NHibernate.Dialect { /// <summary> /// Provides a standard implementation that supports the majority of the HQL /// functions that are translated to SQL. /// </summary> /// <remarks> /// The Dialect and its sub-classes use this class to provide details required /// for processing of the associated function. /// </remarks> public class StandardSQLFunction : ISQLFunction { private IType returnType = null; /// <summary> /// /// </summary> public StandardSQLFunction() { } /// <summary> /// /// </summary> /// <param name="typeValue"></param> public StandardSQLFunction( IType typeValue ) { returnType = typeValue; } /// <summary> /// /// </summary> /// <param name="columnType"></param> /// <param name="mapping"></param> /// <returns></returns> public IType ReturnType( IType columnType, IMapping mapping ) { if ( returnType == null ) return columnType; return returnType; } /// <summary> /// /// </summary> public bool HasArguments { get { return true; } } /// <summary> /// /// </summary> public bool HasParenthesesIfNoArguments { get { return true; } } } } Index: MsSql2000Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** MsSql2000Dialect.cs 30 Jan 2005 20:03:33 -0000 1.24 --- MsSql2000Dialect.cs 1 Mar 2005 16:24:44 -0000 1.25 *************** *** 34,50 **** public MsSql2000Dialect() : base() { ! Register( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! Register( DbType.AnsiStringFixedLength, 8000, "CHAR($1)" ); ! Register( DbType.AnsiString, "VARCHAR(255)" ); ! Register( DbType.AnsiString, 8000, "VARCHAR($1)" ); ! Register( DbType.AnsiString, 2147483647, "TEXT" ); ! Register( DbType.Binary, "VARBINARY(8000)" ); ! Register( DbType.Binary, 8000, "VARBINARY($1)" ); ! Register( DbType.Binary, 2147483647, "IMAGE" ); ! Register( DbType.Boolean, "BIT" ); ! Register( DbType.Byte, "TINYINT" ); ! Register( DbType.Currency, "MONEY" ); ! Register( DbType.Date, "DATETIME" ); ! Register( DbType.DateTime, "DATETIME" ); // TODO: figure out if this is the good way to fix the problem // with exporting a DECIMAL column --- 34,50 ---- public MsSql2000Dialect() : base() { ! RegisterColumnType( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 8000, "CHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, "VARCHAR(255)" ); ! RegisterColumnType( DbType.AnsiString, 8000, "VARCHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, 2147483647, "TEXT" ); ! RegisterColumnType( DbType.Binary, "VARBINARY(8000)" ); ! RegisterColumnType( DbType.Binary, 8000, "VARBINARY($1)" ); ! RegisterColumnType( DbType.Binary, 2147483647, "IMAGE" ); ! RegisterColumnType( DbType.Boolean, "BIT" ); ! RegisterColumnType( DbType.Byte, "TINYINT" ); ! RegisterColumnType( DbType.Currency, "MONEY" ); ! RegisterColumnType( DbType.Date, "DATETIME" ); ! RegisterColumnType( DbType.DateTime, "DATETIME" ); // TODO: figure out if this is the good way to fix the problem // with exporting a DECIMAL column *************** *** 54,71 **** // sql-type="decimal(20,5)" if they need to do that. The Decimal parameter and ddl will get generated // correctly with minimal work. ! Register( DbType.Decimal, "DECIMAL(19,5)" ); ! Register( DbType.Decimal, 19, "DECIMAL(19, $1)" ); ! Register( DbType.Double, "DOUBLE PRECISION" ); //synonym for FLOAT(53) ! Register( DbType.Guid, "UNIQUEIDENTIFIER" ); ! Register( DbType.Int16, "SMALLINT" ); ! Register( DbType.Int32, "INT" ); ! Register( DbType.Int64, "BIGINT" ); ! Register( DbType.Single, "REAL" ); //synonym for FLOAT(24) ! Register( DbType.StringFixedLength, "NCHAR(255)" ); ! Register( DbType.StringFixedLength, 4000, "NCHAR($1)" ); ! Register( DbType.String, "NVARCHAR(255)" ); ! Register( DbType.String, 4000, "NVARCHAR($1)" ); ! Register( DbType.String, 1073741823, "NTEXT" ); ! Register( DbType.Time, "DATETIME" ); DefaultProperties[ Environment.OuterJoin ] = "true"; --- 54,143 ---- // sql-type="decimal(20,5)" if they need to do that. The Decimal parameter and ddl will get generated // correctly with minimal work. ! RegisterColumnType( DbType.Decimal, "DECIMAL(19,5)" ); ! RegisterColumnType( DbType.Decimal, 19, "DECIMAL(19, $1)" ); ! RegisterColumnType( DbType.Double, "DOUBLE PRECISION" ); //synonym for FLOAT(53) ! RegisterColumnType( DbType.Guid, "UNIQUEIDENTIFIER" ); ! RegisterColumnType( DbType.Int16, "SMALLINT" ); ! RegisterColumnType( DbType.Int32, "INT" ); ! RegisterColumnType( DbType.Int64, "BIGINT" ); ! RegisterColumnType( DbType.Single, "REAL" ); //synonym for FLOAT(24) ! RegisterColumnType( DbType.StringFixedLength, "NCHAR(255)" ); ! RegisterColumnType( DbType.StringFixedLength, 4000, "NCHAR($1)" ); ! RegisterColumnType( DbType.String, "NVARCHAR(255)" ); ! RegisterColumnType( DbType.String, 4000, "NVARCHAR($1)" ); ! RegisterColumnType( DbType.String, 1073741823, "NTEXT" ); ! RegisterColumnType( DbType.Time, "DATETIME" ); ! ! RegisterFunction("abs", new StandardSQLFunction() ); ! RegisterFunction("absval", new StandardSQLFunction() ); ! RegisterFunction("sign", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! ! RegisterFunction("ceiling", new StandardSQLFunction() ); ! RegisterFunction("ceil", new StandardSQLFunction() ); ! RegisterFunction("floor", new StandardSQLFunction() ); ! RegisterFunction("round", new StandardSQLFunction() ); ! ! RegisterFunction("acos", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("asin", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("atan", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("cos", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("cot", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("degrees", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("exp", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("float", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("hex", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("ln", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("log", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("log10", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("radians", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("rand", new NoArgSQLFunction( NHibernateUtil.Double )); ! RegisterFunction("sin", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("soundex", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("sqrt", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("stddev", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("tan", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("variance", new StandardSQLFunction( NHibernateUtil.Double ) ); ! ! /* ! RegisterFunction("julian_day", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("microsecond", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("midnight_seconds", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("minute", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("month", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("monthname", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("quarter", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("hour", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("second", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("date", new StandardSQLFunction(Hibernate.DATE) ); ! RegisterFunction("day", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("dayname", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("dayofweek", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("dayofweek_iso", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("dayofyear", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("days", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("time", new StandardSQLFunction( NHibernateUtil.Time ) ); ! RegisterFunction("timestamp", new StandardSQLFunction( NHibernateUtil.Timestamp ) ); ! RegisterFunction("timestamp_iso", new StandardSQLFunction( NHibernateUtil.Timestamp ) ); ! RegisterFunction("week", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("week_iso", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("year", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! ! RegisterFunction("double", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("varchar", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("real", new StandardSQLFunction( NHibernateUtil.Single ) ); ! RegisterFunction("bigint", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("char", new StandardSQLFunction( NHibernateUtil.Character ) ); ! RegisterFunction("integer", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("smallint", new StandardSQLFunction( NHibernateUtil.Int16 ) ); ! */ ! ! RegisterFunction("digits", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("chr", new StandardSQLFunction( NHibernateUtil.Character ) ); ! RegisterFunction("upper", new StandardSQLFunction() ); ! RegisterFunction("ucase", new StandardSQLFunction() ); ! RegisterFunction("lcase", new StandardSQLFunction() ); ! RegisterFunction("lower", new StandardSQLFunction() ); ! RegisterFunction("length", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("ltrim", new StandardSQLFunction() ); DefaultProperties[ Environment.OuterJoin ] = "true"; Index: Oracle9Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Oracle9Dialect.cs 30 Jan 2005 19:39:11 -0000 1.20 --- Oracle9Dialect.cs 1 Mar 2005 16:24:44 -0000 1.21 *************** *** 33,38 **** public class Oracle9Dialect : Dialect { - private readonly IDictionary aggregateFunctions = new Hashtable(); - /// <summary></summary> public Oracle9Dialect() : base() --- 33,36 ---- *************** *** 42,100 **** DefaultProperties[ Environment.ConnectionDriver ] = "NHibernate.Driver.OracleClientDriver"; ! Register( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! Register( DbType.AnsiStringFixedLength, 2000, "CHAR($1)" ); ! Register( DbType.AnsiString, "VARCHAR2(255)" ); ! Register( DbType.AnsiString, 2000, "VARCHAR2($1)" ); ! Register( DbType.AnsiString, 2147483647, "CLOB" ); // should use the IType.ClobType ! Register( DbType.Binary, "RAW(2000)" ); ! Register( DbType.Binary, 2000, "RAW($1)" ); ! Register( DbType.Binary, 2147483647, "BLOB" ); ! Register( DbType.Boolean, "NUMBER(1,0)" ); ! Register( DbType.Byte, "NUMBER(3,0)" ); ! Register( DbType.Currency, "NUMBER(19,1)" ); ! Register( DbType.Date, "DATE" ); ! Register( DbType.DateTime, "DATE" ); ! Register( DbType.Decimal, "NUMBER(19,5)" ); ! Register( DbType.Decimal, 19, "NUMBER(19, $1)" ); // having problems with both ODP and OracleClient from MS not being able // to read values out of a field that is DOUBLE PRECISION ! Register( DbType.Double, "DOUBLE PRECISION" ); //"FLOAT(53)" ); //Oracle does not have a guid datatype ! //Register( DbType.Guid, "UNIQUEIDENTIFIER" ); ! Register( DbType.Int16, "NUMBER(5,0)" ); ! Register( DbType.Int32, "NUMBER(10,0)" ); ! Register( DbType.Int64, "NUMBER(20,0)" ); ! Register( DbType.Single, "FLOAT(24)" ); ! Register( DbType.StringFixedLength, "NCHAR(255)" ); ! Register( DbType.StringFixedLength, 2000, "NCHAR($1)" ); ! Register( DbType.String, "NVARCHAR2(255)" ); ! Register( DbType.String, 2000, "NVARCHAR2($1)" ); ! Register( DbType.String, 1073741823, "NCLOB" ); ! Register( DbType.Time, "DATE" ); ! // add all the functions from the base into this instance ! foreach( DictionaryEntry de in base.AggregateFunctions ) ! { ! aggregateFunctions[ de.Key ] = de.Value; ! } ! aggregateFunctions[ "trunc" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "round" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "abs" ] = new QueryFunctionStandard( NHibernateUtil.Int32 ); ! aggregateFunctions[ "sign" ] = new QueryFunctionStandard( NHibernateUtil.Int32 ); ! aggregateFunctions[ "ceil" ] = new QueryFunctionStandard( NHibernateUtil.Int32 ); ! aggregateFunctions[ "floor" ] = new QueryFunctionStandard( NHibernateUtil.Int32 ); ! aggregateFunctions[ "sqrt" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "exp" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "ln" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "sin" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "sinh" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "cos" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "cosh" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "tan" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "tanh" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "stddev" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "variance" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "sysdate" ] = new SysdateQueryFunctionInfo(); ! aggregateFunctions[ "lastday" ] = new QueryFunctionStandard( NHibernateUtil.Date ); } --- 40,137 ---- DefaultProperties[ Environment.ConnectionDriver ] = "NHibernate.Driver.OracleClientDriver"; ! RegisterColumnType( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 2000, "CHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, "VARCHAR2(255)" ); ! RegisterColumnType( DbType.AnsiString, 2000, "VARCHAR2($1)" ); ! RegisterColumnType( DbType.AnsiString, 2147483647, "CLOB" ); // should use the IType.ClobType ! RegisterColumnType( DbType.Binary, "RAW(2000)" ); ! RegisterColumnType( DbType.Binary, 2000, "RAW($1)" ); ! RegisterColumnType( DbType.Binary, 2147483647, "BLOB" ); ! RegisterColumnType( DbType.Boolean, "NUMBER(1,0)" ); ! RegisterColumnType( DbType.Byte, "NUMBER(3,0)" ); ! RegisterColumnType( DbType.Currency, "NUMBER(19,1)" ); ! RegisterColumnType( DbType.Date, "DATE" ); ! RegisterColumnType( DbType.DateTime, "DATE" ); ! RegisterColumnType( DbType.Decimal, "NUMBER(19,5)" ); ! RegisterColumnType( DbType.Decimal, 19, "NUMBER(19, $1)" ); // having problems with both ODP and OracleClient from MS not being able // to read values out of a field that is DOUBLE PRECISION ! RegisterColumnType( DbType.Double, "DOUBLE PRECISION" ); //"FLOAT(53)" ); //Oracle does not have a guid datatype ! //RegisterColumnType( DbType.Guid, "UNIQUEIDENTIFIER" ); ! RegisterColumnType( DbType.Int16, "NUMBER(5,0)" ); ! RegisterColumnType( DbType.Int32, "NUMBER(10,0)" ); ! RegisterColumnType( DbType.Int64, "NUMBER(20,0)" ); ! RegisterColumnType( DbType.Single, "FLOAT(24)" ); ! RegisterColumnType( DbType.StringFixedLength, "NCHAR(255)" ); ! RegisterColumnType( DbType.StringFixedLength, 2000, "NCHAR($1)" ); ! RegisterColumnType( DbType.String, "NVARCHAR2(255)" ); ! RegisterColumnType( DbType.String, 2000, "NVARCHAR2($1)" ); ! RegisterColumnType( DbType.String, 1073741823, "NCLOB" ); ! RegisterColumnType( DbType.Time, "DATE" ); ! RegisterFunction( "abs", new StandardSQLFunction() ); ! RegisterFunction( "sign", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! ! RegisterFunction( "acos", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "asin", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "atan", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "cos", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "cosh", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "exp", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "ln", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "sin", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "sinh", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "stddev", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "sqrt", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "tan", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "tanh", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "variance", new StandardSQLFunction( NHibernateUtil.Double ) ); ! ! RegisterFunction( "round", new StandardSQLFunction() ); ! RegisterFunction( "trunc", new StandardSQLFunction() ); ! RegisterFunction( "ceil", new StandardSQLFunction() ); ! RegisterFunction( "floor", new StandardSQLFunction() ); ! ! RegisterFunction( "chr", new StandardSQLFunction( NHibernateUtil.Character ) ); ! RegisterFunction( "initcap", new StandardSQLFunction() ); ! RegisterFunction( "lower", new StandardSQLFunction() ); ! RegisterFunction( "ltrim", new StandardSQLFunction() ); ! RegisterFunction( "rtrim", new StandardSQLFunction() ); ! RegisterFunction( "soundex", new StandardSQLFunction() ); ! RegisterFunction( "upper", new StandardSQLFunction() ); ! RegisterFunction( "ascii", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction( "length", new StandardSQLFunction( NHibernateUtil.Int64 ) ); ! ! RegisterFunction( "to_char", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "to_date", new StandardSQLFunction( NHibernateUtil.Timestamp ) ); ! ! RegisterFunction( "lastday", new StandardSQLFunction( NHibernateUtil.Date ) ); ! RegisterFunction( "sysdate", new NoArgSQLFunction( NHibernateUtil.Date, false) ); ! RegisterFunction( "uid", new NoArgSQLFunction( NHibernateUtil.Int32, false) ); ! RegisterFunction( "user", new NoArgSQLFunction( NHibernateUtil.String, false) ); ! ! // Multi-param string dialect functions... ! RegisterFunction( "concat", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "instr", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "instrb", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "lpad", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "replace", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "rpad", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "substr", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "substrb", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "translate", new StandardSQLFunction( NHibernateUtil.String ) ); ! ! // Multi-param numeric dialect functions... ! RegisterFunction( "atan2", new StandardSQLFunction( NHibernateUtil.Single ) ); ! RegisterFunction( "log", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction( "mod", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction( "nvl", new StandardSQLFunction() ); ! RegisterFunction( "power", new StandardSQLFunction( NHibernateUtil.Single ) ); ! ! // Multi-param date dialect functions... ! RegisterFunction( "add_months", new StandardSQLFunction( NHibernateUtil.Date ) ); ! RegisterFunction( "months_between", new StandardSQLFunction( NHibernateUtil.Single ) ); ! RegisterFunction( "next_day", new StandardSQLFunction( NHibernateUtil.Date ) ); } *************** *** 186,230 **** /// <summary></summary> - public override IDictionary AggregateFunctions - { - get { return aggregateFunctions; } - } - - /// <summary></summary> public override bool UseMaxForLimit { get { return true; } } - - /// <summary></summary> - public class SysdateQueryFunctionInfo : IQueryFunctionInfo - { - #region IQueryFunctionInfo Members - - /// <summary> - /// - /// </summary> - /// <param name="columnType"></param> - /// <param name="mapping"></param> - /// <returns></returns> - public IType QueryFunctionType( IType columnType, IMapping mapping ) - { - return NHibernateUtil.Date; - } - - /// <summary></summary> - public bool IsFunctionArgs - { - get { return false; } - } - - /// <summary></summary> - public bool IsFunctionNoArgsUseParanthesis - { - get { return false; } - } - - #endregion - } } } \ No newline at end of file --- 223,230 ---- Index: Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/Dialect.cs,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** Dialect.cs 9 Feb 2005 03:09:38 -0000 1.44 --- Dialect.cs 1 Mar 2005 16:24:44 -0000 1.45 *************** *** 28,33 **** private TypeNames typeNames = new TypeNames( "$1" ); private IDictionary properties = new Hashtable(); ! private static readonly IDictionary aggregateFunctions = new Hashtable(); /// <summary></summary> --- 28,34 ---- private TypeNames typeNames = new TypeNames( "$1" ); private IDictionary properties = new Hashtable(); + private IDictionary sqlFunctions; ! private static readonly IDictionary standardAggregateFunctions = new Hashtable(); /// <summary></summary> *************** *** 39,47 **** static Dialect() { ! aggregateFunctions[ "count" ] = new CountQueryFunctionInfo(); ! aggregateFunctions[ "avg" ] = new AvgQueryFunctionInfo(); ! aggregateFunctions[ "max" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "min" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "sum" ] = new QueryFunctionStandard(); } --- 40,48 ---- static Dialect() { ! standardAggregateFunctions[ "count" ] = new CountQueryFunctionInfo(); ! standardAggregateFunctions[ "avg" ] = new AvgQueryFunctionInfo(); ! standardAggregateFunctions[ "max" ] = new StandardSQLFunction(); ! standardAggregateFunctions[ "min" ] = new StandardSQLFunction(); ! standardAggregateFunctions[ "sum" ] = new StandardSQLFunction(); } *************** *** 63,66 **** --- 64,68 ---- { log.Info( "Using dialect: " + this ); + sqlFunctions = new Hashtable( standardAggregateFunctions ) ; } *************** *** 108,111 **** --- 110,123 ---- /// <summary> + /// + /// </summary> + /// <param name="name"></param> + /// <param name="function"></param> + protected void RegisterFunction( string name, ISQLFunction function ) + { + sqlFunctions.Add( name, function ); + } + + /// <summary> /// Subclasses register a typename for the given type code and maximum /// column length. <c>$1</c> in the type name will be replaced by the column *************** *** 115,119 **** /// <param name="capacity">Maximum length of database type</param> /// <param name="name">The database type name</param> ! protected void Register( DbType code, int capacity, string name ) { typeNames.Put( code, capacity, name ); --- 127,131 ---- /// <param name="capacity">Maximum length of database type</param> /// <param name="name">The database type name</param> ! protected void RegisterColumnType( DbType code, int capacity, string name ) { typeNames.Put( code, capacity, name ); *************** *** 126,130 **** /// <param name="code">The typecode</param> /// <param name="name">The database type name</param> ! protected void Register( DbType code, string name ) { typeNames.Put( code, name ); --- 138,142 ---- /// <param name="code">The typecode</param> /// <param name="name">The database type name</param> ! protected void RegisterColumnType( DbType code, string name ) { typeNames.Put( code, name ); *************** *** 559,565 **** /// specialization's data. /// </remarks> ! public virtual IDictionary AggregateFunctions { ! get { return aggregateFunctions; } } --- 571,577 ---- /// specialization's data. /// </remarks> ! public virtual IDictionary Functions { ! get { return sqlFunctions; } } *************** *** 825,831 **** /// /// </summary> ! public class CountQueryFunctionInfo : IQueryFunctionInfo { ! #region IQueryFunctionInfo Members /// <summary> --- 837,843 ---- /// /// </summary> ! public class CountQueryFunctionInfo : ISQLFunction { ! #region ISQLFunction Members /// <summary> *************** *** 835,851 **** /// <param name="mapping"></param> /// <returns></returns> ! public IType QueryFunctionType( IType columnType, IMapping mapping ) { return NHibernateUtil.Int32; } ! /// <summary></summary> ! public bool IsFunctionArgs { get { return true; } } ! /// <summary></summary> ! public bool IsFunctionNoArgsUseParanthesis { get { return true; } --- 847,867 ---- /// <param name="mapping"></param> /// <returns></returns> ! public IType ReturnType(IType columnType, IMapping mapping) { return NHibernateUtil.Int32; } ! /// <summary> ! /// ! /// </summary> ! public bool HasArguments { get { return true; } } ! /// <summary> ! /// ! /// </summary> ! public bool HasParenthesesIfNoArguments { get { return true; } *************** *** 856,862 **** /// <summary></summary> ! public class AvgQueryFunctionInfo : IQueryFunctionInfo { ! #region IQueryFunctionInfo Members /// <summary> --- 872,878 ---- /// <summary></summary> ! public class AvgQueryFunctionInfo : ISQLFunction { ! #region ISQLFunction Members /// <summary> *************** *** 866,870 **** /// <param name="mapping"></param> /// <returns></returns> ! public IType QueryFunctionType( IType columnType, IMapping mapping ) { SqlType[ ] sqlTypes; --- 882,886 ---- /// <param name="mapping"></param> /// <returns></returns> ! public IType ReturnType(IType columnType, IMapping mapping) { SqlType[ ] sqlTypes; *************** *** 895,906 **** } ! /// <summary></summary> ! public bool IsFunctionArgs { get { return true; } } ! /// <summary></summary> ! public bool IsFunctionNoArgsUseParanthesis { get { return true; } --- 911,926 ---- } ! /// <summary> ! /// ! /// </summary> ! public bool HasArguments { get { return true; } } ! /// <summary> ! /// ! /// </summary> ! public bool HasParenthesesIfNoArguments { get { return true; } |