You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael D. <mik...@us...> - 2004-07-19 13:52:35
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv790/Dialect Modified Files: MySQLDialect.cs Log Message: Fixed a few minor problems with using MySql database. Still have not figured out why we can't write to a varchar(x) binary field. Index: MySQLDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/MySQLDialect.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** MySQLDialect.cs 19 Jul 2004 03:24:02 -0000 1.17 --- MySQLDialect.cs 19 Jul 2004 13:52:26 -0000 1.18 *************** *** 16,36 **** { Register( DbType.AnsiStringFixedLength, "CHAR(255)"); - Register( DbType.AnsiStringFixedLength, 16777215, "MEDIUMTEXT" ); - Register( DbType.AnsiStringFixedLength, 65535, "TEXT" ); Register( DbType.AnsiStringFixedLength, 255, "CHAR($1)" ); Register( DbType.AnsiString, "VARCHAR(255)" ); - Register( DbType.AnsiString, 16777215, "MEDIUMTEXT" ); - Register( DbType.AnsiString, 65535, "TEXT" ); Register( DbType.AnsiString, 255, "VARCHAR($1)" ); Register( DbType.Binary, "LONGBLOB"); - Register( DbType.Binary, 16777215, "MEDIUMBLOB"); - Register( DbType.Binary, 65535, "BLOB"); Register( DbType.Binary, 255, "VARCHAR($1) BINARY"); ! Register( DbType.Boolean, "TINYTINT(1)" ); Register( DbType.Byte, "TINYINT UNSIGNED" ); Register( DbType.Currency, "MONEY"); Register( DbType.Date, "DATE"); Register( DbType.DateTime, "DATETIME" ); ! Register( DbType.Decimal, "NUMERIC(19, $1)"); Register( DbType.Double, "FLOAT" ); Register( DbType.Int16, "SMALLINT" ); --- 16,37 ---- { 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, 255, "VARCHAR($1) BINARY"); ! 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, "FLOAT" ); Register( DbType.Int16, "SMALLINT" ); *************** *** 39,49 **** Register( DbType.Single, "FLOAT" ); Register( DbType.StringFixedLength, "CHAR(255)"); - Register( DbType.StringFixedLength, 16777215, "MEDIUMTEXT" ); - Register( DbType.StringFixedLength, 65535, "TEXT" ); Register( DbType.StringFixedLength, 255, "CHAR($1)" ); Register( DbType.String, "VARCHAR(255)" ); - Register( DbType.String, 16777215, "MEDIUMTEXT" ); - Register( DbType.String, 65535, "TEXT" ); Register( DbType.String, 255, "VARCHAR($1)" ); Register( DbType.Time, "TIME" ); --- 40,50 ---- 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" ); |
From: Michael D. <mik...@us...> - 2004-07-19 03:25:35
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/SqlCommandTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15450/NHibernate.Test/SqlCommandTest Modified Files: SqlDeleteBuilderFixture.cs SqlInsertBuilderFixture.cs SqlSelectBuilderFixture.cs SqlSimpleSelectBuilderFixture.cs SqlStringParameterFixture.cs SqlUpdateBuilderFixture.cs Log Message: Updated test with changes made to how IDbCommands are prepared. Index: SqlDeleteBuilderFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlDeleteBuilderFixture.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SqlDeleteBuilderFixture.cs 30 Apr 2004 04:43:08 -0000 1.2 --- SqlDeleteBuilderFixture.cs 19 Jul 2004 03:25:25 -0000 1.3 *************** *** 52,66 **** Parameter firstParam = new Parameter(); ! firstParam.DbType = DbType.Decimal; firstParam.Name = "decimalColumn"; Parameter secondParam = new Parameter(); ! secondParam.DbType = DbType.Int32; secondParam.Name = "versionColumn"; ! Assertion.AssertEquals("firstParam Type", firstParam.DbType, actualParams[0].DbType); Assertion.AssertEquals("firstParam Name", firstParam.Name, actualParams[0].Name); ! Assertion.AssertEquals("secondParam Type", secondParam.DbType, actualParams[1].DbType); Assertion.AssertEquals("secondParam Name", secondParam.Name, actualParams[1].Name); --- 52,66 ---- Parameter firstParam = new Parameter(); ! firstParam.SqlType = new SqlTypes.DecimalSqlType(); firstParam.Name = "decimalColumn"; Parameter secondParam = new Parameter(); ! secondParam.SqlType = new SqlTypes.Int32SqlType(); secondParam.Name = "versionColumn"; ! Assertion.AssertEquals("firstParam Type", firstParam.SqlType.DbType, actualParams[0].SqlType.DbType); Assertion.AssertEquals("firstParam Name", firstParam.Name, actualParams[0].Name); ! Assertion.AssertEquals("secondParam Type", secondParam.SqlType.DbType, actualParams[1].SqlType.DbType); Assertion.AssertEquals("secondParam Name", secondParam.Name, actualParams[1].Name); Index: SqlSimpleSelectBuilderFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlSimpleSelectBuilderFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SqlSimpleSelectBuilderFixture.cs 20 Mar 2004 23:08:55 -0000 1.1 --- SqlSimpleSelectBuilderFixture.cs 19 Jul 2004 03:25:25 -0000 1.2 *************** *** 71,92 **** Parameter firstParam = new Parameter(); ! firstParam.DbType = DbType.Int64; firstParam.Name = "identity_column"; Parameter secondParam = new Parameter(); ! secondParam.DbType = DbType.Int32; secondParam.Name = "version_column"; Parameter thirdParam = new Parameter(); ! thirdParam.DbType = DbType.Int32; thirdParam.Name = "where_frag_column"; ! Assertion.AssertEquals("First Parameter Type", firstParam.DbType, actualParams[0].DbType); Assertion.AssertEquals("First Parameter Name", firstParam.Name, actualParams[0].Name); ! Assertion.AssertEquals("Second Parameter Type", secondParam.DbType, actualParams[1].DbType); Assertion.AssertEquals("Second Parameter Name", secondParam.Name, actualParams[1].Name); ! Assertion.AssertEquals("Third Parameter Type", thirdParam.DbType, actualParams[2].DbType); Assertion.AssertEquals("Third Parameter Name", thirdParam.Name, actualParams[2].Name); --- 71,92 ---- Parameter firstParam = new Parameter(); ! firstParam.SqlType = new SqlTypes.Int64SqlType(); firstParam.Name = "identity_column"; Parameter secondParam = new Parameter(); ! secondParam.SqlType = new SqlTypes.Int32SqlType(); secondParam.Name = "version_column"; Parameter thirdParam = new Parameter(); ! thirdParam.SqlType = new SqlTypes.Int32SqlType(); thirdParam.Name = "where_frag_column"; ! Assertion.AssertEquals("First Parameter Type", firstParam.SqlType.DbType, actualParams[0].SqlType.DbType); Assertion.AssertEquals("First Parameter Name", firstParam.Name, actualParams[0].Name); ! Assertion.AssertEquals("Second Parameter Type", secondParam.SqlType.DbType, actualParams[1].SqlType.DbType); Assertion.AssertEquals("Second Parameter Name", secondParam.Name, actualParams[1].Name); ! Assertion.AssertEquals("Third Parameter Type", thirdParam.SqlType.DbType, actualParams[2].SqlType.DbType); Assertion.AssertEquals("Third Parameter Name", thirdParam.Name, actualParams[2].Name); Index: SqlUpdateBuilderFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlUpdateBuilderFixture.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SqlUpdateBuilderFixture.cs 30 Apr 2004 04:43:08 -0000 1.2 --- SqlUpdateBuilderFixture.cs 19 Jul 2004 03:25:25 -0000 1.3 *************** *** 59,87 **** Parameter firstParam = new Parameter(); ! firstParam.DbType = DbType.Int32; firstParam.Name = "intColumn"; Parameter secondParam = new Parameter(); ! secondParam.DbType = DbType.Int64; secondParam.Name = "longColumn"; Parameter thirdParam = new Parameter(); ! thirdParam.DbType = DbType.Decimal; thirdParam.Name = "decimalColumn"; Parameter fourthParam = new Parameter(); ! fourthParam.DbType = DbType.Int32; fourthParam.Name = "versionColumn"; ! Assertion.AssertEquals("firstParam Type", firstParam.DbType, actualParams[0].DbType); Assertion.AssertEquals("firstParam Name", firstParam.Name, actualParams[0].Name); ! Assertion.AssertEquals("secondParam Type", secondParam.DbType, actualParams[1].DbType); Assertion.AssertEquals("secondParam Name", secondParam.Name, actualParams[1].Name); ! Assertion.AssertEquals("thirdParam Type", thirdParam.DbType, actualParams[2].DbType); Assertion.AssertEquals("thirdParam Name", thirdParam.Name, actualParams[2].Name); ! Assertion.AssertEquals("fourthParam Type", fourthParam.DbType, actualParams[3].DbType); Assertion.AssertEquals("fourthParam Name", fourthParam.Name, actualParams[3].Name); --- 59,87 ---- Parameter firstParam = new Parameter(); ! firstParam.SqlType = new SqlTypes.Int32SqlType(); firstParam.Name = "intColumn"; Parameter secondParam = new Parameter(); ! secondParam.SqlType = new SqlTypes.Int64SqlType(); secondParam.Name = "longColumn"; Parameter thirdParam = new Parameter(); ! thirdParam.SqlType = new SqlTypes.DecimalSqlType(); thirdParam.Name = "decimalColumn"; Parameter fourthParam = new Parameter(); ! fourthParam.SqlType = new SqlTypes.Int32SqlType(); fourthParam.Name = "versionColumn"; ! Assertion.AssertEquals("firstParam Type", firstParam.SqlType.DbType, actualParams[0].SqlType.DbType); Assertion.AssertEquals("firstParam Name", firstParam.Name, actualParams[0].Name); ! Assertion.AssertEquals("secondParam Type", secondParam.SqlType.DbType, actualParams[1].SqlType.DbType); Assertion.AssertEquals("secondParam Name", secondParam.Name, actualParams[1].Name); ! Assertion.AssertEquals("thirdParam Type", thirdParam.SqlType.DbType, actualParams[2].SqlType.DbType); Assertion.AssertEquals("thirdParam Name", thirdParam.Name, actualParams[2].Name); ! Assertion.AssertEquals("fourthParam Type", fourthParam.SqlType.DbType, actualParams[3].SqlType.DbType); Assertion.AssertEquals("fourthParam Name", fourthParam.Name, actualParams[3].Name); Index: SqlStringParameterFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlStringParameterFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SqlStringParameterFixture.cs 20 Mar 2004 23:08:55 -0000 1.1 --- SqlStringParameterFixture.cs 19 Jul 2004 03:25:25 -0000 1.2 *************** *** 23,27 **** Parameter cloned = null; ! original.DbType = DbType.Int32; original.Name = "originalName"; --- 23,27 ---- Parameter cloned = null; ! original.SqlType = new SqlTypes.Int32SqlType(); original.Name = "originalName"; *************** *** 29,41 **** Assertion.Assert("Not the same object by ==", (original==cloned)==false); ! Assertion.AssertEquals("Same DbType", original.DbType, cloned.DbType); Assertion.AssertEquals("Same Name", original.Name, cloned.Name); // change some of the values of the clone to ensure the original doesn't change ! cloned.DbType = DbType.String; cloned.Name = "Cloned name"; ! Assertion.Assert("Should not the same db type anymore", cloned.DbType!=original.DbType); Assertion.Assert("Should not the same name anymore", cloned.Name!=original.Name); --- 29,41 ---- Assertion.Assert("Not the same object by ==", (original==cloned)==false); ! Assertion.AssertEquals("Same DbType", original.SqlType.DbType, cloned.SqlType.DbType); Assertion.AssertEquals("Same Name", original.Name, cloned.Name); // change some of the values of the clone to ensure the original doesn't change ! cloned.SqlType = new SqlTypes.StringSqlType(); cloned.Name = "Cloned name"; ! Assertion.Assert("Should not the same db type anymore", cloned.SqlType.DbType!=original.SqlType.DbType); Assertion.Assert("Should not the same name anymore", cloned.Name!=original.Name); *************** *** 49,53 **** ParameterLength cloned = null; ! original.DbType = DbType.String; original.Name = "originalName"; original.Length = 275; --- 49,53 ---- ParameterLength cloned = null; ! original.SqlType = new SqlTypes.StringSqlType(275); original.Name = "originalName"; original.Length = 275; *************** *** 56,60 **** Assertion.Assert("Not the same object by ==", (original==cloned)==false); ! Assertion.AssertEquals("Same DbType", original.DbType, cloned.DbType); Assertion.AssertEquals("Same Name", original.Name, cloned.Name); Assertion.AssertEquals("Same Length", original.Length, cloned.Length); --- 56,60 ---- Assertion.Assert("Not the same object by ==", (original==cloned)==false); ! Assertion.AssertEquals("Same DbType", original.SqlType.DbType, cloned.SqlType.DbType); Assertion.AssertEquals("Same Name", original.Name, cloned.Name); Assertion.AssertEquals("Same Length", original.Length, cloned.Length); *************** *** 62,70 **** // change some of the values of the clone to ensure the original doesn't change ! cloned.DbType = DbType.AnsiString; cloned.Name = "Cloned name"; cloned.Length = 175; ! Assertion.Assert("Should not the same db type anymore", cloned.DbType!=original.DbType); Assertion.Assert("Should not the same name anymore", cloned.Name!=original.Name); Assertion.Assert("Should not the same length anymore", cloned.Length!=original.Length); --- 62,70 ---- // change some of the values of the clone to ensure the original doesn't change ! cloned.SqlType = new SqlTypes.AnsiStringSqlType(175); cloned.Name = "Cloned name"; cloned.Length = 175; ! Assertion.Assert("Should not the same db type anymore", cloned.SqlType.DbType!=original.SqlType.DbType); Assertion.Assert("Should not the same name anymore", cloned.Name!=original.Name); Assertion.Assert("Should not the same length anymore", cloned.Length!=original.Length); *************** *** 78,82 **** ParameterPrecisionScale cloned = null; ! original.DbType = DbType.Decimal; original.Name = "originalName"; original.Precision = 19; --- 78,82 ---- ParameterPrecisionScale cloned = null; ! original.SqlType = new SqlTypes.DecimalSqlType(19, 5); original.Name = "originalName"; original.Precision = 19; *************** *** 86,90 **** Assertion.Assert("Not the same object by ==", (original==cloned)==false); ! Assertion.AssertEquals("Same DbType", original.DbType, cloned.DbType); Assertion.AssertEquals("Same Name", original.Name, cloned.Name); Assertion.AssertEquals("Same Precision", original.Precision, cloned.Precision); --- 86,90 ---- Assertion.Assert("Not the same object by ==", (original==cloned)==false); ! Assertion.AssertEquals("Same DbType", original.SqlType.DbType, cloned.SqlType.DbType); Assertion.AssertEquals("Same Name", original.Name, cloned.Name); Assertion.AssertEquals("Same Precision", original.Precision, cloned.Precision); *************** *** 95,104 **** // I know AnsiString is not a precision based but for this example we just need // to make sure the clonging is working... ! cloned.DbType = DbType.AnsiString; cloned.Name = "Cloned name"; cloned.Precision = 15; cloned.Scale = 4; ! Assertion.Assert("Should not the same db type anymore", cloned.DbType!=original.DbType); Assertion.Assert("Should not the same name anymore", cloned.Name!=original.Name); Assertion.Assert("Should not the same Precision anymore", cloned.Precision!=original.Precision); --- 95,104 ---- // I know AnsiString is not a precision based but for this example we just need // to make sure the clonging is working... ! cloned.SqlType = new SqlTypes.AnsiStringSqlType(); cloned.Name = "Cloned name"; cloned.Precision = 15; cloned.Scale = 4; ! Assertion.Assert("Should not the same db type anymore", cloned.SqlType.DbType!=original.SqlType.DbType); Assertion.Assert("Should not the same name anymore", cloned.Name!=original.Name); Assertion.Assert("Should not the same Precision anymore", cloned.Precision!=original.Precision); *************** *** 119,127 **** origParams[0] = new Parameter(); ! origParams[0].DbType = DbType.Int32; origParams[0].Name = "OP1"; origParams[1] = new Parameter(); ! origParams[1].DbType = DbType.Int64; origParams[1].Name = "OP2"; --- 119,127 ---- origParams[0] = new Parameter(); ! origParams[0].SqlType = new SqlTypes.Int32SqlType(); origParams[0].Name = "OP1"; origParams[1] = new Parameter(); ! origParams[1].SqlType = new SqlTypes.Int64SqlType(); origParams[1].Name = "OP2"; Index: SqlSelectBuilderFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlSelectBuilderFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SqlSelectBuilderFixture.cs 20 Mar 2004 23:08:55 -0000 1.1 --- SqlSelectBuilderFixture.cs 19 Jul 2004 03:25:25 -0000 1.2 *************** *** 66,74 **** Parameter firstParam = new Parameter(); ! firstParam.DbType = DbType.Int64; firstParam.TableAlias = "select_test_alias"; firstParam.Name = "identity_column"; ! Assertion.AssertEquals("First Parameter Type", firstParam.DbType, expectedParam.DbType); Assertion.AssertEquals("First Parameter TableAlias", firstParam.TableAlias, expectedParam.TableAlias); Assertion.AssertEquals("First Parameter Name", firstParam.Name, expectedParam.Name); --- 66,74 ---- Parameter firstParam = new Parameter(); ! firstParam.SqlType = new SqlTypes.Int64SqlType(); firstParam.TableAlias = "select_test_alias"; firstParam.Name = "identity_column"; ! Assertion.AssertEquals("First Parameter Type", firstParam.SqlType.DbType, expectedParam.SqlType.DbType); Assertion.AssertEquals("First Parameter TableAlias", firstParam.TableAlias, expectedParam.TableAlias); Assertion.AssertEquals("First Parameter Name", firstParam.Name, expectedParam.Name); Index: SqlInsertBuilderFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlInsertBuilderFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SqlInsertBuilderFixture.cs 20 Mar 2004 23:08:55 -0000 1.1 --- SqlInsertBuilderFixture.cs 19 Jul 2004 03:25:25 -0000 1.2 *************** *** 53,67 **** Parameter firstParam = new Parameter(); ! firstParam.DbType = DbType.Int32; firstParam.Name = "intColumn"; Parameter secondParam = new Parameter(); ! secondParam.DbType = DbType.Int64; secondParam.Name = "longColumn"; ! Assertion.AssertEquals("First Parameter Type", firstParam.DbType, actualParams[0].DbType); Assertion.AssertEquals("First Parameter Name", firstParam.Name, actualParams[0].Name); ! Assertion.AssertEquals("Second Parameter Type", secondParam.DbType, actualParams[1].DbType); Assertion.AssertEquals("Second Parameter Name", secondParam.Name, actualParams[1].Name); --- 53,67 ---- Parameter firstParam = new Parameter(); ! firstParam.SqlType = new SqlTypes.Int32SqlType(); firstParam.Name = "intColumn"; Parameter secondParam = new Parameter(); ! secondParam.SqlType = new SqlTypes.Int64SqlType(); secondParam.Name = "longColumn"; ! Assertion.AssertEquals("First Parameter Type", firstParam.SqlType.DbType, actualParams[0].SqlType.DbType); Assertion.AssertEquals("First Parameter Name", firstParam.Name, actualParams[0].Name); ! Assertion.AssertEquals("Second Parameter Type", secondParam.SqlType.DbType, actualParams[1].SqlType.DbType); Assertion.AssertEquals("Second Parameter Name", secondParam.Name, actualParams[1].Name); |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15450/NHibernate.Test/ExpressionTest Modified Files: BetweenExpressionFixture.cs InExpressionFixture.cs InsensitiveLikeExpressionFixture.cs NotExpressionFixture.cs SimpleExpressionFixture.cs Log Message: Updated test with changes made to how IDbCommands are prepared. Index: BetweenExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/BetweenExpressionFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BetweenExpressionFixture.cs 20 Mar 2004 23:08:55 -0000 1.1 --- BetweenExpressionFixture.cs 19 Jul 2004 03:25:25 -0000 1.2 *************** *** 32,36 **** Parameter firstBetweenParam = new Parameter(); ! firstBetweenParam.DbType = DbType.Int32; firstBetweenParam.TableAlias = "simple_alias"; firstBetweenParam.Name = "count__lo"; --- 32,36 ---- Parameter firstBetweenParam = new Parameter(); ! firstBetweenParam.SqlType = new SqlTypes.Int32SqlType(); firstBetweenParam.TableAlias = "simple_alias"; firstBetweenParam.Name = "count__lo"; *************** *** 38,42 **** Parameter secondBetweenParam = new Parameter(); ! secondBetweenParam.DbType = DbType.Int32; secondBetweenParam.TableAlias = "simple_alias"; secondBetweenParam.Name = "count__hi"; --- 38,42 ---- Parameter secondBetweenParam = new Parameter(); ! secondBetweenParam.SqlType = new SqlTypes.Int32SqlType(); secondBetweenParam.TableAlias = "simple_alias"; secondBetweenParam.Name = "count__hi"; Index: SimpleExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/SimpleExpressionFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SimpleExpressionFixture.cs 20 Mar 2004 23:08:55 -0000 1.1 --- SimpleExpressionFixture.cs 19 Jul 2004 03:25:25 -0000 1.2 *************** *** 27,31 **** public void SimpleSqlStringTest() { - ISession session = factory.OpenSession(); --- 27,30 ---- *************** *** 37,44 **** Parameter[] expectedParams = new Parameter[1]; ! ParameterLength firstAndParam = new ParameterLength(); ! firstAndParam.DbType = DbType.String; firstAndParam.TableAlias = "simple_alias"; - firstAndParam.Length = 200; firstAndParam.Name = "address"; --- 36,46 ---- Parameter[] expectedParams = new Parameter[1]; ! // even though a String parameter is a Size based Parameter it will not ! // be a ParameterLength unless in the mapping file it is defined as ! // type="String(200)" -> in the mapping file it is now defined as ! // type="String" length="200" ! Parameter firstAndParam = new Parameter(); ! firstAndParam.SqlType = new SqlTypes.StringSqlType(); firstAndParam.TableAlias = "simple_alias"; firstAndParam.Name = "address"; Index: InExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/InExpressionFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** InExpressionFixture.cs 20 Mar 2004 23:08:55 -0000 1.1 --- InExpressionFixture.cs 19 Jul 2004 03:25:25 -0000 1.2 *************** *** 36,40 **** { Parameter param = new Parameter(); ! param.DbType = DbType.Int32; param.TableAlias = "simple_alias"; param.Name = "count_" + "_" + i; --- 36,40 ---- { Parameter param = new Parameter(); ! param.SqlType = new SqlTypes.Int32SqlType(); param.TableAlias = "simple_alias"; param.Name = "count_" + "_" + i; Index: InsensitiveLikeExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/InsensitiveLikeExpressionFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** InsensitiveLikeExpressionFixture.cs 20 Mar 2004 23:08:55 -0000 1.1 --- InsensitiveLikeExpressionFixture.cs 19 Jul 2004 03:25:25 -0000 1.2 *************** *** 32,41 **** Parameter[] expectedParams = new Parameter[1]; ! ParameterLength firstParam = new ParameterLength(); ! firstParam.DbType = DbType.String; firstParam.TableAlias = "simple_alias"; firstParam.Name = "address"; ! firstParam.Length = 200; ! expectedParams[0] = firstParam; --- 32,40 ---- Parameter[] expectedParams = new Parameter[1]; ! Parameter firstParam = new Parameter(); ! firstParam.SqlType = new SqlTypes.StringSqlType(); firstParam.TableAlias = "simple_alias"; firstParam.Name = "address"; ! expectedParams[0] = firstParam; Index: NotExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/NotExpressionFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NotExpressionFixture.cs 20 Mar 2004 23:08:55 -0000 1.1 --- NotExpressionFixture.cs 19 Jul 2004 03:25:25 -0000 1.2 *************** *** 31,35 **** Parameter firstParam = new Parameter(); ! firstParam.DbType = DbType.String; firstParam.TableAlias = "simple_alias"; firstParam.Name = "address"; --- 31,35 ---- Parameter firstParam = new Parameter(); ! firstParam.SqlType = new SqlTypes.StringSqlType(); firstParam.TableAlias = "simple_alias"; firstParam.Name = "address"; |
From: Michael D. <mik...@us...> - 2004-07-19 03:24:54
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15260/NHibernate Modified Files: NHibernate-1.1.csproj Log Message: Readded TypeNames to get schema-export working like hibernate. Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** NHibernate-1.1.csproj 2 Jul 2004 17:11:55 -0000 1.30 --- NHibernate-1.1.csproj 19 Jul 2004 03:24:34 -0000 1.31 *************** *** 501,504 **** --- 501,509 ---- /> <File + RelPath = "Dialect\TypeNames.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Driver\ByteFXDataDriver.cs" SubType = "Code" |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/NHibernate/Dialect Modified Files: Dialect.cs FirebirdDialect.cs GenericDialect.cs MsSql2000Dialect.cs MySQLDialect.cs Oracle9Dialect.cs Added Files: TypeNames.cs Log Message: Readded typeNames to get schema-export working like hibernate. Index: Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/Dialect.cs,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Dialect.cs 11 Jul 2004 21:04:13 -0000 1.33 --- Dialect.cs 19 Jul 2004 03:24:02 -0000 1.34 *************** *** 26,29 **** --- 26,32 ---- private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Dialect)); + private TypeNames typeNames = new TypeNames("$1"); + private IDictionary properties = new Hashtable(); + private static readonly IDictionary aggregateFunctions = new Hashtable(); *************** *** 41,44 **** --- 44,60 ---- } + /// <summary> + /// The base constructor for Dialect. + /// </summary> + /// <remarks> + /// Every subclass should override this and call Register() with every <see cref="DbType"/> except + /// <see cref="DbType.Object"/>, <see cref="DbType.SByte"/>, <see cref="DbType.UInt16"/>, <see cref="DbType.UInt32"/>, + /// <see cref="DbType.UInt64"/>, <see cref="DbType.VarNumeric"/>. + /// + /// <para> + /// The Default properties for this Dialect should also be set - such as whether or not to use outer-joins + /// and what the batch size should be. + /// </para> + /// </remarks> protected Dialect() { *************** *** 46,50 **** } - private IDictionary properties = new Hashtable(); /// <summary> --- 62,65 ---- *************** *** 55,58 **** --- 70,133 ---- /// <summary> + /// Get the name of the database type associated with the given + /// <see cref="NHibernate.SqlTypes.SqlType"/>, + /// </summary> + /// <param name="code">The SqlType</param> + /// <returns>The database type name used by ddl.</returns> + public virtual string GetTypeName(SqlType sqlType) + { + string result = typeNames.Get(sqlType.DbType); + if(result==null) + { + throw new HibernateException( "No default type mapping for SqlType " + sqlType.ToString() ); + } + + return result; + } + + /// <summary> + /// Get the name of the database type associated with the given + /// <see cref="SqlType"/>. + /// </summary> + /// <param name="sqlType">The SqlType </param> + /// <param name="length">The length of the SqlType</param> + /// <returns>The database type name used by ddl.</returns> + public virtual string GetTypeName(SqlType sqlType, int length) + { + string result = typeNames.Get(sqlType.DbType, length); + if(result==null) + { + throw new HibernateException( "No type mapping for SqlType " + sqlType.ToString() + " of length " + length ); + } + return result; + } + + /// <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 + /// length (if appropriate) + /// </summary> + /// <param name="code">The typecode</param> + /// <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); + } + + /// <summary> + /// Suclasses register a typename for the given type code. <c>$1</c> in the + /// typename will be replaced by the column length (if appropriate). + /// </summary> + /// <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); + } + + + + /// <summary> /// Does this dialect support the <c>ALTER TABLE</c> syntax? /// </summary> *************** *** 260,264 **** { string dialectName = Cfg.Environment.Properties[Cfg.Environment.Dialect] as string; ! if (dialectName==null) throw new HibernateException("The dialect was not set. Set the property hibernate.dialect."); try { --- 335,339 ---- { string dialectName = Cfg.Environment.Properties[Cfg.Environment.Dialect] as string; ! if (dialectName==null) throw new HibernateException("The dialect was not set. Set the property hibernate.dialect."); try { *************** *** 458,702 **** - /// <summary> ! /// Converts the SqlType to the Dialect specific column type string used when ! /// <c>CREATE</c>ing the table. /// </summary> - /// <param name="sqlType">The SqlType to convert to a string</param> - /// <returns>A string that can be used in the table CREATE statement.</returns> /// <remarks> /// <para> ! /// This method uses SqlType.DbType to call the appropriate protected method of SqlTypeToString(). ! /// All Dialects should override the SqlTypeToString methods because that is where the underlying ! /// SqlType is converted to a string. /// </para> /// </remarks> ! public string SqlTypeToString(SqlType sqlType) ! { ! switch(sqlType.DbType) ! { ! case DbType.AnsiString: ! return SqlTypeToString((AnsiStringSqlType)sqlType); ! case DbType.AnsiStringFixedLength: ! return SqlTypeToString((AnsiStringFixedLengthSqlType)sqlType); ! case DbType.Binary : ! return SqlTypeToString((BinarySqlType)sqlType); ! case DbType.Boolean : ! return SqlTypeToString((BooleanSqlType)sqlType); ! case DbType.Byte: ! return SqlTypeToString((ByteSqlType)sqlType); ! case DbType.Currency: ! return SqlTypeToString((CurrencySqlType)sqlType); ! case DbType.Date: ! return SqlTypeToString((DateSqlType)sqlType); ! case DbType.DateTime: ! return SqlTypeToString((DateTimeSqlType)sqlType); ! case DbType.Decimal: ! return SqlTypeToString((DecimalSqlType)sqlType); ! case DbType.Double: ! return SqlTypeToString((DoubleSqlType)sqlType); ! case DbType.Guid: ! return SqlTypeToString((GuidSqlType)sqlType); ! case DbType.Int16: ! return SqlTypeToString((Int16SqlType)sqlType); ! case DbType.Int32: ! return SqlTypeToString((Int32SqlType)sqlType); ! case DbType.Int64: ! return SqlTypeToString((Int64SqlType)sqlType); ! case DbType.Single: ! return SqlTypeToString((SingleSqlType)sqlType); ! case DbType.StringFixedLength: ! return SqlTypeToString((StringFixedLengthSqlType)sqlType); ! case DbType.String: ! return SqlTypeToString((StringSqlType)sqlType); ! case DbType.Time: ! return SqlTypeToString((TimeSqlType)sqlType); ! default: ! throw new ApplicationException("Unmapped DBType"); ! //break; ! } ! ! } ! ! /// <summary> ! /// Converts an AnsiStringSqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(AnsiStringSqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an AnsiStringFixedLengthSqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(AnsiStringFixedLengthSqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an BinarySqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(BinarySqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an BooleanSqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(BooleanSqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an ByteSqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(ByteSqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an CurrencySqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(CurrencySqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an DateSqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(DateSqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an DateTimeSqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(DateTimeSqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an DecimalSqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(DecimalSqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an DoubleSqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(DoubleSqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an GuidSqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(GuidSqlType sqlType) { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); } /// <summary> ! /// Converts an Int16SqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(Int16SqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an Int32SqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(Int32SqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an Int64SqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(Int64SqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an SingleSqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(SingleSqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an StringFixedLengthSqlType to the Database specific column type. ! /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(StringFixedLengthSqlType sqlType) ! { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); ! } ! ! /// <summary> ! /// Converts an StringSqlType to the Database specific column type. /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(StringSqlType sqlType) { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); } /// <summary> ! /// Converts an TimeSqlType to the Database specific column type. /// </summary> ! /// <param name="sqlType">The SqlType to convert to a string.</param> ! /// <returns>A string that can be used for the column type when creating the table.</returns> ! protected virtual string SqlTypeToString(TimeSqlType sqlType) { ! throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); } - /// <summary> --- 533,592 ---- /// <summary> ! /// The largest value that can be set in IDbDataParameter.Size for a parameter ! /// that contains an AnsiString. /// </summary> /// <remarks> /// <para> ! /// Setting the value to 0 indicates that there is no Maximum Size or that it ! /// does not need to be set to Prepare the IDbCommand. ! /// </para> ! /// <para> ! /// Currently the only Driver that needs to worry about setting the Param size ! /// is MsSql /// </para> /// </remarks> ! public virtual int MaxAnsiStringSize { ! get { throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); } } /// <summary> ! /// The largest value that can be set in IDbDataParameter.Size for a parameter ! /// that contains a Binary. /// </summary> ! /// <remarks> ! /// <para> ! /// Setting the value to 0 indicates that there is no Maximum Size or that it ! /// does not need to be set to Prepare the IDbCommand. ! /// </para> ! /// <para> ! /// Currently the only Driver that needs to worry about setting the Param size ! /// is MsSql ! /// </para> ! /// </remarks> ! public virtual int MaxBinarySize { ! get { throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); } } /// <summary> ! /// The largest value that can be set in IDbDataParameter.Size for a parameter ! /// that contains an Unicode String. /// </summary> ! /// <remarks> ! /// <para> ! /// Setting the value to 0 indicates that there is no Maximum Size or that it ! /// does not need to be set to Prepare the IDbCommand. ! /// </para> ! /// <para> ! /// Currently the only Driver that needs to worry about setting the Param size ! /// is MsSql ! /// </para> ! /// </remarks> ! public virtual int MaxStringSize { ! get { throw new NotImplementedException("should be implemented by subclass - this will be converted to abstract"); } } /// <summary> Index: FirebirdDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/FirebirdDialect.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FirebirdDialect.cs 20 Mar 2004 03:37:59 -0000 1.5 --- FirebirdDialect.cs 19 Jul 2004 03:24:02 -0000 1.6 *************** *** 12,15 **** --- 12,41 ---- 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, "BLOB(8000) SUB_TYPE 0"); + Register( DbType.Binary, 8000, "BLOB($1) SUB_TYPE 0"); + 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(19,0)" ); // NUMERIC(19,0) is equivalent to DECIMAL(19,0) + Register( DbType.Decimal, 19, "DECIMAL(19, $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" ); } *************** *** 41,171 **** get { return true; } } - - - private string SqlTypeToString(string name, int length) - { - return name + "(" + length + ")"; - } - - private string SqlTypeToString(string name, int precision, int scale) - { - if (precision > 18) precision = 18; - return name + "(" + precision + ", " + scale + ")"; - } - - protected override string SqlTypeToString(AnsiStringFixedLengthSqlType sqlType) - { - - if(sqlType.Length <= 8000) - { - return SqlTypeToString("CHAR", sqlType.Length); - } - else - { - return "BLOB SUB_TYPE 1"; // should use the IType.ClobType - } - - } - - protected override string SqlTypeToString(BinarySqlType sqlType) - { - return "BLOB SUB_TYPE 0"; // should use the IType.BlobType - } - - protected override string SqlTypeToString(BooleanSqlType sqlType) - { - return "SMALLINT"; - } - - protected override string SqlTypeToString(ByteSqlType sqlType) - { - return "SMALLINT"; - } - - protected override string SqlTypeToString(CurrencySqlType sqlType) - { - return "DECIMAL(16,4)"; - } - - protected override string SqlTypeToString(DateSqlType sqlType) - { - return "DATE"; - } - - protected override string SqlTypeToString(DateTimeSqlType sqlType) - { - return "TIMESTAMP"; - } - - protected override string SqlTypeToString(DecimalSqlType sqlType) - { - return SqlTypeToString("DECIMAL", sqlType.Precision, sqlType.Scale); - } - - protected override string SqlTypeToString(DoubleSqlType sqlType) - { - return "DOUBLE PRECISION"; - } - - protected override string SqlTypeToString(Int16SqlType sqlType) - { - return "SMALLINT"; - } - - protected override string SqlTypeToString(Int32SqlType sqlType) - { - return "INTEGER"; - } - - protected override string SqlTypeToString(Int64SqlType sqlType) - { - return "BIGINT"; - } - - protected override string SqlTypeToString(SingleSqlType sqlType) - { - return "FLOAT"; - } - - protected override string SqlTypeToString(StringFixedLengthSqlType sqlType) - { - if(sqlType.Length <= 4000) - { - return SqlTypeToString("CHAR", sqlType.Length); - } - else - { - return "BLOB SUB_TYPE 1"; // should use the IType.ClobType - } - } - - protected override string SqlTypeToString(StringSqlType sqlType) - { - if(sqlType.Length <= 4000) - { - return SqlTypeToString("VARCHAR", sqlType.Length); - } - else - { - return "BLOB SUB_TYPE 1"; - } - } - - protected override string SqlTypeToString(TimeSqlType sqlType) - { - return "TIME"; - } - - protected override string SqlTypeToString(AnsiStringSqlType sqlType) - { - if(sqlType.Length <= 4000) - { - return SqlTypeToString("CHAR", sqlType.Length); - } - else - { - return "BLOB SUB_TYPE 1"; // should use the IType.ClobType - } - } } } --- 67,70 ---- Index: MsSql2000Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** MsSql2000Dialect.cs 11 Jul 2004 21:04:13 -0000 1.13 --- MsSql2000Dialect.cs 19 Jul 2004 03:24:02 -0000 1.14 *************** *** 15,18 **** --- 15,58 ---- 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"); // should use the IType.ClobType + // TODO: figure out how to support this - VARCHAR > 8000 since + // there is no DbType.CLOB - might just make it a mapping + // requirement that they specify a sql-type or make NHibernate's + // own DbType enum or use SqlType as the key for Register + //Register( DbType.AnsiString, "TEXT" ); + Register( DbType.Binary, "VARBINARY(8000)"); + Register( DbType.Binary, 8000, "VARBINARY($1)"); + Register( DbType.Binary, 2147483647, "IMAGE" );// should use the IType.BlobType + Register( DbType.Boolean, "BIT" ); //Sybase BIT type does not support null values + 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 + // NUMERIC(precision, scale) has a hardcoded precision of 19, even though it can range from 1 to 38 + // and the scale has to be 0 <= scale <= precision. + // I think how I might handle it is keep the type="Decimal(29,5)" and make them specify a + // 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" );// should use the IType.ClobType + Register( DbType.Time, "DATETIME" ); + DefaultProperties[Cfg.Environment.OuterJoin] = "true"; DefaultProperties[Cfg.Environment.StatementBatchSize] = NoBatch; *************** *** 87,90 **** --- 127,146 ---- } + public override int MaxAnsiStringSize + { + get { return 8000; } + } + + public override int MaxBinarySize + { + get { return 8000; } + } + + public override int MaxStringSize + { + get { return 4000; } + } + + protected override char CloseQuote { *************** *** 118,265 **** return quoted.Replace( new string(CloseQuote, 2), CloseQuote.ToString() ); } - - private string SqlTypeToString(string name, int length) - { - return name + "(" + length + ")"; - } - - private string SqlTypeToString(string name, int precision, int scale) - { - return name + "(" + precision + ", " + scale + ")"; - } - - protected override string SqlTypeToString(AnsiStringSqlType sqlType) - { - if(sqlType.Length <= 8000) - { - return SqlTypeToString("VARCHAR", sqlType.Length); - } - else - { - return "TEXT"; // should use the IType.ClobType - } - } - - protected override string SqlTypeToString(AnsiStringFixedLengthSqlType sqlType) - { - - if(sqlType.Length <= 8000) - { - return SqlTypeToString("CHAR", sqlType.Length); - } - else - { - return "TEXT"; // should use the IType.ClobType - } - - } - - protected override string SqlTypeToString(BinarySqlType sqlType) - { - - if(sqlType.Length <= 8000) - { - return SqlTypeToString("VARBINARY", sqlType.Length); - } - else - { - return "IMAGE"; // should use the IType.BlobType - } - - } - - protected override string SqlTypeToString(BooleanSqlType sqlType) - { - return "BIT"; - } - - - protected override string SqlTypeToString(ByteSqlType sqlType) - { - return "TINYINT"; - } - - protected override string SqlTypeToString(CurrencySqlType sqlType) - { - return "MONEY"; - } - - protected override string SqlTypeToString(DateSqlType sqlType) - { - return "DATETIME"; - } - - protected override string SqlTypeToString(DateTimeSqlType sqlType) - { - return "DATETIME"; - } - - protected override string SqlTypeToString(TimeSqlType sqlType) - { - return "DATETIME"; - } - - protected override string SqlTypeToString(DecimalSqlType sqlType) - { - return SqlTypeToString("DECIMAL", sqlType.Precision, sqlType.Scale); - } - - protected override string SqlTypeToString(DoubleSqlType sqlType) - { - return SqlTypeToString("FLOAT", sqlType.Length); - } - - protected override string SqlTypeToString(GuidSqlType sqlType) - { - return "UNIQUEIDENTIFIER"; - } - - protected override string SqlTypeToString(Int16SqlType sqlType) - { - return "SMALLINT"; - } - - protected override string SqlTypeToString(Int32SqlType sqlType) - { - return "INT"; - } - - protected override string SqlTypeToString(Int64SqlType sqlType) - { - return "BIGINT"; - } - - protected override string SqlTypeToString(SingleSqlType sqlType) - { - return SqlTypeToString("FLOAT", sqlType.Length); - } - - protected override string SqlTypeToString(StringFixedLengthSqlType sqlType) - { - - if(sqlType.Length <= 4000) - { - return SqlTypeToString("NCHAR", sqlType.Length); - } - else - { - return "NTEXT"; // should use the IType.ClobType - } - - } - - protected override string SqlTypeToString(StringSqlType sqlType) { - - if(sqlType.Length <= 4000) - { - return SqlTypeToString("NVARCHAR", sqlType.Length); - } - else - { - return "NTEXT"; - } - - } - } } --- 174,177 ---- Index: Oracle9Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Oracle9Dialect.cs 11 Jul 2004 21:04:13 -0000 1.9 --- Oracle9Dialect.cs 19 Jul 2004 03:24:02 -0000 1.10 *************** *** 28,31 **** --- 28,60 ---- DefaultProperties[Cfg.Environment.OuterJoin] = "true"; + 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, "VARBINARY($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)"); + Register( DbType.Double, "DOUBLE PRECISION" ); + //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" ); + 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) *************** *** 109,116 **** p1.Name = "p1"; ! p1.DbType = DbType.Int16; p2.Name = "p2"; ! p2.DbType = DbType.Int16; /* --- 138,145 ---- p1.Name = "p1"; ! p1.SqlType = new Int16SqlType(); p2.Name = "p2"; ! p2.SqlType = new Int16SqlType(); /* *************** *** 163,275 **** - - private string SqlTypeToString(string name, int length) - { - return name + "(" + length + ")"; - } - - private string SqlTypeToString(string name, int precision, int scale) - { - if (precision > 19) precision = 19; - return name + "(" + precision + ", " + scale + ")"; - } - - protected override string SqlTypeToString(AnsiStringFixedLengthSqlType sqlType) - { - return SqlTypeToString("NVARCHAR2", 1000); - } - - protected override string SqlTypeToString(BinarySqlType sqlType) - { - if(sqlType.Length <= 8000) - { - return SqlTypeToString("RAW", sqlType.Length); - } - else - { - return "BLOB"; // should use the IType.BlobType - } - } - - protected override string SqlTypeToString(BooleanSqlType sqlType) - { - return "NUMBER(1,0)"; - } - - - protected override string SqlTypeToString(ByteSqlType sqlType) - { - return "NUMBER(3,0)"; - } - - protected override string SqlTypeToString(CurrencySqlType sqlType) - { - return "NUMBER(19, 1)"; - } - - protected override string SqlTypeToString(DateSqlType sqlType) - { - return "DATE"; - } - - protected override string SqlTypeToString(DateTimeSqlType sqlType) - { - return "DATE"; - } - - protected override string SqlTypeToString(DecimalSqlType sqlType) - { - return SqlTypeToString("NUMBER", sqlType.Precision, sqlType.Scale); - } - - protected override string SqlTypeToString(DoubleSqlType sqlType) - { - return "DOUBLE PRECISION"; - } - - protected override string SqlTypeToString(Int16SqlType sqlType) - { - return "NUMBER(5,0)"; - } - - protected override string SqlTypeToString(Int32SqlType sqlType) - { - return "NUMBER(10,0)"; - } - - protected override string SqlTypeToString(Int64SqlType sqlType) - { - return "NUMBER(20,0)"; - } - - protected override string SqlTypeToString(SingleSqlType sqlType) - { - return "FLOAT"; - } - - protected override string SqlTypeToString(StringFixedLengthSqlType sqlType) - { - if(sqlType.Length <= 2000) - { - return SqlTypeToString("NVARCHAR2", sqlType.Length); - } - else - { - return string.Empty; // should use the IType.ClobType - } - } - - protected override string SqlTypeToString(StringSqlType sqlType) - { - if(sqlType.Length <= 2000) - { - return SqlTypeToString("NVARCHAR2", sqlType.Length); - } - else - { - return string.Empty; // should use the IType.ClobType - } - } - public class SysdateQueryFunctionInfo : IQueryFunctionInfo { --- 192,195 ---- --- NEW FILE: TypeNames.cs --- using System; using System.Collections; using System.Data; using NHibernate.Util; namespace NHibernate.Dialect { /// <summary> /// This class maps a DbType to names. /// </summary> /// <remarks> /// Associations may be marked with a capacity. Calling the <c>Get()</c> /// method with a type and actual size n will return the associated /// name with smallest capacity >= n, if available and an unmarked /// default type otherwise. /// Eg, setting /// <code> /// Names.Put(DbType, "TEXT" ); /// Names.Put(DbType, 255, "VARCHAR($1)" ); /// Names.Put(DbType, 65534, "LONGVARCHAR($1)" ); /// </code> /// will give you back the following: /// <code> /// Names.Get(DbType) // --> "TEXT" (default) /// Names.Get(DbType,100) // --> "VARCHAR(100)" (100 is in [0:255]) /// Names.Get(DbType,1000) // --> "LONGVARCHAR(1000)" (100 is in [256:65534]) /// Names.Get(DbType,100000) // --> "TEXT" (default) /// </code> /// On the other hand, simply putting /// <code> /// Names.Put(DbType, "VARCHAR($1)" ); /// </code> /// would result in /// <code> /// Names.Get(DbType) // --> "VARCHAR($1)" (will cause trouble) /// Names.Get(DbType,100) // --> "VARCHAR(100)" /// Names.Get(DbType,1000) // --> "VARCHAR(1000)" /// Names.Get(DbType,10000) // --> "VARCHAR(10000)" /// </code> /// </remarks> public class TypeNames { private string placeholder; private Hashtable weighted = new Hashtable(); private Hashtable defaults = new Hashtable(); /// <summary> /// Constructor. /// </summary> /// <param name="placeholder">String to be replaced by actual size/length in type names</param> public TypeNames(string placeholder) { this.placeholder = placeholder; } /// <summary> /// Get default type name for specified type /// </summary> /// <param name="typecode">the type key</param> /// <returns>the default type name associated with the specified key</returns> public string Get(DbType typecode) { return (string) defaults[typecode]; } /// <summary> /// Get the type name specified type and size /// </summary> /// <param name="typecode">the type key</param> /// <param name="size">the (maximum) type size/length</param> /// <returns> /// The associated name with smallest capacity >= size if available and the /// default type name otherwise /// </returns> public string Get(DbType typecode, int size) { IDictionary map = weighted[typecode] as IDictionary; if (map != null && map.Count > 0) { foreach(int entrySize in map.Keys) { if (size <= entrySize) { return StringHelper.ReplaceOnce( (string) map[entrySize], placeholder, size.ToString() ); } } } return StringHelper.ReplaceOnce(Get(typecode), placeholder, size.ToString()); } /// <summary> /// Set a type name for specified type key and capacity /// </summary> /// <param name="typecode">the type key</param> /// <param name="size">the (maximum) type size/length</param> /// <param name="value">The associated name</param> public void Put(DbType typecode, int capacity, string value) { SequencedHashMap map = weighted[ typecode ] as SequencedHashMap; if (map==null) { weighted[typecode] = map = new SequencedHashMap(); } map[capacity] = value; } public void Put(DbType typecode, string value) { defaults[typecode] = value; } } } Index: GenericDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/GenericDialect.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** GenericDialect.cs 19 May 2004 04:14:18 -0000 1.8 --- GenericDialect.cs 19 Jul 2004 03:24:02 -0000 1.9 *************** *** 4,121 **** using NHibernate.SqlTypes; ! namespace NHibernate.Dialect { ! /// <summary> /// A generic SQL dialect which may or may not work on any actual databases /// </summary> ! public class GenericDialect : Dialect { ! ! public GenericDialect() : base() { ! } ! ! public override string AddColumnString { ! get { return "add column"; } ! } ! ! private string SqlTypeToString(string name, int length) ! { ! return name + "(" + length + ")"; ! } ! ! private string SqlTypeToString(string name, int precision, int scale) ! { ! return name + "(" + precision + ", " + scale + ")"; ! } ! ! protected override string SqlTypeToString(AnsiStringSqlType sqlType) ! { ! return SqlTypeToString("VARCHAR", sqlType.Length); ! } ! ! protected override string SqlTypeToString(AnsiStringFixedLengthSqlType sqlType) ! { ! return SqlTypeToString("CHAR", sqlType.Length); ! } ! ! protected override string SqlTypeToString(BinarySqlType sqlType) ! { ! return SqlTypeToString("VARBINARY", sqlType.Length); ! } ! ! protected override string SqlTypeToString(BooleanSqlType sqlType) ! { ! return "BIT"; ! } ! ! ! protected override string SqlTypeToString(ByteSqlType sqlType) ! { ! return "TINYINT"; ! } ! ! protected override string SqlTypeToString(CurrencySqlType sqlType) ! { ! return "MONEY"; ! } ! ! protected override string SqlTypeToString(DateSqlType sqlType) ! { ! return "DATETIME"; ! } ! ! protected override string SqlTypeToString(DateTimeSqlType sqlType) ! { ! return "DATETIME"; ! } ! ! protected override string SqlTypeToString(TimeSqlType sqlType) ! { ! return "DATETIME"; ! } ! ! protected override string SqlTypeToString(DecimalSqlType sqlType) ! { ! return SqlTypeToString("DECIMAL", sqlType.Precision, sqlType.Scale); ! } ! ! protected override string SqlTypeToString(DoubleSqlType sqlType) ! { ! return SqlTypeToString("FLOAT", sqlType.Length); ! } ! ! protected override string SqlTypeToString(GuidSqlType sqlType) ! { ! return "UNIQUEIDENTIFIER"; ! } ! ! protected override string SqlTypeToString(Int16SqlType sqlType) ! { ! return "SMALLINT"; ! } ! ! protected override string SqlTypeToString(Int32SqlType sqlType) ! { ! return "INTEGER"; ! } ! ! protected override string SqlTypeToString(Int64SqlType sqlType) ! { ! return "BIGINT"; ! } ! ! protected override string SqlTypeToString(SingleSqlType sqlType) { ! return SqlTypeToString("FLOAT", sqlType.Length); } ! protected override string SqlTypeToString(StringFixedLengthSqlType sqlType) { ! return SqlTypeToString("NCHAR", sqlType.Length); } - protected override string SqlTypeToString(StringSqlType sqlType) - { - return SqlTypeToString("NVARCHAR", sqlType.Length); - } } } --- 4,42 ---- using NHibernate.SqlTypes; ! namespace NHibernate.Dialect ! { /// <summary> /// A generic SQL dialect which may or may not work on any actual databases /// </summary> ! public class GenericDialect : Dialect ! { ! 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" ); ! } ! public override string AddColumnString { ! get { return "add column"; } } } } Index: MySQLDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/MySQLDialect.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** MySQLDialect.cs 11 Jul 2004 21:04:13 -0000 1.16 --- MySQLDialect.cs 19 Jul 2004 03:24:02 -0000 1.17 *************** *** 9,13 **** { /// <summary> ! /// An SQL dialect for MySQL /// </summary> public class MySQLDialect : Dialect --- 9,13 ---- { /// <summary> ! /// A SQL dialect for MySQL /// </summary> public class MySQLDialect : Dialect *************** *** 15,18 **** --- 15,51 ---- public MySQLDialect() : base() { + Register( DbType.AnsiStringFixedLength, "CHAR(255)"); + Register( DbType.AnsiStringFixedLength, 16777215, "MEDIUMTEXT" ); + Register( DbType.AnsiStringFixedLength, 65535, "TEXT" ); + Register( DbType.AnsiStringFixedLength, 255, "CHAR($1)" ); + Register( DbType.AnsiString, "VARCHAR(255)" ); + Register( DbType.AnsiString, 16777215, "MEDIUMTEXT" ); + Register( DbType.AnsiString, 65535, "TEXT" ); + Register( DbType.AnsiString, 255, "VARCHAR($1)" ); + Register( DbType.Binary, "LONGBLOB"); + Register( DbType.Binary, 16777215, "MEDIUMBLOB"); + Register( DbType.Binary, 65535, "BLOB"); + Register( DbType.Binary, 255, "VARCHAR($1) BINARY"); + Register( DbType.Boolean, "TINYTINT(1)" ); + Register( DbType.Byte, "TINYINT UNSIGNED" ); + Register( DbType.Currency, "MONEY"); + Register( DbType.Date, "DATE"); + Register( DbType.DateTime, "DATETIME" ); + Register( DbType.Decimal, "NUMERIC(19, $1)"); + Register( DbType.Double, "FLOAT" ); + Register( DbType.Int16, "SMALLINT" ); + Register( DbType.Int32, "INTEGER" ); + Register( DbType.Int64, "BIGINT" ); + Register( DbType.Single, "FLOAT" ); + Register( DbType.StringFixedLength, "CHAR(255)"); + Register( DbType.StringFixedLength, 16777215, "MEDIUMTEXT" ); + Register( DbType.StringFixedLength, 65535, "TEXT" ); + Register( DbType.StringFixedLength, 255, "CHAR($1)" ); + Register( DbType.String, "VARCHAR(255)" ); + Register( DbType.String, 16777215, "MEDIUMTEXT" ); + Register( DbType.String, 65535, "TEXT" ); + Register( DbType.String, 255, "VARCHAR($1)" ); + Register( DbType.Time, "TIME" ); + DefaultProperties[Cfg.Environment.OuterJoin] = "true"; DefaultProperties[Cfg.Environment.StatementBatchSize] = DefaultBatchSize; *************** *** 75,238 **** .ToString(); } - - private string SqlTypeToString(string name, int length) - { - return name + "(" + length + ")"; - } - - private string SqlTypeToString(string name, int precision, int scale) - { - return name + "(" + precision + ", " + scale + ")"; - } - - protected override string SqlTypeToString(AnsiStringFixedLengthSqlType sqlType) - { - - if(sqlType.Length <= 255) - { - return SqlTypeToString("CHAR", sqlType.Length); - } - else if(sqlType.Length <= 65535) - { - return "TEXT"; - } - else if(sqlType.Length <= 16777215) - { - return "MEDIUMTEXT"; - } - else - { - return "LONGTEXT"; - } - - } - - protected override string SqlTypeToString(BinarySqlType sqlType) - { - - if(sqlType.Length <= 255) - { - //return SqlTypeToString("VARBINARY", sqlType.Length); - return "TINYBLOB"; - } - else if (sqlType.Length <= 65535) - { - return "BLOB"; - } - else if (sqlType.Length <= 16777215) - { - return "MEDIUMBLOB"; - } - else { - return "LONGBLOB"; - } - - } - - protected override string SqlTypeToString(BooleanSqlType sqlType) - { - return "TINYINT(1)"; - } - - - protected override string SqlTypeToString(ByteSqlType sqlType) - { - return "TINYINT UNSIGNED"; - } - - protected override string SqlTypeToString(CurrencySqlType sqlType) - { - return "MONEY"; - } - - protected override string SqlTypeToString(DateSqlType sqlType) - { - return "DATE"; - } - - protected override string SqlTypeToString(DateTimeSqlType sqlType) - { - return "DATETIME"; - } - - protected override string SqlTypeToString(DecimalSqlType sqlType) - { - return SqlTypeToString("NUMERIC", sqlType.Precision, sqlType.Scale); - } - - protected override string SqlTypeToString(DoubleSqlType sqlType) - { - return SqlTypeToString("FLOAT", sqlType.Length); - } - - protected override string SqlTypeToString(Int16SqlType sqlType) - { - return "SMALLINT"; - } - - protected override string SqlTypeToString(Int32SqlType sqlType) - { - return "INTEGER"; - } - - protected override string SqlTypeToString(Int64SqlType sqlType) - { - return "BIGINT"; - } - - protected override string SqlTypeToString(SingleSqlType sqlType) - { - return SqlTypeToString("FLOAT", sqlType.Length); - } - - protected override string SqlTypeToString(StringFixedLengthSqlType sqlType) - { - - if(sqlType.Length <= 255) - { - return SqlTypeToString("CHAR", sqlType.Length); - } - else if(sqlType.Length <= 65535) - { - return "TEXT"; - } - else if(sqlType.Length <= 16777215) - { - return "MEDIUMTEXT"; - } - else - { - return "LONGTEXT"; - } - - } - - protected override string SqlTypeToString(StringSqlType sqlType) - { - - if(sqlType.Length <= 255) - { - return SqlTypeToString("VARCHAR", sqlType.Length); - } - else if(sqlType.Length <= 65535) - { - return "TEXT"; - } - else if(sqlType.Length <= 16777215) - { - return "MEDIUMTEXT"; - } - else - { - return "LONGTEXT"; - } - - } - - protected override string SqlTypeToString(TimeSqlType sqlType) - { - return "TIME"; - } - } } --- 108,111 ---- |
From: Michael D. <mik...@us...> - 2004-07-19 03:24:20
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/NHibernate/Mapping Modified Files: Column.cs Log Message: Readded typeNames to get schema-export working like hibernate. Index: Column.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Column.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Column.cs 16 Apr 2004 04:13:22 -0000 1.11 --- Column.cs 19 Jul 2004 03:24:03 -0000 1.12 *************** *** 132,141 **** { SqlType sqlTypeObject = GetAutoSqlType(mapping); ! // if(sqlTypeObject!=null) { ! return dialect.SqlTypeToString(sqlTypeObject); ! // } ! // else { ! // returnString = dialect.GetTypeName( GetAutoDbType(mapping), Length ); ! // } } else --- 132,136 ---- { SqlType sqlTypeObject = GetAutoSqlType(mapping); ! return dialect.GetTypeName( sqlTypeObject, Length ); } else *************** *** 144,147 **** --- 139,143 ---- } } + public override bool Equals(object obj) |
From: Michael D. <mik...@us...> - 2004-07-19 03:23:22
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15025/NHibernate/Id Modified Files: TableGenerator.cs Log Message: Modified to use Driver to generate the IDbCommand instead of SqlString Index: TableGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/TableGenerator.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TableGenerator.cs 25 Jun 2004 20:38:46 -0000 1.8 --- TableGenerator.cs 19 Jul 2004 03:23:13 -0000 1.9 *************** *** 61,69 **** Parameter setParam = new Parameter(); setParam.Name = columnName; ! setParam.DbType = DbType.Int32; Parameter whereParam = new Parameter(); whereParam.Name = columnName; ! whereParam.DbType = DbType.Int32; SqlStringBuilder builder = new SqlStringBuilder(); --- 61,69 ---- Parameter setParam = new Parameter(); setParam.Name = columnName; ! setParam.SqlType = new Int32SqlType(); Parameter whereParam = new Parameter(); whereParam.Name = columnName; ! whereParam.SqlType = new Int32SqlType(); SqlStringBuilder builder = new SqlStringBuilder(); *************** *** 124,129 **** } ! ! IDbCommand ups = updateSql.BuildCommand(session.Factory.ConnectionProvider.Driver); ups.Connection = conn; ups.Transaction = trans; --- 124,128 ---- } ! IDbCommand ups = session.Factory.ConnectionProvider.Driver.GenerateCommand(session.Factory.Dialect, updateSql); ups.Connection = conn; ups.Transaction = trans; *************** *** 161,165 **** { return new string[] { ! "create table " + tableName + " ( " + columnName + " " + dialect.SqlTypeToString(SqlTypeFactory.GetInt32()) + " )", "insert into " + tableName + " values ( 0 )" }; --- 160,164 ---- { return new string[] { ! "create table " + tableName + " ( " + columnName + " " + dialect.GetTypeName( SqlTypeFactory.GetInt32() ) + " )", "insert into " + tableName + " values ( 0 )" }; |
From: Michael D. <mik...@us...> - 2004-07-19 03:21:54
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14833/NHibernate/Impl Modified Files: PreparerImpl.cs Log Message: Preparer is now using the Driver to built the IDbCommand instead of having the SqlString build an IDbCommand. Index: PreparerImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/PreparerImpl.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PreparerImpl.cs 16 Jul 2004 03:57:56 -0000 1.6 --- PreparerImpl.cs 19 Jul 2004 03:21:32 -0000 1.7 *************** *** 7,22 **** using NHibernate.SqlCommand; ! namespace NHibernate.Impl { ! /// <summary> /// The implementing class for the Interface IPreparer. /// </summary> ! internal class PreparerImpl: IPreparer { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(PreparerImpl)); - private ISessionFactoryImplementor factory; - private ISessionImplementor session; - // key = SqlString or a sql string // value = ADO.NET Command --- 7,25 ---- using NHibernate.SqlCommand; ! namespace NHibernate.Impl ! { /// <summary> /// The implementing class for the Interface IPreparer. /// </summary> ! /// <remarks> ! /// This provides a Session level cache of SqlString/string containing sql to an IDbCommand that has been built with ! /// it. ! /// </remarks> ! internal class PreparerImpl: IPreparer ! { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(PreparerImpl)); + private readonly ISessionFactoryImplementor factory; + private readonly ISessionImplementor session; // key = SqlString or a sql string // value = ADO.NET Command *************** *** 31,38 **** private IDbConnection currentConnection; ! public PreparerImpl(ISessionFactoryImplementor factory, ISessionImplementor session){ this.factory = factory; this.session = session; - } --- 34,41 ---- private IDbConnection currentConnection; ! public PreparerImpl(ISessionFactoryImplementor factory, ISessionImplementor session) ! { this.factory = factory; this.session = session; } *************** *** 41,53 **** /// </summary> /// <remarks>If the Connection ever changes then we need to clear out the hashtables.</remarks> ! private IDbConnection DbConnection { ! get { return this.currentConnection; } ! set { ! if(currentConnection!=value) { ! ! if(currentConnection!=null) log.Warn("The current connection was not the same at the Connection from the Session"); // reset the prepared Commands because they are specific to --- 44,61 ---- /// </summary> /// <remarks>If the Connection ever changes then we need to clear out the hashtables.</remarks> ! private IDbConnection DbConnection ! { ! get ! { return this.currentConnection; } ! set ! { ! if(currentConnection!=value) ! { ! if(currentConnection!=null) ! { log.Warn("The current connection was not the same at the Connection from the Session"); + } // reset the prepared Commands because they are specific to *************** *** 58,79 **** currentConnection = value; } ! else { ! log.Info("PrepareImpl is using the same connection as the Session"); } } } ! public IDbCommand BuildCommand(string sql) { ! if(builtCommands.ContainsKey(sql)) { ! return (IDbCommand)builtCommands[sql]; ! } ! else { ! IDbCommand cmd = factory.ConnectionProvider.Driver.CreateCommand(); ! cmd.CommandText = sql; ! ! builtCommands.Add(sql, cmd); ! return cmd; } ! } --- 66,91 ---- currentConnection = value; } ! else ! { ! log.Debug("PrepareImpl is using the same connection as the Session"); } } } ! public IDbCommand BuildCommand(string sql) ! { ! IDbCommand cmd = builtCommands[sql] as IDbCommand; ! if( cmd==null ) ! { ! cmd = factory.ConnectionProvider.Driver.GenerateCommand(factory.Dialect, sql); ! if(log.IsDebugEnabled) ! { ! log.Debug( "Building an IDbCommand object for the sql: " + sql ); ! } } ! ! builtCommands[sql] = cmd; ! return cmd; ! } *************** *** 81,92 **** public IDbCommand BuildCommand(SqlString sqlString) { ! if(builtCommands.ContainsKey(sqlString)) ! return (IDbCommand) builtCommands[sqlString]; ! ! IDbCommand cmd = sqlString.BuildCommand(factory.ConnectionProvider.Driver); ! ! builtCommands.Add(sqlString, cmd); return cmd; --- 93,108 ---- public IDbCommand BuildCommand(SqlString sqlString) { + IDbCommand cmd = builtCommands[sqlString] as IDbCommand; ! if( cmd==null ) ! { ! cmd = factory.ConnectionProvider.Driver.GenerateCommand(factory.Dialect, sqlString); ! if(log.IsDebugEnabled) ! { ! log.Debug( "Building an IDbCommand object for the SqlString: " + sqlString.ToString() ); ! } ! } ! builtCommands[sqlString] = cmd; return cmd; *************** *** 99,104 **** /// <param name="command">The command to setup the Transaction on.</param> /// <returns>A IDbCommand with a valid Transaction property.</returns> ! private IDbCommand JoinTransaction(IDbCommand command) { ! IDbTransaction sessionAdoTrx = null; --- 115,120 ---- /// <param name="command">The command to setup the Transaction on.</param> /// <returns>A IDbCommand with a valid Transaction property.</returns> ! private IDbCommand JoinTransaction(IDbCommand command) ! { IDbTransaction sessionAdoTrx = null; *************** *** 112,120 **** // if the sessionAdoTrx is null then we don't want the command to be a part of // any Transaction - so lets set the command trx to null ! if(sessionAdoTrx==null) { ! ! if(command.Transaction!=null) log.Warn("set a nonnull IDbCommand.Transaction to null because the Session had no Transaction"); command.Transaction = null; - } --- 128,138 ---- // if the sessionAdoTrx is null then we don't want the command to be a part of // any Transaction - so lets set the command trx to null ! if(sessionAdoTrx==null) ! { ! if(command.Transaction!=null) ! { ! log.Warn("set a nonnull IDbCommand.Transaction to null because the Session had no Transaction"); ! } command.Transaction = null; } *************** *** 122,132 **** // in a different Transaction than the Session, but I don't understand all of the code // well enough yet to verify that. ! else if (sessionAdoTrx!=command.Transaction) { // got into here because the command was being initialized and had a null Transaction - probably // don't need to be confused by that - just a normal part of initialization... if(command.Transaction!=null) log.Warn("The IDbCommand had a different Transaction than the Session. This can occur when " + ! "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific."); command.Transaction = sessionAdoTrx; --- 140,153 ---- // in a different Transaction than the Session, but I don't understand all of the code // well enough yet to verify that. ! else if (sessionAdoTrx!=command.Transaction) ! { // got into here because the command was being initialized and had a null Transaction - probably // don't need to be confused by that - just a normal part of initialization... if(command.Transaction!=null) + { log.Warn("The IDbCommand had a different Transaction than the Session. This can occur when " + ! "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific."); ! } command.Transaction = sessionAdoTrx; *************** *** 136,142 **** } ! public IDbCommand PrepareCommand(IDbCommand dbCommand){ - try { dbCommand.Connection = this.DbConnection; dbCommand = JoinTransaction(dbCommand); --- 157,170 ---- } ! public IDbCommand PrepareCommand(IDbCommand dbCommand) ! { ! ! try ! { ! if(log.IsInfoEnabled) ! { ! log.Info(dbCommand.CommandText); ! } dbCommand.Connection = this.DbConnection; dbCommand = JoinTransaction(dbCommand); *************** *** 146,154 **** // one that cannot. // for example - with SqlServer2000 a Command with a binary type ! dbCommand.Prepare(); return dbCommand; } ! catch(Exception e) { throw new ApplicationException( "While preparing " + dbCommand.CommandText + " an error occurred" --- 174,186 ---- // one that cannot. // for example - with SqlServer2000 a Command with a binary type ! if(factory.ConnectionProvider.Driver.SupportsPreparingCommands) ! { ! dbCommand.Prepare(); ! } return dbCommand; } ! catch(Exception e) ! { throw new ApplicationException( "While preparing " + dbCommand.CommandText + " an error occurred" *************** *** 158,193 **** ! public IDbCommand PrepareCommand(string sql) { this.DbConnection = session.Connection; ! IDbCommand cmd = null; ! if(preparedCommands.ContainsKey(sql)) { ! return (IDbCommand)preparedCommands[sql]; } ! ! cmd = this.BuildCommand(sql); cmd = PrepareCommand(cmd); ! preparedCommands.Add(sql, cmd); return cmd; - } ! public IDbCommand PrepareCommand(SqlString sqlString) { this.DbConnection = session.Connection; ! IDbCommand cmd = null; ! if(preparedCommands.ContainsKey(sqlString)) { ! cmd = (IDbCommand)preparedCommands[sqlString]; ! cmd = JoinTransaction(cmd); ! return cmd; } - cmd = this.BuildCommand(sqlString); cmd = PrepareCommand(cmd); ! preparedCommands.Add(sqlString, cmd); ! return cmd; --- 190,221 ---- ! public IDbCommand PrepareCommand(string sql) ! { this.DbConnection = session.Connection; ! IDbCommand cmd = preparedCommands[sql] as IDbCommand; ! if( cmd==null ) { ! cmd = this.BuildCommand(sql); } ! cmd = PrepareCommand(cmd); ! preparedCommands[sql] = cmd; return cmd; } ! public IDbCommand PrepareCommand(SqlString sqlString) ! { this.DbConnection = session.Connection; ! IDbCommand cmd = preparedCommands[sqlString] as IDbCommand; ! if( cmd==null ) { ! cmd = this.BuildCommand(sqlString); } cmd = PrepareCommand(cmd); ! preparedCommands[sqlString] = cmd; return cmd; |
From: Michael D. <mik...@us...> - 2004-07-19 03:21:54
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14833/NHibernate/SqlCommand Modified Files: Parameter.cs ParameterLength.cs ParameterPrecisionScale.cs SqlString.cs Log Message: Preparer is now using the Driver to built the IDbCommand instead of having the SqlString build an IDbCommand. Index: Parameter.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/Parameter.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Parameter.cs 25 Jun 2004 20:31:32 -0000 1.7 --- Parameter.cs 19 Jul 2004 03:21:33 -0000 1.8 *************** *** 1,6 **** using System; ! using System.Data; ! using NHibernate.Driver; using NHibernate.Engine; using NHibernate.SqlTypes; --- 1,6 ---- using System; ! //using System.Data; ! //using NHibernate.Driver; using NHibernate.Engine; using NHibernate.SqlTypes; *************** *** 16,30 **** public class Parameter: ICloneable { - private DbType dbType; - private string tableAlias; private string name; ! ! public System.Data.DbType DbType { ! get {return dbType;} ! set {this.dbType = value;} ! } ! ! public string Name { get{ return name;} set{ this.name = value;} --- 16,25 ---- public class Parameter: ICloneable { private string tableAlias; private string name; ! private SqlType _sqlType; ! ! public string Name ! { get{ return name;} set{ this.name = value;} *************** *** 32,72 **** ! public string TableAlias { get {return tableAlias;} set {this.tableAlias = value;} } ! /// <summary> ! /// Returns a string version of the Parameter that is in the correct ! /// format for the SQL in the CommandText. ! /// </summary> ! /// <param name="driver">The Driver that knows how to format the name.</param> ! /// <param name="name">The name to format for SQL.</param> ! /// <returns>A valid SQL string for this Parameter.</returns> ! public string GetSqlName(IDriver driver, string name) ! { ! return driver.FormatNameForSql(name); ! } ! ! /// <summary> ! /// Returns a string version of the Parameter that is in the correct ! /// format for the IDbDataParameter.Name ! /// </summary> ! /// <param name="driver">The Driver that knows how to format the name.</param> ! /// <param name="name">The name to format for the IDbDataParameter.</param> ! /// <returns>A valid IDbDataParameter Name for this Parameter.</returns> ! public string GetParameterName(IDriver driver, string name) { ! return driver.FormatNameForParameter(name); } - public virtual IDbDataParameter GetIDbDataParameter(IDbCommand command, IDriver driver, string name) - { - IDbDataParameter param = command.CreateParameter(); - param.DbType = dbType; - param.ParameterName = GetParameterName(driver, name); - - return param; - } /// <summary> --- 27,43 ---- ! public string TableAlias ! { get {return tableAlias;} set {this.tableAlias = value;} } ! ! public SqlType SqlType { ! get { return _sqlType; } ! set { _sqlType = value; } } /// <summary> *************** *** 76,80 **** /// <param name="type">The IType to turn into Parameters</param> /// <returns>An Array of IParameter objects</returns> ! public static Parameter[] GenerateParameters(ISessionFactoryImplementor factory, string[] columnNames, IType type) { return Parameter.GenerateParameters(factory, null, columnNames, type); } --- 47,52 ---- /// <param name="type">The IType to turn into Parameters</param> /// <returns>An Array of IParameter objects</returns> ! public static Parameter[] GenerateParameters(ISessionFactoryImplementor factory, string[] columnNames, IType type) ! { return Parameter.GenerateParameters(factory, null, columnNames, type); } *************** *** 89,93 **** /// <param name="type">The IType to turn into Parameters</param> /// <returns>An Array of IParameter objects</returns> ! public static Parameter[] GenerateParameters(ISessionFactoryImplementor factory, string tableAlias, string[] columnNames, IType type) { SqlType[] sqlTypes = type.SqlTypes(factory); --- 61,66 ---- /// <param name="type">The IType to turn into Parameters</param> /// <returns>An Array of IParameter objects</returns> ! public static Parameter[] GenerateParameters(ISessionFactoryImplementor factory, string tableAlias, string[] columnNames, IType type) ! { SqlType[] sqlTypes = type.SqlTypes(factory); *************** *** 111,116 **** parameters[i].Name = columnNames[i]; - parameters[i].DbType = sqlTypes[i].DbType; parameters[i].TableAlias = tableAlias; } --- 84,90 ---- parameters[i].Name = columnNames[i]; parameters[i].TableAlias = tableAlias; + parameters[i].SqlType = sqlTypes[i]; + } *************** *** 135,139 **** // these 2 fields will not be null so compare them... ! if(this.DbType.Equals(rhs.DbType)==false || this.Name.Equals(rhs.Name)==false) return false; // becareful with TableAlias being null --- 109,117 ---- // these 2 fields will not be null so compare them... ! if( this.SqlType.Equals(rhs.SqlType)==false ! || this.Name.Equals(rhs.Name)==false) ! { ! return false; ! } // becareful with TableAlias being null *************** *** 158,162 **** unchecked { ! hashCode = dbType.GetHashCode() + name.GetHashCode(); if(tableAlias!=null) { --- 136,140 ---- unchecked { ! hashCode = _sqlType.GetHashCode() + name.GetHashCode(); if(tableAlias!=null) { *************** *** 187,195 **** } ! object ICloneable.Clone() { return Clone(); } #endregion } --- 165,176 ---- } ! object ICloneable.Clone() ! { return Clone(); } #endregion + + } Index: SqlString.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlString.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SqlString.cs 25 Jun 2004 20:31:32 -0000 1.7 --- SqlString.cs 19 Jul 2004 03:21:33 -0000 1.8 *************** *** 1,8 **** using System; - using System.Data; using System.Text; - using NHibernate.Driver; - namespace NHibernate.SqlCommand { --- 1,5 ---- *************** *** 52,92 **** } - /// <summary> - /// Builds an IDbCommand using the Driver to help format the Sql and Parameters - /// </summary> - /// <param name="driver">The Driver to use to create the Sql and Parameters.</param> - /// <returns>An IDbCommand with its CommandText and ParametersCollection populated.</returns> - public IDbCommand BuildCommand(IDriver driver) - { - int paramIndex = 0; - IDbCommand cmd = driver.CreateCommand(); - - StringBuilder builder = new StringBuilder(sqlParts.Length * 15); - for(int i = 0; i < sqlParts.Length; i++) - { - object part = sqlParts[i]; - Parameter parameter = part as Parameter; - - if(parameter!=null) - { - string paramName = "p" + paramIndex; - builder.Append( parameter.GetSqlName(driver, paramName) ); - IDbDataParameter dbParam = parameter.GetIDbDataParameter(cmd, driver, paramName); - cmd.Parameters.Add(dbParam); - - paramIndex++; - } - else - { - builder.Append((string)part); - } - } - - cmd.CommandText = builder.ToString(); - - return cmd; - } - - #region System.Object Members --- 49,52 ---- Index: ParameterLength.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/ParameterLength.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ParameterLength.cs 25 Jun 2004 20:31:32 -0000 1.5 --- ParameterLength.cs 19 Jul 2004 03:21:33 -0000 1.6 *************** *** 1,8 **** using System; - using System.Data; - - using NHibernate.Driver; - using NHibernate.Engine; - using NHibernate.Type; namespace NHibernate.SqlCommand --- 1,3 ---- *************** *** 10,15 **** /// <summary> /// Extension to the Parameter class that supports Parameters with ! /// a Length /// </summary> public class ParameterLength : Parameter { --- 5,15 ---- /// <summary> /// Extension to the Parameter class that supports Parameters with ! /// a Length. /// </summary> + /// <remarks> + /// This should only be used when the property needs to be mapped with + /// a <c>type="String(200)"</c> because for some reason the default parameter + /// generation of <c>nvarchar(4000)</c> (MsSql specific) is not good enough. + /// </remarks> public class ParameterLength : Parameter { *************** *** 22,32 **** } - public override IDbDataParameter GetIDbDataParameter(IDbCommand command, IDriver driver, string name) - { - IDbDataParameter param = base.GetIDbDataParameter (command, driver, name); - param.Size = length; - - return param; - } #region System.Object Members --- 22,25 ---- Index: ParameterPrecisionScale.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/ParameterPrecisionScale.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ParameterPrecisionScale.cs 25 Jun 2004 20:31:32 -0000 1.5 --- ParameterPrecisionScale.cs 19 Jul 2004 03:21:33 -0000 1.6 *************** *** 1,8 **** using System; - using System.Data; - - using NHibernate.Driver; - using NHibernate.Engine; - using NHibernate.Type; namespace NHibernate.SqlCommand --- 1,3 ---- *************** *** 12,15 **** --- 7,15 ---- /// a Precision and a Scale /// </summary> + /// <remarks> + /// This should only be used when the property needs to be mapped with + /// a <c>type="Decimal(20,4)"</c> because for some reason the default parameter + /// generation of <c>decimal(19,5)</c> (MsSql specific) is not good enough. + /// </remarks> public class ParameterPrecisionScale : Parameter { *************** *** 29,40 **** } - public override IDbDataParameter GetIDbDataParameter(IDbCommand command, IDriver driver, string name) - { - IDbDataParameter param = base.GetIDbDataParameter (command, driver, name); - param.Precision = precision; - param.Scale = scale; - - return param; - } #region System.Object Members --- 29,32 ---- |
From: Michael D. <mik...@us...> - 2004-07-19 03:20:44
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Driver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14722/NHibernate/Driver Modified Files: DriverBase.cs IDriver.cs SqlClientDriver.cs Log Message: Add methods for the Driver to be in control of generating the IDbCommand from the SqlString or string. Index: DriverBase.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Driver/DriverBase.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DriverBase.cs 18 Jul 2004 03:05:08 -0000 1.5 --- DriverBase.cs 19 Jul 2004 03:20:25 -0000 1.6 *************** *** 86,89 **** --- 86,154 ---- } + public virtual IDbCommand GenerateCommand(Dialect.Dialect dialect, SqlCommand.SqlString sqlString) + { + int paramIndex = 0; + IDbCommand cmd = this.CreateCommand(); + + System.Text.StringBuilder builder = new System.Text.StringBuilder(sqlString.SqlParts.Length * 15); + for(int i = 0; i < sqlString.SqlParts.Length; i++) + { + object part = sqlString.SqlParts[i]; + SqlCommand.Parameter parameter = part as SqlCommand.Parameter; + + if(parameter!=null) + { + string paramName = "p" + paramIndex; + builder.Append ( this.FormatNameForSql(paramName) ); + + IDbDataParameter dbParam = GenerateParameter(cmd, paramName, parameter, dialect); + + cmd.Parameters.Add(dbParam); + + paramIndex++; + } + else + { + builder.Append((string)part); + } + } + + cmd.CommandText = builder.ToString(); + + return cmd; + } + + public virtual IDbCommand GenerateCommand(Dialect.Dialect dialect, string sqlString) + { + IDbCommand cmd = this.CreateCommand(); + cmd.CommandText = sqlString; + + return cmd; + } + + /// <summary> + /// Generates an IDbDataParameter for the IDbCommand. It does not add the IDbDataParameter to the IDbCommand's + /// Parameter collection. + /// </summary> + /// <param name="command">The IDbCommand to use to create the IDbDataParameter.</param> + /// <param name="name">The name to set for IDbDataParameter.Name</param> + /// <param name="parameter">The Parameter to convert to an IDbDataParameter.</param> + /// <param name="dialect">The Dialect to use for Default lengths if needed.</param> + /// <returns>An IDbDataParameter ready to be added to an IDbCommand.</returns> + /// <remarks> + /// Drivers that require Size or Precision/Scale to be set before the IDbCommand is prepared should + /// override this method and use the info contained in the Parameter to set those value. By default + /// those values are not set, only the DbType and ParameterName are set. + /// </remarks> + protected virtual IDbDataParameter GenerateParameter(IDbCommand command, string name, SqlCommand.Parameter parameter, Dialect.Dialect dialect) + { + IDbDataParameter dbParam = command.CreateParameter(); + dbParam.DbType = parameter.SqlType.DbType; + + dbParam.ParameterName = this.FormatNameForParameter(name); + + return dbParam; + } + #endregion } Index: SqlClientDriver.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Driver/SqlClientDriver.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SqlClientDriver.cs 18 May 2004 05:02:27 -0000 1.3 --- SqlClientDriver.cs 19 Jul 2004 03:20:25 -0000 1.4 *************** *** 64,67 **** --- 64,133 ---- + /// <summary> + /// Generates an IDbDataParameter that has values for the Size or Precision/Scale Properties set. + /// </summary> + /// <param name="command">The IDbCommand to use to create the IDbDataParameter.</param> + /// <param name="name">The name to set for IDbDataParameter.Name</param> + /// <param name="parameter">The Parameter to convert to an IDbDataParameter.</param> + /// <param name="dialect">The Dialect to use for Default lengths if needed.</param> + /// <returns>An IDbDataParameter ready to be added to an IDbCommand.</returns> + /// <remarks> + /// In order to prepare an IDbCommand against an MsSql database all variable length values need + /// to be set. + /// </remarks> + protected override IDbDataParameter GenerateParameter(IDbCommand command, string name, SqlCommand.Parameter parameter, Dialect.Dialect dialect) + { + IDbDataParameter dbParam = base.GenerateParameter(command, name, parameter, dialect); + + // take a look at the SqlType and determine if this is one that MsSql needs to set Size or + // Precision/Scale for + + // if this parameter needs to have a value set for the Size or Precision/Scale besides the default + // value of the Dialect then one of these will not be null + SqlCommand.ParameterLength pl = null; + SqlCommand.ParameterPrecisionScale pps = null; + + switch( parameter.SqlType.DbType ) + { + case DbType.AnsiString: + case DbType.AnsiStringFixedLength: + pl = parameter as SqlCommand.ParameterLength; + dbParam.Size = dialect.MaxAnsiStringSize; + break; + + case DbType.Binary: + pl = parameter as SqlCommand.ParameterLength; + dbParam.Size = dialect.MaxBinarySize; + break; + + case DbType.String: + case DbType.StringFixedLength: + pl = parameter as SqlCommand.ParameterLength; + dbParam.Size = dialect.MaxStringSize; + break; + case DbType.Decimal: + pps = parameter as SqlCommand.ParameterPrecisionScale; + //TODO: remove this hardcoding... + dbParam.Precision = 19; + dbParam.Scale = 5; + break; + } + + // if one of these is not null then override the default values + // set in the earlier switch statement. + if( pl!=null ) + { + dbParam.Size = pl.Length; + } + else if( pps!=null ) + { + dbParam.Precision = pps.Precision; + dbParam.Scale = pps.Scale; + } + + return dbParam; + + } + } Index: IDriver.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Driver/IDriver.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IDriver.cs 18 Jul 2004 03:05:08 -0000 1.4 --- IDriver.cs 19 Jul 2004 03:20:25 -0000 1.5 *************** *** 172,175 **** --- 172,196 ---- + /// <summary> + /// Generates an IDbCommand from the SqlString according to the requirements of the DataProvider. + /// </summary> + /// <param name="dialect">The Dialect to help build the IDbCommand</param> + /// <param name="sqlString">The SqlString that contains the sql and parameters.</param> + /// <returns>An IDbCommand with the CommandText and Parameters fully set.</returns> + IDbCommand GenerateCommand(Dialect.Dialect dialect, SqlCommand.SqlString sqlString); + + /// <summary> + /// Generates an IDbCommand from the string containing sql according to the requirements + /// of the DataProvider. + /// </summary> + /// <param name="dialect">The Dialect to help build the IDbCommand</param> + /// <param name="sqlString">The string that contains the sql that has NO parameters.</param> + /// <returns>An IDbCommand with the CommandText fully set.</returns> + /// <remarks>This can not be used to build an IDbCommand that needs to contain Parameters.</remarks> + IDbCommand GenerateCommand(Dialect.Dialect dialect, string sqlString); + + + + } } |
From: Michael D. <mik...@us...> - 2004-07-19 03:19:13
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NHSpecific In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14496/NHibernate.DomainModel/NHSpecific Modified Files: BasicClass.hbm.xml Child.hbm.xml ClassWithCompositeId.hbm.xml Node.hbm.xml Log Message: Minor hbm changes so schema export generates tables correctly. Index: BasicClass.hbm.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NHSpecific/BasicClass.hbm.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BasicClass.hbm.xml 29 Jun 2004 04:28:08 -0000 1.2 --- BasicClass.hbm.xml 19 Jul 2004 03:19:00 -0000 1.3 *************** *** 13,17 **** <property name="BooleanProperty" type="Boolean" column="bool_p"/> <property name="ByteProperty" type="Byte" column="byte_p"/> ! <property name="CharacterProperty" type="Char" column="char_p"/> <property name="ClassProperty" type="Type" column="class_p"/> <property name="CultureInfoProperty" type="CultureInfo" column="cinfo_p"/> --- 13,17 ---- <property name="BooleanProperty" type="Boolean" column="bool_p"/> <property name="ByteProperty" type="Byte" column="byte_p"/> ! <property name="CharacterProperty" type="Char" column="char_p" length="1"/> <property name="ClassProperty" type="Type" column="class_p"/> <property name="CultureInfoProperty" type="CultureInfo" column="cinfo_p"/> *************** *** 26,36 **** <property name="StringProperty" type="String" column="str_p"/> <property name="TicksProperty" type="Ticks" column="ticks_p"/> ! <property name="TrueFalseProperty" type="TrueFalse" column="tf_p"/> ! <property name="YesNoProperty" type="YesNo" column="yn_p"/> <array name="StringArray" table="bc_starr" > <key column="bc_id" /> <index column="sa_idx" /> ! <element column="str_val" type="String(100)" /> </array> --- 26,36 ---- <property name="StringProperty" type="String" column="str_p"/> <property name="TicksProperty" type="Ticks" column="ticks_p"/> ! <property name="TrueFalseProperty" type="TrueFalse" column="tf_p" length="1"/> ! <property name="YesNoProperty" type="YesNo" column="yn_p" length="1"/> <array name="StringArray" table="bc_starr" > <key column="bc_id" /> <index column="sa_idx" /> ! <element column="str_val" type="String(100)" length="100"/> </array> *************** *** 43,47 **** <bag name="StringBag" table="bc_stbag"> <key column="bc_id" /> ! <element column="str_value" type="String(25)" /> </bag> --- 43,47 ---- <bag name="StringBag" table="bc_stbag"> <key column="bc_id" /> ! <element column="str_value" type="String(25)" length="25"/> </bag> *************** *** 49,64 **** <key column="bc_id" /> <index column="lst_idx" /> ! <element column="str_val" type="String(300)" /> </list> <map name="StringMap" table="bc_stmap" > <key column="bc_id"/> ! <index column="strm_idx" type="String(10)" /> ! <element column="str_val" type="String(50)" /> </map> <set name="StringSet" table="bc_stset"> <key column="bc_id" /> ! <element column="str_val" type="String(25)"/> </set> --- 49,64 ---- <key column="bc_id" /> <index column="lst_idx" /> ! <element column="str_val" type="String(300)" length="300" /> </list> <map name="StringMap" table="bc_stmap" > <key column="bc_id"/> ! <index column="strm_idx" type="String(10)" length="10" /> ! <element column="str_val" type="String(50)" length="50"/> </map> <set name="StringSet" table="bc_stset"> <key column="bc_id" /> ! <element column="str_val" type="String(25)" length="25"/> </set> Index: Node.hbm.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NHSpecific/Node.hbm.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Node.hbm.xml 9 Jun 2004 01:04:35 -0000 1.1 --- Node.hbm.xml 19 Jul 2004 03:19:01 -0000 1.2 *************** *** 3,7 **** <class name="NHibernate.DomainModel.NHSpecific.Node, NHibernate.DomainModel"> ! <id name="Id" column="id" type="String(10)"> <generator class="assigned" /> </id> --- 3,7 ---- <class name="NHibernate.DomainModel.NHSpecific.Node, NHibernate.DomainModel"> ! <id name="Id" column="id" type="String(10)" length="10"> <generator class="assigned" /> </id> Index: ClassWithCompositeId.hbm.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NHSpecific/ClassWithCompositeId.hbm.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ClassWithCompositeId.hbm.xml 9 Jun 2004 01:04:35 -0000 1.1 --- ClassWithCompositeId.hbm.xml 19 Jul 2004 03:19:01 -0000 1.2 *************** *** 8,12 **** > <composite-id name="Id" class="NHibernate.DomainModel.NHSpecific.CompositeId, NHibernate.DomainModel"> ! <key-property name="KeyString" column="string_" type="String(20)" /> <key-property name="KeyShort" column="short_"/> <key-property name="KeyDateTime" column="date_" type="DateTime"/> --- 8,12 ---- > <composite-id name="Id" class="NHibernate.DomainModel.NHSpecific.CompositeId, NHibernate.DomainModel"> ! <key-property name="KeyString" column="string_" type="String(20)" length="20"/> <key-property name="KeyShort" column="short_"/> <key-property name="KeyDateTime" column="date_" type="DateTime"/> Index: Child.hbm.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NHSpecific/Child.hbm.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Child.hbm.xml 9 Jun 2004 01:04:35 -0000 1.1 --- Child.hbm.xml 19 Jul 2004 03:19:00 -0000 1.2 *************** *** 10,14 **** </id> ! <property name="FullName" type="String(45)" column="full_name" /> <property name="FavoriteDate" type="DateTime" column="favorite_date" /> --- 10,14 ---- </id> ! <property name="FullName" type="String(45)" column="full_name" length="45"/> <property name="FavoriteDate" type="DateTime" column="favorite_date" /> |
From: Michael D. <mik...@us...> - 2004-07-19 03:09:41
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13125/NHibernate/Type Modified Files: TypeFactory.cs Log Message: Minor mods to TypeFactory that are part of a large batch of changes to schema-export and how IDbCommands are built. Index: TypeFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TypeFactory.cs,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** TypeFactory.cs 3 May 2004 04:56:44 -0000 1.31 --- TypeFactory.cs 19 Jul 2004 03:09:32 -0000 1.32 *************** *** 111,117 **** getTypeDelegatesWithLength.Add(TypeFactory.GetAnsiStringType().Name, new GetNullableTypeWithLength(GetAnsiStringType)); getTypeDelegatesWithLength.Add(TypeFactory.GetBinaryType().Name, new GetNullableTypeWithLength(GetBinaryType)); - getTypeDelegatesWithLength.Add(TypeFactory.GetDoubleType().Name, new GetNullableTypeWithLength(GetDoubleType)); getTypeDelegatesWithLength.Add(TypeFactory.GetSerializableType().Name, new GetNullableTypeWithLength(GetSerializableType)); - getTypeDelegatesWithLength.Add(TypeFactory.GetSingleType().Name, new GetNullableTypeWithLength(GetSingleType)); getTypeDelegatesWithLength.Add(TypeFactory.GetStringType().Name, new GetNullableTypeWithLength(GetStringType)); getTypeDelegatesWithLength.Add(TypeFactory.GetTypeType().Name, new GetNullableTypeWithLength(GetTypeType)); --- 111,115 ---- *************** *** 389,393 **** if(returnType==null) { ! returnType = GetAnsiStringType(255); AddToTypeOfName(key, returnType); } --- 387,391 ---- if(returnType==null) { ! returnType = new AnsiStringType( new AnsiStringSqlType() ); AddToTypeOfName(key, returnType); } *************** *** 403,407 **** if(returnType==null) { ! returnType = new AnsiStringType(SqlTypeFactory.GetAnsiString(length)); AddToTypeOfNameWithLength(key, returnType); } --- 401,405 ---- if(returnType==null) { ! returnType = new AnsiStringType( SqlTypeFactory.GetAnsiString(length) ); AddToTypeOfNameWithLength(key, returnType); } *************** *** 431,436 **** if(returnType==null) { ! returnType = GetBinaryType(255); ! AddToTypeOfName(key, returnType); } --- 429,434 ---- if(returnType==null) { ! returnType = new BinaryType(new BinarySqlType()); ! AddToTypeOfName(key, returnType); } *************** *** 473,477 **** if(returnType==null) { ! returnType = new BooleanType(SqlTypeFactory.GetBoolean()); AddToTypeOfName(key, returnType); } --- 471,475 ---- if(returnType==null) { ! returnType = new BooleanType( SqlTypeFactory.GetBoolean() ); AddToTypeOfName(key, returnType); } *************** *** 491,495 **** if(returnType==null) { ! returnType = new ByteType(SqlTypeFactory.GetByte()); AddToTypeOfName(key, returnType); } --- 489,493 ---- if(returnType==null) { ! returnType = new ByteType( SqlTypeFactory.GetByte() ); AddToTypeOfName(key, returnType); } *************** *** 509,513 **** if(returnType==null) { ! returnType = new CharType(SqlTypeFactory.GetStringFixedLength(1)); AddToTypeOfName(key, returnType); } --- 507,511 ---- if(returnType==null) { ! returnType = new CharType( SqlTypeFactory.GetStringFixedLength(1) ); AddToTypeOfName(key, returnType); } *************** *** 526,532 **** if(returnType==null) { ! //TODO: I believe 10 is still set way to high. If I read the doco correctly ! // then at most it should be 5... ! returnType = new CultureInfoType(SqlTypeFactory.GetString(10)); AddToTypeOfName(key, returnType); } --- 524,528 ---- if(returnType==null) { ! returnType = new CultureInfoType( SqlTypeFactory.GetString(10) ); AddToTypeOfName(key, returnType); } *************** *** 563,567 **** if(returnType==null) { ! returnType = new DateType(SqlTypeFactory.GetDate()); AddToTypeOfName(key, returnType); } --- 559,563 ---- if(returnType==null) { ! returnType = new DateType( SqlTypeFactory.GetDate() ); AddToTypeOfName(key, returnType); } *************** *** 581,585 **** if(returnType==null) { ! returnType = GetDecimalType(19,0); AddToTypeOfName(key, returnType); } --- 577,581 ---- if(returnType==null) { ! returnType = new DecimalType(new DecimalSqlType()); AddToTypeOfName(key, returnType); } *************** *** 601,605 **** if(returnType==null) { ! returnType = new DecimalType(SqlTypeFactory.GetDecimal(precision, scale)); AddToTypeOfNameWithPrecision(key, returnType); } --- 597,601 ---- if(returnType==null) { ! returnType = new DecimalType( SqlTypeFactory.GetDecimal(precision, scale) ); AddToTypeOfNameWithPrecision(key, returnType); } *************** *** 619,623 **** if(returnType==null) { ! returnType = GetDoubleType(53); AddToTypeOfName(key, returnType); } --- 615,619 ---- if(returnType==null) { ! returnType = new DoubleType( SqlTypeFactory.GetDouble() ); AddToTypeOfName(key, returnType); } *************** *** 631,653 **** /// /// </summary> - /// <param name="length"></param> - /// <returns></returns> - public static NullableType GetDoubleType(int length) - { - string key = GetKeyForLengthBased(typeof(DoubleType).FullName, length); - NullableType returnType = (NullableType)typeByTypeOfName[key]; - if(returnType==null) - { - returnType = new DoubleType(SqlTypeFactory.GetDouble(length)); - AddToTypeOfNameWithLength(key, returnType); - } - - return returnType; - - } - - /// <summary> - /// - /// </summary> /// <returns></returns> public static NullableType GetGuidType() --- 627,630 ---- *************** *** 658,662 **** if(returnType==null) { ! returnType = new GuidType(SqlTypeFactory.GetGuid()); AddToTypeOfName(key, returnType); } --- 635,639 ---- if(returnType==null) { ! returnType = new GuidType( SqlTypeFactory.GetGuid() ); AddToTypeOfName(key, returnType); } *************** *** 676,680 **** if(returnType==null) { ! returnType = new Int16Type(SqlTypeFactory.GetInt16()); AddToTypeOfName(key, returnType); } --- 653,657 ---- if(returnType==null) { ! returnType = new Int16Type( SqlTypeFactory.GetInt16() ); AddToTypeOfName(key, returnType); } *************** *** 695,699 **** if(returnType==null) { ! returnType = new Int32Type(SqlTypeFactory.GetInt32()); AddToTypeOfName(key, returnType); } --- 672,676 ---- if(returnType==null) { ! returnType = new Int32Type( SqlTypeFactory.GetInt32() ); AddToTypeOfName(key, returnType); } *************** *** 713,717 **** NullableType returnType = (NullableType)typeByTypeOfName[key]; if(returnType==null) { ! returnType = new Int64Type(SqlTypeFactory.GetInt64()); AddToTypeOfName(key, returnType); } --- 690,694 ---- NullableType returnType = (NullableType)typeByTypeOfName[key]; if(returnType==null) { ! returnType = new Int64Type( SqlTypeFactory.GetInt64() ); AddToTypeOfName(key, returnType); } *************** *** 730,734 **** if(returnType==null) { ! returnType = GetSingleType(24); AddToTypeOfName(key, returnType); } --- 707,711 ---- if(returnType==null) { ! returnType = new SingleType( SqlTypeFactory.GetSingle() ); AddToTypeOfName(key, returnType); } *************** *** 741,764 **** /// /// </summary> - /// <param name="length"></param> - /// <returns></returns> - public static NullableType GetSingleType(int length) - { - string key = GetKeyForLengthBased(typeof(SingleType).FullName, length); - - NullableType returnType = (NullableType)typeByTypeOfName[key]; - if(returnType==null) - { - returnType = new SingleType(SqlTypeFactory.GetSingle(length)); - AddToTypeOfNameWithLength(key, returnType); - } - - return returnType; - - } - - /// <summary> - /// - /// </summary> /// <returns></returns> public static NullableType GetSerializableType() --- 718,721 ---- *************** *** 862,866 **** if(returnType==null) { ! returnType = GetStringType(255); AddToTypeOfName(key, returnType); } --- 819,823 ---- if(returnType==null) { ! returnType = new StringType( new StringSqlType() ); AddToTypeOfName(key, returnType); } *************** *** 881,885 **** if(returnType==null) { ! returnType = new StringType(SqlTypeFactory.GetString(length)); AddToTypeOfNameWithLength(key, returnType); } --- 838,842 ---- if(returnType==null) { ! returnType = new StringType( SqlTypeFactory.GetString(length) ); AddToTypeOfNameWithLength(key, returnType); } *************** *** 901,905 **** if(returnType==null) { ! returnType = new TicksType(SqlTypeFactory.GetInt64()); AddToTypeOfName(key, returnType); } --- 858,862 ---- if(returnType==null) { ! returnType = new TicksType( SqlTypeFactory.GetInt64() ); AddToTypeOfName(key, returnType); } *************** *** 921,925 **** if(returnType==null) { ! returnType = new TimeSpanType(SqlTypeFactory.GetInt64()); AddToTypeOfName(key, returnType); } --- 878,882 ---- if(returnType==null) { ! returnType = new TimeSpanType( SqlTypeFactory.GetInt64() ); AddToTypeOfName(key, returnType); } *************** *** 940,944 **** if(returnType==null) { ! returnType = new TimestampType(SqlTypeFactory.GetDateTime()); AddToTypeOfName(key, returnType); } --- 897,901 ---- if(returnType==null) { ! returnType = new TimestampType( SqlTypeFactory.GetDateTime() ); AddToTypeOfName(key, returnType); } *************** *** 959,963 **** if(returnType==null) { ! returnType = new TimeType(SqlTypeFactory.GetTime()); AddToTypeOfName(key, returnType); } --- 916,920 ---- if(returnType==null) { ! returnType = new TimeType( SqlTypeFactory.GetTime() ); AddToTypeOfName(key, returnType); } *************** *** 978,982 **** if(returnType==null) { ! returnType = new TrueFalseType(SqlTypeFactory.GetAnsiStringFixedLength(1)); AddToTypeOfName(key, returnType); } --- 935,939 ---- if(returnType==null) { ! returnType = new TrueFalseType( SqlTypeFactory.GetAnsiStringFixedLength(1) ); AddToTypeOfName(key, returnType); } *************** *** 999,1003 **** if(returnType==null) { ! returnType = GetTypeType(255); AddToTypeOfName(key, returnType); } --- 956,960 ---- if(returnType==null) { ! returnType = new TypeType( new StringSqlType() ); AddToTypeOfName(key, returnType); } *************** *** 1019,1023 **** if(returnType==null) { ! returnType = new TypeType(SqlTypeFactory.GetString(length)); AddToTypeOfNameWithLength(key, returnType); } --- 976,980 ---- if(returnType==null) { ! returnType = new TypeType( SqlTypeFactory.GetString(length) ); AddToTypeOfNameWithLength(key, returnType); } *************** *** 1038,1042 **** if(returnType==null) { ! returnType = new YesNoType(SqlTypeFactory.GetAnsiStringFixedLength(1)); AddToTypeOfName(key, returnType); } --- 995,999 ---- if(returnType==null) { ! returnType = new YesNoType( SqlTypeFactory.GetAnsiStringFixedLength(1) ); AddToTypeOfName(key, returnType); } |
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)); } |
From: Michael D. <mik...@us...> - 2004-07-19 03:02:43
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12146/NHibernate.DomainModel Modified Files: Baz.hbm.xml FooBar.hbm.xml Simple.hbm.xml Log Message: Minor hbm changes so schema export generates tables correctly. Index: Simple.hbm.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Simple.hbm.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Simple.hbm.xml 9 Jul 2004 19:22:11 -0000 1.5 --- Simple.hbm.xml 19 Jul 2004 03:02:33 -0000 1.6 *************** *** 7,11 **** </id> <property name="Name"/> ! <property name="Address" type="String(200)" column="address" /> <property name="Count" column="count_" not-null="true" unique="true"/> <property name="Date" column="date_"/> --- 7,11 ---- </id> <property name="Name"/> ! <property name="Address" type="String" length="200" column="address" /> <property name="Count" column="count_" not-null="true" unique="true"/> <property name="Date" column="date_"/> Index: FooBar.hbm.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/FooBar.hbm.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FooBar.hbm.xml 13 Jul 2004 06:46:57 -0000 1.10 --- FooBar.hbm.xml 19 Jul 2004 03:02:33 -0000 1.11 *************** *** 25,29 **** </generator> </id> ! <discriminator column="`$foo_subclass^`" type="Char"/> <version name="Version"/> <!--<version name="versionCalendar" type="calendar"/>--> --- 25,33 ---- </generator> </id> ! <discriminator column="`$foo_subclass^`" type="Char" length="1"/> ! <!-- ! added length for NH because a Char does not have a direct DbType.Char but instead ! uses DbType.String so it defaults to 255 if 1 is not found. ! --> <version name="Version"/> <!--<version name="versionCalendar" type="calendar"/>--> Index: Baz.hbm.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Baz.hbm.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Baz.hbm.xml 15 Jul 2004 19:16:39 -0000 1.14 --- Baz.hbm.xml 19 Jul 2004 03:02:33 -0000 1.15 *************** *** 282,286 **** <map name="TopGlarchez"> <key column="idtopglarch" /> ! <index column="mapkey" type="Char"/> <one-to-many class = "NHibernate.DomainModel.Glarch, NHibernate.DomainModel"/> </map> --- 282,290 ---- <map name="TopGlarchez"> <key column="idtopglarch" /> ! <index column="mapkey" type="Char" length="1"/> ! <!-- ! added length for NH because a Char does not have a direct DbType.Char but instead ! uses DbType.String so it defaults to 255 if 1 is not found. ! --> <one-to-many class = "NHibernate.DomainModel.Glarch, NHibernate.DomainModel"/> </map> |
From: Michael D. <mik...@us...> - 2004-07-18 03:06:21
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10103/Type Modified Files: TrueFalseType.cs YesNoType.cs Log Message: Added comments about needing to set sql-type or length in the hbm.xml for the correct column type to be generated by schema export. Index: YesNoType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/YesNoType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** YesNoType.cs 10 Feb 2004 18:41:42 -0000 1.3 --- YesNoType.cs 18 Jul 2004 03:06:13 -0000 1.4 *************** *** 9,26 **** /// "Y"/"N" to indicate true/false. /// </summary> ! public class YesNoType : CharBooleanType { ! internal YesNoType(AnsiStringFixedLengthSqlType sqlType) : base(sqlType) { } ! protected override sealed string TrueString { get { return "Y"; } } ! protected override sealed string FalseString { get { return "N"; } } ! public override string Name { get { return "YesNo"; } } --- 9,39 ---- /// "Y"/"N" to indicate true/false. /// </summary> ! /// <remarks> ! /// If you are using schema-export to generate your tables then you need ! /// to set the column attributes: <c>length=1</c> or <c>sql-type="char(1)"</c>. ! /// ! /// This needs to be done because in Java's JDBC there is a type for CHAR and ! /// in ADO.NET there is not one specifically for char, so you need to tell schema ! /// export to create a char(1) column. ! /// </remarks> ! public class YesNoType : CharBooleanType ! { ! internal YesNoType(AnsiStringFixedLengthSqlType sqlType) : base(sqlType) ! { } ! protected override sealed string TrueString ! { get { return "Y"; } } ! protected override sealed string FalseString ! { get { return "N"; } } ! public override string Name ! { get { return "YesNo"; } } Index: TrueFalseType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TrueFalseType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TrueFalseType.cs 10 Feb 2004 18:41:42 -0000 1.2 --- TrueFalseType.cs 18 Jul 2004 03:06:13 -0000 1.3 *************** *** 9,12 **** --- 9,20 ---- /// "T"/F" to indicate true/false. /// </summary> + /// <remarks> + /// If you are using schema-export to generate your tables then you need + /// to set the column attributes: <c>length=1</c> or <c>sql-type="char(1)"</c>. + /// + /// This needs to be done because in Java's JDBC there is a type for CHAR and + /// in ADO.NET there is not one specifically for char, so you need to tell schema + /// export to create a char(1) column. + /// </remarks> public class TrueFalseType: CharBooleanType { |
From: Michael D. <mik...@us...> - 2004-07-18 03:05:16
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Driver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9951/Driver Modified Files: DriverBase.cs IDriver.cs Log Message: Added ability for a Driver to disable calls to IDbCommand.Prepare() Index: DriverBase.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Driver/DriverBase.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DriverBase.cs 18 May 2004 05:02:27 -0000 1.4 --- DriverBase.cs 18 Jul 2004 03:05:08 -0000 1.5 *************** *** 81,84 **** --- 81,89 ---- } + public virtual bool SupportsPreparingCommands + { + get { return true; } + } + #endregion } Index: IDriver.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Driver/IDriver.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IDriver.cs 18 May 2004 05:02:27 -0000 1.3 --- IDriver.cs 18 Jul 2004 03:05:08 -0000 1.4 *************** *** 155,158 **** --- 155,175 ---- bool SupportsMultipleOpenReaders { get; } + /// <summary> + /// Does this Driver support IDbCommand.Prepare(). + /// </summary> + /// <remarks> + /// <para> + /// A value of <c>false</c> indicates that an exception would be thrown or the + /// company that produces the Driver we are wrapping does not recommend using + /// IDbCommand.Prepare(). + /// </para> + /// <para> + /// A value of <c>true</c> indicates that calling IDbCommand.Prepare() will function + /// fine on this Driver. + /// </para> + /// </remarks> + bool SupportsPreparingCommands { get; } + + } } |
From: Michael D. <mik...@us...> - 2004-07-16 03:58:18
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27563/nhibernate/src/NHibernate.Test Modified Files: FooBarTest.cs Log Message: Implemented more tests Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** FooBarTest.cs 16 Jul 2004 03:29:25 -0000 1.46 --- FooBarTest.cs 16 Jul 2004 03:58:10 -0000 1.47 *************** *** 2667,2673 **** [Test] ! [Ignore("Test not written yet.")] public void UserProvidedConnection() { } --- 2667,2688 ---- [Test] ! //[Ignore("Test not written yet.")] public void UserProvidedConnection() { + Connection.IConnectionProvider prov = Connection.ConnectionProviderFactory.NewConnectionProvider(cfg.Properties); + ISession s = sessions.OpenSession( prov.GetConnection() ); + ITransaction tx = s.BeginTransaction(); + s.Find("from foo in class NHibernate.DomainModel.Fo"); + tx.Commit(); + + IDbConnection c = s.Disconnect(); + Assert.IsNotNull(c); + + s.Reconnect(c); + tx = s.BeginTransaction(); + s.Find("from foo in class NHibernate.DomainModel.Fo"); + tx.Commit(); + Assert.AreSame( c, s.Close() ); + c.Close(); } |
From: Michael D. <mik...@us...> - 2004-07-16 03:58:04
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27513/nhibernate/src/NHibernate/Impl Modified Files: PreparerImpl.cs Log Message: Fixed problem where Commands from a string prepared in a Session with a Transaction that is Disconnected and Reconnected were not associated with the correct IDbTransaction. Found during writing of FooBarTest.UserSuppliedConnection Index: PreparerImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/PreparerImpl.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PreparerImpl.cs 25 Jun 2004 20:42:24 -0000 1.5 --- PreparerImpl.cs 16 Jul 2004 03:57:56 -0000 1.6 *************** *** 127,131 **** // don't need to be confused by that - just a normal part of initialization... if(command.Transaction!=null) ! log.Warn("The IDbCommand had a different Transaction than the Session."); command.Transaction = sessionAdoTrx; --- 127,132 ---- // don't need to be confused by that - just a normal part of initialization... if(command.Transaction!=null) ! log.Warn("The IDbCommand had a different Transaction than the Session. This can occur when " + ! "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific."); command.Transaction = sessionAdoTrx; *************** *** 180,184 **** if(preparedCommands.ContainsKey(sqlString)) { ! return (IDbCommand)preparedCommands[sqlString]; } --- 181,187 ---- if(preparedCommands.ContainsKey(sqlString)) { ! cmd = (IDbCommand)preparedCommands[sqlString]; ! cmd = JoinTransaction(cmd); ! return cmd; } |
From: Michael D. <mik...@us...> - 2004-07-16 03:29:44
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24586/nhibernate/src/NHibernate.Test Modified Files: FooBarTest.cs Log Message: Implemented more tests Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** FooBarTest.cs 15 Jul 2004 19:16:39 -0000 1.45 --- FooBarTest.cs 16 Jul 2004 03:29:25 -0000 1.46 *************** *** 2590,2596 **** [Test] - [Ignore("Test not written yet.")] public void AuotFlushCollections() { } --- 2590,2667 ---- [Test] public void AuotFlushCollections() { + ISession s = sessions.OpenSession(); + ITransaction tx = s.BeginTransaction(); + Baz baz = new Baz(); + baz.SetDefaults(); + s.Save(baz); + tx.Commit(); + s.Close(); + + s = sessions.OpenSession(); + tx = s.BeginTransaction(); + baz = (Baz)s.Load( typeof(Baz), baz.Code ); + baz.StringArray[0] = "bark"; + IEnumerator e = s.Enumerable("select baz.StringArray.elements from baz in class NHibernate.DomainModel.Baz").GetEnumerator(); + bool found = false; + while( e.MoveNext() ) + { + if ( "bark".Equals( e.Current ) ) + { + found = true; + } + } + Assert.IsTrue(found); + baz.StringArray = null; + e = s.Enumerable("select distinct baz.StringArray.elements from baz in class NHibernate.DomainModel.Baz").GetEnumerator(); + Assert.IsFalse( e.MoveNext() ); + baz.StringArray = new string[] {"foo", "bar"}; + e = s.Enumerable("select baz.StringArray.elements from baz in class NHibernate.DomainModel.Baz").GetEnumerator(); + Assert.IsTrue( e.MoveNext() ); + + Foo foo = new Foo(); + s.Save(foo); + s.Flush(); + baz.FooArray = new Foo[]{foo}; + + e = s.Enumerable("select foo from baz in class NHibernate.DomainModel.Baz, foo in baz.FooArray.elements").GetEnumerator(); + found = false; + while( e.MoveNext() ) + { + if ( foo==e.Current ) + { + found = true; + } + } + Assert.IsTrue(found); + + baz.FooArray[0] = null; + e = s.Enumerable("select foo from baz in class NHibernate.DomainModel.Baz, foo in baz.FooArray.elements").GetEnumerator(); + Assert.IsFalse( e.MoveNext() ); + baz.FooArray[0] = foo; + e = s.Enumerable("select baz.FooArray.elements from baz in class NHibernate.DomainModel.Baz").GetEnumerator(); + Assert.IsTrue( e.MoveNext() ); + + if( !(dialect is Dialect.MySQLDialect) + // HSQLDialect, InterbaseDialect, PointbaseDialect, SAPDBDialect + ) + { + baz.FooArray[0] = null; + e = s.Enumerable("from baz in class NHibernate.DomainModel.Baz where ? in baz.FooArray.elements", + foo, + NHibernate.Entity( typeof(Foo) ) ).GetEnumerator(); + + Assert.IsFalse( e.MoveNext() ); + baz.FooArray[0] = foo; + e = s.Enumerable("select foo from foo in class NHibernate.DomainModel.Foo where foo in " + + "(select elt from baz in class NHibernate.DomainModel.Baz, elt in baz.FooArray.elements)" + ).GetEnumerator(); + Assert.IsTrue( e.MoveNext() ); + } + s.Delete(foo); + s.Delete(baz); + tx.Commit(); + s.Close(); } |
From: Michael D. <mik...@us...> - 2004-07-16 03:27:22
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24352/nhibernate/src/NHibernate/Impl Modified Files: QueryImpl.cs Log Message: Added SetAnsiString to IQuery and QueryImpl for http://jira.nhibernate.org:8080/browse/NH-63 Index: QueryImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/QueryImpl.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** QueryImpl.cs 29 Apr 2004 14:00:52 -0000 1.9 --- QueryImpl.cs 16 Jul 2004 03:27:03 -0000 1.10 *************** *** 89,92 **** --- 89,98 ---- } + public IQuery SetAnsiString(int position, string val) + { + SetParameter(position, val, NHibernate.AnsiString); + return this; + } + public IQuery SetString(int position, string val) { SetParameter(position, val, NHibernate.String); *************** *** 154,157 **** --- 160,168 ---- } + public IQuery SetAnsiString(string name, string val) + { + SetParameter(name, val, NHibernate.AnsiString); + return this; + } public IQuery SetString(string name, string val) { |
From: Michael D. <mik...@us...> - 2004-07-16 03:27:21
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24352/nhibernate/src/NHibernate Modified Files: IQuery.cs Log Message: Added SetAnsiString to IQuery and QueryImpl for http://jira.nhibernate.org:8080/browse/NH-63 Index: IQuery.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/IQuery.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** IQuery.cs 20 Apr 2004 17:39:44 -0000 1.7 --- IQuery.cs 16 Jul 2004 03:27:03 -0000 1.8 *************** *** 169,172 **** --- 169,173 ---- IQuery SetProperties(object obj); + IQuery SetAnsiString(int position, string val); IQuery SetString(int position, string val); IQuery SetCharacter(int position, char val); *************** *** 183,186 **** --- 184,188 ---- IQuery SetTimestamp(int position, DateTime val); + IQuery SetAnsiString(string name, string val); IQuery SetString(string name, string val); IQuery SetCharacter(string name, char val); |
From: Michael D. <mik...@us...> - 2004-07-15 19:16:48
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3927/NHibernate.Test Modified Files: FooBarTest.cs Log Message: Implemented more tests. Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** FooBarTest.cs 14 Jul 2004 21:27:05 -0000 1.44 --- FooBarTest.cs 15 Jul 2004 19:16:39 -0000 1.45 *************** *** 28,32 **** "Immutable.hbm.xml" , "Fee.hbm.xml", ! //"Vetoer.hbm.xml", "Holder.hbm.xml", "Location.hbm.xml", --- 28,32 ---- "Immutable.hbm.xml" , "Fee.hbm.xml", ! "Vetoer.hbm.xml", "Holder.hbm.xml", "Location.hbm.xml", *************** *** 1979,1997 **** [Test] - [Ignore("Test not written yet.")] public void MultiColumnQueries() { } [Test] - [Ignore("Test not written yet.")] public void DeleteTransient() { } [Test] - [Ignore("Test not written yet.")] public void UpdateFromTransient() { } --- 1979,2170 ---- [Test] public void MultiColumnQueries() { + ISession s = sessions.OpenSession(); + Foo foo = new Foo(); + s.Save(foo); + Foo foo1 = new Foo(); + s.Save(foo1); + foo.TheFoo = foo1; + IList l = s.Find("select parent, child from parent in class NHibernate.DomainModel.Foo, child in class NHibernate.DomainModel.Foo where parent.TheFoo = child"); + Assert.AreEqual( 1, l.Count, "multi-column find" ); + + IEnumerator rs = s.Enumerable("select count(distinct child.id), count(distinct parent.id) from parent in class NHibernate.DomainModel.Foo, child in class NHibernate.DomainModel.Foo where parent.TheFoo = child").GetEnumerator(); + Assert.IsTrue( rs.MoveNext() ); + object[] row = (object[]) rs.Current; + Assert.AreEqual( 1, row[0], "multi-column count" ); + Assert.AreEqual( 1, row[1], "multi-column count" ); + Assert.IsFalse( rs.MoveNext() ); + + rs = s.Enumerable("select child.id, parent.id, child.Long from parent in class NHibernate.DomainModel.Foo, child in class NHibernate.DomainModel.Foo where parent.TheFoo = child").GetEnumerator(); + Assert.IsTrue( rs.MoveNext() ); + row = (object[]) rs.Current; + Assert.AreEqual( foo.TheFoo.Key, row[0], "multi-column id" ); + Assert.AreEqual( foo.Key, row[1], "multi-column id" ); + Assert.AreEqual( foo.TheFoo.Long, row[2], "multi-column property" ); + Assert.IsFalse( rs.MoveNext() ); + + rs = s.Enumerable("select child.id, parent.id, child.Long, child, parent.TheFoo from parent in class NHibernate.DomainModel.Foo, child in class NHibernate.DomainModel.Foo where parent.TheFoo = child").GetEnumerator(); + Assert.IsTrue( rs.MoveNext() ); + row = (object[]) rs.Current; + Assert.AreEqual( foo.TheFoo.Key, row[0], "multi-column id" ); + Assert.AreEqual( foo.Key, row[1], "multi-column id" ); + Assert.AreEqual( foo.TheFoo.Long, row[2], "multi-column property" ); + Assert.AreSame( foo.TheFoo, row[3], "multi-column object" ); + Assert.AreSame( row[3], row[4], "multi-column same object" ); + Assert.IsFalse( rs.MoveNext() ); + + row = (object[])l[0]; + Assert.AreSame( foo, row[0], "multi-column find" ); + Assert.AreSame( foo.TheFoo, row[1], "multi-column find" ); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + IEnumerator enumer = s.Enumerable("select parent, child from parent in class NHibernate.DomainModel.Foo, child in class NHibernate.DomainModel.Foo where parent.TheFoo = child and parent.String='a string'").GetEnumerator(); + int deletions = 0; + while( enumer.MoveNext() ) + { + object[] pnc = (object[]) enumer.Current; + s.Delete(pnc[0]); + s.Delete(pnc[1]); + deletions++; + } + Assert.AreEqual( 1, deletions, "multi-column enumerate"); + s.Flush(); + s.Close(); } [Test] public void DeleteTransient() { + Fee fee = new Fee(); + ISession s = sessions.OpenSession(); + ITransaction tx = s.BeginTransaction(); + s.Save(fee); + s.Flush(); + fee.Count = 123; + tx.Commit(); + s.Close(); + + s = sessions.OpenSession(); + tx = s.BeginTransaction(); + s.Delete(fee); + tx.Commit(); + s.Close(); + + s = sessions.OpenSession(); + tx = s.BeginTransaction(); + Assert.AreEqual( 0, s.Find("from fee in class Fee").Count ); + tx.Commit(); + s.Close(); } [Test] public void UpdateFromTransient() { + ISession s = sessions.OpenSession(); + Fee fee1 = new Fee(); + s.Save(fee1); + Fee fee2 = new Fee(); + fee1.TheFee = fee2; + fee2.TheFee = fee1; + fee2.Fees = new Hashtable(); + Fee fee3 = new Fee(); + fee3.TheFee = fee1; + fee3.AnotherFee = fee2; + fee2.AnotherFee = fee3; + s.Save(fee3); + s.Save(fee2); + s.Flush(); + s.Close(); + + fee1.Fi = "changed"; + s = sessions.OpenSession(); + s.SaveOrUpdate(fee1); + s.Flush(); + s.Close(); + + Qux q = new Qux("quxxy"); + //TODO: not sure the test will work with this because unsaved-value="0" + // and in h2.0.3 it is unsaved-value="null" + q.TheKey = 0; + fee1.Qux = q; + s = sessions.OpenSession(); + s.SaveOrUpdate(fee1); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + fee1 = (Fee)s.Load( typeof(Fee), fee1.Key ); + Assert.AreEqual( "changed", fee1.Fi, "updated from transient" ); + Assert.IsNotNull( fee1.Qux, "unsaved-value" ); + s.Delete( fee1.Qux ); + fee1.Qux = null; + s.Flush(); + s.Close(); + + fee2.Fi = "CHANGED"; + fee2.Fees.Add( "an element", new object() ); + fee1.Fi = "changed again"; + s = sessions.OpenSession(); + s.SaveOrUpdate(fee2); + s.Update( fee1, fee1.Key ); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + Fee fee = new Fee(); + s.Load( fee, fee2.Key ); + fee1 = (Fee)s.Load( typeof(Fee), fee1.Key ); + Assert.AreEqual("changed again", fee1.Fi, "updated from transient" ); + Assert.AreEqual("CHANGED", fee.Fi, "updated from transient" ); + Assert.IsTrue( fee.Fees.Contains("an element"), "updated collection" ); + s.Flush(); + s.Close(); + + fee.Fees.Clear(); + fee.Fees.Add("new element", new object() ); + fee1.TheFee = null; + s = sessions.OpenSession(); + s.SaveOrUpdate(fee); + s.SaveOrUpdate(fee1); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + s.Load( fee, fee.Key ); + Assert.IsNotNull( fee.AnotherFee, "update" ); + Assert.IsNotNull( fee.TheFee, "update" ); + Assert.AreSame( fee.AnotherFee.TheFee, fee.TheFee, "update" ); + Assert.IsTrue( fee.Fees.Contains("new element"), "updated collection" ); + Assert.IsFalse( fee.Fees.Contains("an element"), "updated collection" ); + s.Flush(); + s.Close(); + + fee.Qux = new Qux("quxy"); + s = sessions.OpenSession(); + s.SaveOrUpdate(fee); + s.Flush(); + s.Close(); + + fee.Qux.Stuff = "xxx"; + s = sessions.OpenSession(); + s.SaveOrUpdate(fee); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + s.Load( fee, fee.Key ); + Assert.IsNotNull( fee.Qux, "cascade update" ); + Assert.AreEqual( "xxx", fee.Qux.Stuff, "cascade update" ); + Assert.IsNotNull( fee.AnotherFee, "update" ); + Assert.IsNotNull( fee.TheFee, "update" ); + Assert.AreSame( fee.AnotherFee.TheFee, fee.TheFee, "update" ); + fee.AnotherFee.AnotherFee = null; + s.Delete(fee); + s.Delete("from fee in class NHibernate.DomainModel.Fee"); + s.Flush(); + s.Close(); } *************** *** 2009,2027 **** [Test] - [Ignore("Test not written yet.")] public void Components() { } [Test] - [Ignore("Test not written yet.")] public void Enum() { } [Test] - [Ignore("Test not written yet.")] public void NoForeignKeyViolations() { } --- 2182,2274 ---- [Test] public void Components() { + ISession s = sessions.OpenSession(); + Foo foo = new Foo(); + foo.Component = new FooComponent( "foo", 69, null, new FooComponent("bar", 96, null, null) ); + s.Save(foo); + foo.Component.Name = "IFA"; + s.Flush(); + s.Close(); + + foo.Component = null; + s = sessions.OpenSession(); + s.Load( foo, foo.Key ); + + Assert.AreEqual( "IFA", foo.Component.Name, "save components" ); + Assert.AreEqual( "bar", foo.Component.Subcomponent.Name, "save subcomponent" ); + Assert.IsNotNull( foo.Component.Glarch, "cascades save via component"); + foo.Component.Subcomponent.Name = "baz"; + s.Flush(); + s.Close(); + + foo.Component = null; + s = sessions.OpenSession(); + s.Load( foo, foo.Key ); + Assert.AreEqual( "IFA", foo.Component.Name, "update components" ); + Assert.AreEqual( "baz", foo.Component.Subcomponent.Name, "update subcomponent" ); + s.Delete(foo); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + foo = new Foo(); + s.Save(foo); + foo.Custom = new string[] {"one", "two"}; + + // Custom.s1 uses the first column under the <property name="Custom"...> + // which is first_name + Assert.AreSame( foo, s.Find("from Foo foo where foo.Custom.s1 = 'one'")[0] ); + s.Delete(foo); + s.Flush(); + s.Close(); } [Test] public void Enum() { + ISession s = sessions.OpenSession(); + FooProxy foo = new Foo(); + object id = s.Save(foo); + foo.Status = FooStatus.ON; + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + foo = (FooProxy)s.Load( typeof(Foo), id ); + Assert.AreEqual( FooStatus.ON, foo.Status ); + foo.Status = FooStatus.OFF; + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + foo = (FooProxy)s.Load( typeof(Foo), id); + Assert.AreEqual( FooStatus.OFF, foo.Status ); + s.Delete(foo); + s.Flush(); + s.Close(); + } [Test] public void NoForeignKeyViolations() { + ISession s = sessions.OpenSession(); + Glarch g1 = new Glarch(); + Glarch g2 = new Glarch(); + g1.Next = g2; + g2.Next = g1; + s.Save(g1); + s.Save(g2); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + IList l = s.Find("from g in class NHibernate.DomainModel.Glarch where g.Next is not null"); + s.Delete( l[0] ); + s.Delete( l[1] ); + s.Flush(); + s.Close(); + } *************** *** 2074,2086 **** [Test] - [Ignore("Test not written yet.")] public void NewSessionLifecycle() { } [Test] - [Ignore("Test not written yet.")] public void Disconnect() { } --- 2321,2410 ---- [Test] public void NewSessionLifecycle() { + ISession s = sessions.OpenSession(); + ITransaction t = s.BeginTransaction(); + object fid = null; + try + { + Foo f = new Foo(); + s.Save(f); + fid = s.GetIdentifier(f); + //s.Flush(); + t.Commit(); + } + catch (Exception e) + { + t.Rollback(); + throw e; + } + finally + { + s.Close(); + } + + s = sessions.OpenSession(); + t = s.BeginTransaction(); + try + { + Foo f = new Foo(); + s.Delete(f); + //s.Flush(); + t.Commit(); + } + catch (Exception e) + { + t.Rollback(); + } + finally + { + s.Close(); + } + + s = sessions.OpenSession(); + t = s.BeginTransaction(); + try + { + Foo f = (Foo)s.Load( typeof(Foo), fid, LockMode.Upgrade ); + s.Delete(f); + // s.Flush(); + t.Commit(); + } + catch(Exception e) + { + t.Rollback(); + throw e; + } + finally + { + Assert.IsNull( s.Close() ); + } + } [Test] public void Disconnect() { + ISession s = sessions.OpenSession(); + Foo foo = new Foo(); + Foo foo2 = new Foo(); + s.Save(foo); + s.Save(foo2); + foo2.TheFoo = foo; + s.Flush(); + s.Disconnect(); + + s.Reconnect(); + s.Delete(foo); + foo2.TheFoo = null; + s.Flush(); + s.Disconnect(); + + s.Reconnect(); + s.Delete(foo2); + s.Flush(); + s.Close(); + + } *************** *** 2092,2102 **** [Test] - [Ignore("Test not written yet.")] public void ManyToOne() { } [Test] - [Ignore("won't work without proxy")] public void SaveDelete() { --- 2416,2447 ---- [Test] public void ManyToOne() { + ISession s = sessions.OpenSession(); + One one = new One(); + s.Save(one); + one.Value = "yada"; + Many many = new Many(); + many.One = one; + s.Save(many); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + one = (One)s.Load( typeof(One), one.Key ); + int count = one.Manies.Count; + s.Close(); + + s = sessions.OpenSession(); + many = (Many)s.Load( typeof(Many), many.Key ); + Assert.IsNotNull( many.One, "many-to-one assoc" ); + s.Delete( many.One ); + s.Delete(many); + s.Flush(); + s.Close(); + } [Test] public void SaveDelete() { *************** *** 2146,2170 **** [Test] - [Ignore("Test not written yet.")] public void FindLoad() { } [Test] - [Ignore("Test not written yet.")] public void Refresh() { } [Test] - [Ignore("Test not written yet.")] public void AutoFlush() { } [Test] - [Ignore("Test not written yet.")] public void Veto() { } --- 2491,2584 ---- [Test] public void FindLoad() { + ISession s = sessions.OpenSession(); + FooProxy foo = new Foo(); + s.Save(foo); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + foo = (FooProxy)s.Find("from foo in class NHibernate.DomainModel.Foo")[0]; + FooProxy foo2 = (FooProxy)s.Load( typeof(Foo), foo.Key ); + Assert.AreSame( foo, foo2, "find returns same object as load" ); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + foo2 = (FooProxy)s.Load( typeof(Foo), foo.Key ); + foo = (FooProxy)s.Find("from foo in class NHibernate.DomainModel.Foo")[0]; + Assert.AreSame( foo2, foo, "find returns same object as load" ); + s.Delete("from foo in class NHibernate.DomainModel.Foo"); + s.Flush(); + s.Close(); } [Test] public void Refresh() { + ISession s = sessions.OpenSession(); + Foo foo = new Foo(); + s.Save(foo); + s.Flush(); + + IDbCommand cmd = s.Connection.CreateCommand(); + cmd.CommandText = "update " + dialect.QuoteForTableName("foos") + " set long_ = -3"; + cmd.ExecuteNonQuery(); + s.Refresh(foo); + Assert.AreEqual( (long)-3, foo.Long ) ; + s.Delete(foo); + s.Flush(); + s.Close(); + } [Test] public void AutoFlush() { + ISession s = sessions.OpenSession(); + FooProxy foo = new Foo(); + s.Save(foo); + Assert.AreEqual( 1, s.Find("from foo in class NHibernate.DomainModel.Foo").Count, "autoflush inserted row" ); + foo.Char = 'X'; + Assert.AreEqual( 1, s.Find("from foo in class NHibernate.DomainModel.Foo where foo.Char='X'").Count, "autflush updated row" ); + s.Close(); + + s = sessions.OpenSession(); + foo = (FooProxy)s.Load( typeof(Foo), foo.Key ); + + if( !(dialect is Dialect.MySQLDialect) + // && !(dialect is Dialect.HSQLDialect) + // && !(dialect is Dialect.PointbaseDialect) + ) + { + foo.Bytes = System.Text.UnicodeEncoding.Unicode.GetBytes("osama"); + Assert.AreEqual( 1, s.Find("from foo in class NHibernate.DomainModel.Foo where 111 in foo.Bytes.elements").Count, "autoflush collection update" ); + foo.Bytes[0] = 69; + Assert.AreEqual( 1, s.Find("from foo in class NHibernate.DomainModel.Foo where 69 in foo.Bytes.elements").Count, "autoflush collection update" ); + } + + s.Delete(foo); + Assert.AreEqual( 0, s.Find("from foo in class NHibernate.DomainModel.Foo").Count, "autoflush delete" ); + s.Close(); + } [Test] public void Veto() { + ISession s = sessions.OpenSession(); + Vetoer v = new Vetoer(); + s.Save(v); + object id = s.Save(v); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + s.Update(v, id); + s.Update(v, id); + s.Delete(v); + s.Delete(v); + s.Close(); } |
From: Michael D. <mik...@us...> - 2004-07-15 19:16:48
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3927/NHibernate.DomainModel Modified Files: Baz.hbm.xml Log Message: Implemented more tests. Index: Baz.hbm.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Baz.hbm.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Baz.hbm.xml 30 Jun 2004 18:23:09 -0000 1.13 --- Baz.hbm.xml 15 Jul 2004 19:16:39 -0000 1.14 *************** *** 192,196 **** </map> ! <set name="StringSet" lazy="true" sort="NHibernate.DomainModel.StringComparator, NHibernate.DomainModel"> <!--<jcs-cache usage="read-write"/>--> <!-- commented out in h2.0.3 also --> --- 192,200 ---- </map> ! <set ! name="StringSet" ! lazy="true" ! sort="NHibernate.DomainModel.StringComparator, NHibernate.DomainModel" ! > <!--<jcs-cache usage="read-write"/>--> <!-- commented out in h2.0.3 also --> |
From: Michael D. <mik...@us...> - 2004-07-15 19:16:21
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3840/NHibernate.Test Modified Files: FumTest.cs ParentChildTest.cs Log Message: Modified Vetoer so it now binds correctly. Still have an issue with it that I need to look at. Index: ParentChildTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ParentChildTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ParentChildTest.cs 9 Jun 2004 01:22:37 -0000 1.2 --- ParentChildTest.cs 15 Jul 2004 19:16:12 -0000 1.3 *************** *** 25,29 **** "Immutable.hbm.xml", "Fee.hbm.xml", ! //"Vetoer.hbm.xml", "Holder.hbm.xml", "ParentChild.hbm.xml", --- 25,29 ---- "Immutable.hbm.xml", "Fee.hbm.xml", ! "Vetoer.hbm.xml", "Holder.hbm.xml", "ParentChild.hbm.xml", Index: FumTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FumTest.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FumTest.cs 18 Jun 2004 13:48:11 -0000 1.6 --- FumTest.cs 15 Jul 2004 19:16:12 -0000 1.7 *************** *** 33,37 **** "Immutable.hbm.xml", "Fee.hbm.xml", ! //"Vetoer.hbm.xml", "Holder.hbm.xml", "Location.hbm.xml", --- 33,37 ---- "Immutable.hbm.xml", "Fee.hbm.xml", ! "Vetoer.hbm.xml", "Holder.hbm.xml", "Location.hbm.xml", |
From: Michael D. <mik...@us...> - 2004-07-15 19:16:21
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3840/NHibernate.DomainModel Modified Files: Vetoer.hbm.xml Log Message: Modified Vetoer so it now binds correctly. Still have an issue with it that I need to look at. Index: Vetoer.hbm.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Vetoer.hbm.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Vetoer.hbm.xml 3 Jun 2004 18:55:57 -0000 1.3 --- Vetoer.hbm.xml 15 Jul 2004 19:16:12 -0000 1.4 *************** *** 12,16 **** </id> <property name="Name" /> ! <property name="Strings" /><!-- TODO: fix that NH is not recognizing this as an array --> </class> </hibernate-mapping> \ No newline at end of file --- 12,20 ---- </id> <property name="Name" /> ! <property name="Strings" type="System.String[]"/> ! <!-- ! TODO: fix that NH is not recognizing this as an serializable object and that I have to add ! type="System.String[]" to the property ! --> </class> </hibernate-mapping> \ No newline at end of file |