From: Michael D. <mik...@us...> - 2004-07-19 03:07:14
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12728/NHibernate/SqlTypes Modified Files: AnsiStringFixedLengthSqlType.cs AnsiStringSqlType.cs BinarySqlType.cs BooleanSqlType.cs CurrencySqlType.cs DateTimeSqlType.cs DecimalSqlType.cs DoubleSqlType.cs Int16SqlType.cs Int32SqlType.cs Int64SqlType.cs SingleSqlType.cs SqlType.cs SqlTypeFactory.cs StringFixedLengthSqlType.cs StringSqlType.cs Log Message: Minor mods to SqlTypes that are part of a large batch of changes to schema-export and how IDbCommands are built. Index: DecimalSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/DecimalSqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DecimalSqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- DecimalSqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 2,15 **** using System.Data; ! namespace NHibernate.SqlTypes { ! /// <summary> /// Summary description for DecimalSqlType. /// </summary> ! public class DecimalSqlType : SqlType { ! public DecimalSqlType(byte precision, byte scale) : base(DbType.Decimal, precision, scale) { } - } } --- 2,20 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// Summary description for DecimalSqlType. /// </summary> ! public class DecimalSqlType : SqlType ! { ! public DecimalSqlType() : base(DbType.Decimal) ! { ! } ! ! public DecimalSqlType(byte precision, byte scale) : base(DbType.Decimal, precision, scale) ! { } } } Index: AnsiStringFixedLengthSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/AnsiStringFixedLengthSqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AnsiStringFixedLengthSqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- AnsiStringFixedLengthSqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 2,16 **** using System.Data; ! namespace NHibernate.SqlTypes { ! /// <summary> /// Summary description for AnsiStringFixedLengthSqlType. /// </summary> ! public class AnsiStringFixedLengthSqlType : SqlType { ! public AnsiStringFixedLengthSqlType() : base(DbType.AnsiStringFixedLength, 255) { } public AnsiStringFixedLengthSqlType(int length) : base(DbType.AnsiStringFixedLength, length) { } } } --- 2,20 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// Summary description for AnsiStringFixedLengthSqlType. /// </summary> ! public class AnsiStringFixedLengthSqlType : SqlType ! { ! public AnsiStringFixedLengthSqlType() ! : base(DbType.AnsiStringFixedLength) ! { } public AnsiStringFixedLengthSqlType(int length) : base(DbType.AnsiStringFixedLength, length) { } + } } Index: AnsiStringSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/AnsiStringSqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AnsiStringSqlType.cs 18 Mar 2004 14:58:56 -0000 1.1 --- AnsiStringSqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 10,16 **** --- 10,21 ---- public class AnsiStringSqlType : SqlType { + public AnsiStringSqlType() : base(DbType.AnsiString) + { + } public AnsiStringSqlType(int length) : base(DbType.AnsiString, length) { } + + } } Index: StringSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/StringSqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StringSqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- StringSqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 2,12 **** using System.Data; ! namespace NHibernate.SqlTypes { ! /// <summary> /// Summary description for StringSqlType. /// </summary> ! public class StringSqlType : SqlType { ! public StringSqlType(int length) : base(DbType.String, length) { } } --- 2,17 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// Summary description for StringSqlType. /// </summary> ! public class StringSqlType : SqlType ! { ! public StringSqlType() : base(DbType.String) ! { ! } ! public StringSqlType(int length) : base(DbType.String, length) ! { } } Index: Int64SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/Int64SqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Int64SqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- Int64SqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 2,14 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> /// Summary description for Int64SqlType. /// </summary> ! public class Int64SqlType : SqlType{ ! ! public Int64SqlType(): base(DbType.Int64) { } - } } \ No newline at end of file --- 2,15 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// Summary description for Int64SqlType. /// </summary> ! public class Int64SqlType : SqlType ! { ! public Int64SqlType(): base(DbType.Int64) ! { } } } \ No newline at end of file Index: SqlTypeFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SqlTypeFactory.cs 18 Mar 2004 14:58:56 -0000 1.5 --- SqlTypeFactory.cs 19 Jul 2004 03:07:04 -0000 1.6 *************** *** 4,8 **** namespace NHibernate.SqlTypes { - /// <summary> /// SqlTypeFactory provides Singleton access to the SqlTypes. --- 4,7 ---- *************** *** 10,14 **** public class SqlTypeFactory { - // key = typeof(sqlType).Name : ie - BinarySqlType(l), BooleanSqlType, DecimalSqlType(p,s) // value = SqlType --- 9,12 ---- *************** *** 144,155 **** } ! public static DoubleSqlType GetDouble(int length) { ! string key = GetKeyForLengthBased(typeof(DoubleSqlType).Name, length); DoubleSqlType returnSqlType = (DoubleSqlType)sqlTypes[key]; if(returnSqlType==null) { ! returnSqlType = new DoubleSqlType(length); sqlTypes.Add(key, returnSqlType); } --- 142,153 ---- } ! public static DoubleSqlType GetDouble() { ! string key = typeof(DoubleSqlType).Name; DoubleSqlType returnSqlType = (DoubleSqlType)sqlTypes[key]; if(returnSqlType==null) { ! returnSqlType = new DoubleSqlType(); sqlTypes.Add(key, returnSqlType); } *************** *** 214,225 **** } ! public static SingleSqlType GetSingle(int length) { ! string key = GetKeyForLengthBased(typeof(SingleSqlType).Name, length); SingleSqlType returnSqlType = (SingleSqlType)sqlTypes[key]; if(returnSqlType==null) { ! returnSqlType = new SingleSqlType(length); sqlTypes.Add(key, returnSqlType); } --- 212,223 ---- } ! public static SingleSqlType GetSingle() { ! string key = typeof(SingleSqlType).Name; SingleSqlType returnSqlType = (SingleSqlType)sqlTypes[key]; if(returnSqlType==null) { ! returnSqlType = new SingleSqlType(); sqlTypes.Add(key, returnSqlType); } Index: BooleanSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/BooleanSqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BooleanSqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- BooleanSqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 2,12 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> /// Summary description for BooleanSqlType. /// </summary> ! public class BooleanSqlType : SqlType { ! public BooleanSqlType() : base(DbType.Boolean){ } } --- 2,15 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// Summary description for BooleanSqlType. /// </summary> ! public class BooleanSqlType : SqlType ! { ! public BooleanSqlType() : base(DbType.Boolean) ! { } } Index: CurrencySqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/CurrencySqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CurrencySqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- CurrencySqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 11,19 **** /// is no advantage to using it. /// </summary> ! public class CurrencySqlType : SqlType{ ! ! public CurrencySqlType() : base(DbType.Currency) { } - } } --- 11,19 ---- /// is no advantage to using it. /// </summary> ! public class CurrencySqlType : SqlType ! { ! public CurrencySqlType() : base(DbType.Currency) ! { } } } Index: StringFixedLengthSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/StringFixedLengthSqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StringFixedLengthSqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- StringFixedLengthSqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 2,13 **** using System.Data; ! namespace NHibernate.SqlTypes { ! /// <summary> /// Summary description for StringFixedLengthSqlType. /// </summary> ! public class StringFixedLengthSqlType : SqlType { ! public StringFixedLengthSqlType(int length) : base(DbType.StringFixedLength, length) { } --- 2,18 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// Summary description for StringFixedLengthSqlType. /// </summary> ! public class StringFixedLengthSqlType : SqlType ! { ! public StringFixedLengthSqlType() : base(DbType.StringFixedLength) ! { ! } ! public StringFixedLengthSqlType(int length) : base(DbType.StringFixedLength, length) ! { } Index: DoubleSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/DoubleSqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DoubleSqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- DoubleSqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 2,13 **** using System.Data; ! namespace NHibernate.SqlTypes { ! /// <summary> /// Summary description for DoubleSqlType. /// </summary> ! public class DoubleSqlType : SqlType { ! ! public DoubleSqlType(int length) : base(DbType.Double, length) { } } --- 2,14 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// Summary description for DoubleSqlType. /// </summary> ! public class DoubleSqlType : SqlType ! { ! public DoubleSqlType() : base(DbType.Double) ! { } } Index: Int16SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/Int16SqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Int16SqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- Int16SqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 2,14 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> /// Summary description for Int16SqlType. /// </summary> ! public class Int16SqlType : SqlType{ ! ! public Int16SqlType(): base(DbType.Int16) { } - } } --- 2,15 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// Summary description for Int16SqlType. /// </summary> ! public class Int16SqlType : SqlType ! { ! public Int16SqlType(): base(DbType.Int16) ! { } } } Index: Int32SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/Int32SqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Int32SqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- Int32SqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 2,12 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> /// Summary description for Int32SqlType. /// </summary> ! public class Int32SqlType : SqlType{ ! ! public Int32SqlType(): base(DbType.Int32) { } --- 2,14 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// Summary description for Int32SqlType. /// </summary> ! public class Int32SqlType : SqlType ! { ! public Int32SqlType(): base(DbType.Int32) ! { } Index: SingleSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/SingleSqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SingleSqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- SingleSqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 2,13 **** using System.Data; ! namespace NHibernate.SqlTypes { ! /// <summary> /// Summary description for SingleSqlType. /// </summary> ! public class SingleSqlType : SqlType { ! ! public SingleSqlType(int length) : base(DbType.Single, length) { } } --- 2,14 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// Summary description for SingleSqlType. /// </summary> ! public class SingleSqlType : SqlType ! { ! public SingleSqlType() : base(DbType.Single) ! { } } Index: DateTimeSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/DateTimeSqlType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DateTimeSqlType.cs 15 Mar 2004 15:33:19 -0000 1.2 --- DateTimeSqlType.cs 19 Jul 2004 03:07:04 -0000 1.3 *************** *** 2,12 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> /// Summary description for DateTimeSqlType. /// </summary> ! public class DateTimeSqlType : SqlType { ! ! public DateTimeSqlType() : base(DbType.DateTime) { } } --- 2,14 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// Summary description for DateTimeSqlType. /// </summary> ! public class DateTimeSqlType : SqlType ! { ! public DateTimeSqlType() : base(DbType.DateTime) ! { } } Index: BinarySqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/BinarySqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BinarySqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- BinarySqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 7,13 **** /// Summary description for BinarySqlType. /// </summary> ! public class BinarySqlType : SqlType { ! public BinarySqlType(int length) : base (DbType.Binary, length) { } } --- 7,18 ---- /// Summary description for BinarySqlType. /// </summary> ! public class BinarySqlType : SqlType ! { ! public BinarySqlType() : base (DbType.Binary) ! { ! } ! public BinarySqlType(int length) : base (DbType.Binary, length) ! { } } Index: SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/SqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SqlType.cs 10 Feb 2004 18:40:14 -0000 1.1 --- SqlType.cs 19 Jul 2004 03:07:04 -0000 1.2 *************** *** 2,16 **** using System.Data; ! namespace NHibernate.SqlTypes { ! /// <summary> /// This is the base class that describes the DbType in further detail so we ! /// can prepare the IDbCommands. Each SqlType has a default length & precision/scale ! /// that can get overriden in the hbm files. /// /// It is expected that each Dialect will be the one responsible for converting these /// objects to the sql string when using SchemaExport. /// </summary> ! public abstract class SqlType { protected DbType dbType; --- 2,17 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// This is the base class that describes the DbType in further detail so we ! /// can prepare the IDbCommands. Certain SqlTypes have a default length or ! /// precision/scale that can get overriden in the hbm files. /// /// It is expected that each Dialect will be the one responsible for converting these /// objects to the sql string when using SchemaExport. /// </summary> ! public abstract class SqlType ! { protected DbType dbType; *************** *** 22,30 **** protected bool precisionDefined = false; ! protected SqlType(DbType dbType){ this.dbType = dbType; } ! protected SqlType(DbType dbType, int length){ this.dbType = dbType; this.length = length; --- 23,33 ---- protected bool precisionDefined = false; ! protected SqlType(DbType dbType) ! { this.dbType = dbType; } ! protected SqlType(DbType dbType, int length) ! { this.dbType = dbType; this.length = length; *************** *** 32,36 **** } ! protected SqlType(DbType dbType, byte precision, byte scale) { this.dbType = dbType; this.precision = precision; --- 35,40 ---- } ! protected SqlType(DbType dbType, byte precision, byte scale) ! { this.dbType = dbType; this.precision = precision; *************** *** 39,63 **** } ! public DbType DbType { get { return dbType;} } ! public int Length { get { return length;} } ! public byte Precision { get { return precision;} } ! public byte Scale { get { return scale;} } ! public bool LengthDefined { get { return lengthDefined;} } ! public bool PrecisionDefined { get { return precisionDefined;} } --- 43,73 ---- } ! public DbType DbType ! { get { return dbType;} } ! public int Length ! { get { return length;} } ! public byte Precision ! { get { return precision;} } ! public byte Scale ! { get { return scale;} } ! public bool LengthDefined ! { get { return lengthDefined;} } ! public bool PrecisionDefined ! { get { return precisionDefined;} } *************** *** 65,78 **** #region overrides of Object methods ! public override int GetHashCode() { int hashCode = 0; ! if(lengthDefined) { hashCode = (dbType.GetHashCode()/2) + (length.GetHashCode()/2); } ! else if(precisionDefined) { hashCode = (dbType.GetHashCode()/3) + (precision.GetHashCode()/3) + (scale.GetHashCode()/3); } ! else { hashCode = dbType.GetHashCode(); } --- 75,92 ---- #region overrides of Object methods ! public override int GetHashCode() ! { int hashCode = 0; ! if(lengthDefined) ! { hashCode = (dbType.GetHashCode()/2) + (length.GetHashCode()/2); } ! else if(precisionDefined) ! { hashCode = (dbType.GetHashCode()/3) + (precision.GetHashCode()/3) + (scale.GetHashCode()/3); } ! else ! { hashCode = dbType.GetHashCode(); } *************** *** 81,85 **** } ! public override bool Equals(object obj) { bool equals = false; SqlType rhsSqlType; --- 95,100 ---- } ! public override bool Equals(object obj) ! { bool equals = false; SqlType rhsSqlType; *************** *** 94,107 **** //Step 3: Check each important field ! if(lengthDefined){ equals = (dbType.Equals(rhsSqlType.DbType)) && (length==rhsSqlType.Length); } ! else if (precisionDefined) { equals = (dbType.Equals(rhsSqlType.DbType)) && (precision==rhsSqlType.Precision) && (scale==rhsSqlType.Scale); } ! else { equals = (dbType.Equals(rhsSqlType.DbType)); } --- 109,125 ---- //Step 3: Check each important field ! if(lengthDefined) ! { equals = (dbType.Equals(rhsSqlType.DbType)) && (length==rhsSqlType.Length); } ! else if (precisionDefined) ! { equals = (dbType.Equals(rhsSqlType.DbType)) && (precision==rhsSqlType.Precision) && (scale==rhsSqlType.Scale); } ! else ! { equals = (dbType.Equals(rhsSqlType.DbType)); } |