Skip to content

Commit a4278ce

Browse files
Raise maximal decimal precision from 28 to 29 when .Net is the limiting factor.
* Adjust default registrations of decimal and currency accross dialects for consistency. * Cease applying the decimal limit to Oracle double. * Fixes nhibernate#1606
1 parent 9e7ad12 commit a4278ce

16 files changed

+32
-25
lines changed

src/NHibernate/Cfg/Environment.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public static string Version
226226

227227
/// <summary>
228228
/// Set the default precision used in casting when the target type is decimal and
229-
/// does not specify it. <c>28</c> by default, automatically trimmed down according to dialect type registration.
229+
/// does not specify it. <c>29</c> by default, automatically trimmed down according to dialect type registration.
230230
/// </summary>
231231
public const string QueryDefaultCastPrecision = "query.default_cast_precision";
232232

src/NHibernate/Dialect/DB2Dialect.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ public DB2Dialect()
3535
RegisterColumnType(DbType.Binary, 2147483647, "BLOB");
3636
RegisterColumnType(DbType.Boolean, "SMALLINT");
3737
RegisterColumnType(DbType.Byte, "SMALLINT");
38-
RegisterColumnType(DbType.Currency, "DECIMAL(16,4)");
38+
RegisterColumnType(DbType.Currency, "DECIMAL(18,4)");
3939
RegisterColumnType(DbType.Date, "DATE");
4040
RegisterColumnType(DbType.DateTime, "TIMESTAMP");
4141
RegisterColumnType(DbType.Decimal, "DECIMAL(19,5)");
4242
// DB2 max precision is 31, but .Net is 28-29 anyway.
43-
RegisterColumnType(DbType.Decimal, 28, "DECIMAL($p, $s)");
43+
RegisterColumnType(DbType.Decimal, 29, "DECIMAL($p, $s)");
4444
RegisterColumnType(DbType.Double, "DOUBLE");
4545
RegisterColumnType(DbType.Int16, "SMALLINT");
4646
RegisterColumnType(DbType.Int32, "INTEGER");

src/NHibernate/Dialect/Dialect.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private static Dialect InstantiateDialect(string dialectName, IDictionary<string
201201
public virtual void Configure(IDictionary<string, string> settings)
202202
{
203203
DefaultCastLength = PropertiesHelper.GetInt32(Environment.QueryDefaultCastLength, settings, 4000);
204-
DefaultCastPrecision = PropertiesHelper.GetByte(Environment.QueryDefaultCastPrecision, settings, null) ?? 28;
204+
DefaultCastPrecision = PropertiesHelper.GetByte(Environment.QueryDefaultCastPrecision, settings, null) ?? 29;
205205
DefaultCastScale = PropertiesHelper.GetByte(Environment.QueryDefaultCastScale, settings, null) ?? 10;
206206
}
207207

src/NHibernate/Dialect/InformixDialect.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ public InformixDialect()
4545
RegisterColumnType(DbType.Binary, 2147483647, "BYTE");
4646
RegisterColumnType(DbType.Binary, "BYTE");
4747
RegisterColumnType(DbType.Boolean, "BOOLEAN");
48-
RegisterColumnType(DbType.Currency, "DECIMAL(16,4)");
48+
RegisterColumnType(DbType.Currency, "DECIMAL(18,4)");
4949
RegisterColumnType(DbType.Byte, "SMALLINT");
5050
RegisterColumnType(DbType.Date, "DATE");
5151
RegisterColumnType(DbType.DateTime, "datetime year to fraction(5)");
5252
RegisterColumnType(DbType.Decimal, "DECIMAL(19, 5)");
5353
// Informix max precision is 32, but .Net is limited to 28-29.
54-
RegisterColumnType(DbType.Decimal, 28, "DECIMAL($p, $s)");
54+
RegisterColumnType(DbType.Decimal, 29, "DECIMAL($p, $s)");
5555
RegisterColumnType(DbType.Double, "DOUBLE");
5656
RegisterColumnType(DbType.Int16, "SMALLINT");
5757
RegisterColumnType(DbType.Int32, "INTEGER");

src/NHibernate/Dialect/IngresDialect.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ public IngresDialect()
3232
RegisterColumnType(DbType.Binary, 2147483647, "bytea");
3333
RegisterColumnType(DbType.Boolean, "boolean");
3434
RegisterColumnType(DbType.Byte, "int2");
35-
RegisterColumnType(DbType.Currency, "decimal(16,4)");
35+
RegisterColumnType(DbType.Currency, "decimal(18,4)");
3636
RegisterColumnType(DbType.Date, "date");
3737
RegisterColumnType(DbType.DateTime, "timestamp");
3838
RegisterColumnType(DbType.Decimal, "decimal(19,5)");
3939
// Ingres max precision is 31, but .Net is limited to 28-29.
40-
RegisterColumnType(DbType.Decimal, 28, "decimal($p, $s)");
40+
RegisterColumnType(DbType.Decimal, 29, "decimal($p, $s)");
4141
RegisterColumnType(DbType.Double, "float8");
4242
RegisterColumnType(DbType.Int16, "int2");
4343
RegisterColumnType(DbType.Int32, "int4");

src/NHibernate/Dialect/MsSql2000Dialect.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ protected virtual void RegisterNumericTypeMappings()
376376
RegisterColumnType(DbType.Currency, "MONEY");
377377
RegisterColumnType(DbType.Decimal, "DECIMAL(19,5)");
378378
// SQL Server max precision is 38, but .Net is limited to 28-29.
379-
RegisterColumnType(DbType.Decimal, 28, "DECIMAL($p, $s)");
379+
RegisterColumnType(DbType.Decimal, 29, "DECIMAL($p, $s)");
380380
RegisterColumnType(DbType.Double, "FLOAT(53)");
381381
RegisterColumnType(DbType.Int16, "SMALLINT");
382382
RegisterColumnType(DbType.Int32, "INT");

src/NHibernate/Dialect/MsSqlCeDialect.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ protected virtual void RegisterTypeMapping()
151151
RegisterColumnType(DbType.DateTime, "DATETIME");
152152
RegisterColumnType(DbType.Decimal, "NUMERIC(19,5)");
153153
// SQL Server CE max precision is 38, but .Net is limited to 28-29.
154-
RegisterColumnType(DbType.Decimal, 28, "NUMERIC($p, $s)");
154+
RegisterColumnType(DbType.Decimal, 29, "NUMERIC($p, $s)");
155155
RegisterColumnType(DbType.Double, "FLOAT");
156156
RegisterColumnType(DbType.Guid, "UNIQUEIDENTIFIER");
157157
RegisterColumnType(DbType.Int16, "SMALLINT");

src/NHibernate/Dialect/MySQL5Dialect.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public MySQL5Dialect()
99
{
1010
RegisterColumnType(DbType.Decimal, "DECIMAL(19,5)");
1111
// My SQL supports precision up to 65, but .Net is limited to 28-29.
12-
RegisterColumnType(DbType.Decimal, 28, "DECIMAL($p, $s)");
12+
RegisterColumnType(DbType.Decimal, 29, "DECIMAL($p, $s)");
1313
RegisterColumnType(DbType.Guid, "BINARY(16)");
1414
}
1515

@@ -18,7 +18,7 @@ protected override void RegisterCastTypes() {
1818
// MySql 5 also supports DECIMAL as a cast type target
1919
// http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html
2020
RegisterCastType(DbType.Decimal, "DECIMAL(19,5)");
21-
RegisterCastType(DbType.Decimal, 28, "DECIMAL($p, $s)");
21+
RegisterCastType(DbType.Decimal, 29, "DECIMAL($p, $s)");
2222
RegisterCastType(DbType.Double, "DECIMAL(19,5)");
2323
RegisterCastType(DbType.Single, "DECIMAL(19,5)");
2424
RegisterCastType(DbType.Guid, "BINARY(16)");

src/NHibernate/Dialect/MySQLDialect.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ public MySQLDialect()
7878
RegisterColumnType(DbType.Byte, "TINYINT UNSIGNED");
7979
RegisterColumnType(DbType.Currency, "NUMERIC(18,4)");
8080
RegisterColumnType(DbType.Decimal, "NUMERIC(19,5)");
81-
RegisterColumnType(DbType.Decimal, 19, "NUMERIC($p, $s)");
81+
// Prior to version 5, decimal was stored as a string, so it was supporting a huge precision. Limiting to
82+
// .Net capabilities.
83+
RegisterColumnType(DbType.Decimal, 29, "NUMERIC($p, $s)");
8284
RegisterColumnType(DbType.Double, "DOUBLE");
8385
//The signed range is -32768 to 32767. The unsigned range is 0 to 65535.
8486
RegisterColumnType(DbType.Int16, "SMALLINT");

src/NHibernate/Dialect/Oracle8iDialect.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,14 @@ protected virtual void RegisterNumericTypeMappings()
182182
RegisterColumnType(DbType.UInt32, "NUMBER(10,0)");
183183
RegisterColumnType(DbType.UInt64, "NUMBER(20,0)");
184184

185+
// 6.0 TODO: bring down to 18,4 for consistency with other dialects.
185186
RegisterColumnType(DbType.Currency, "NUMBER(22,4)");
186187
RegisterColumnType(DbType.Single, "FLOAT(24)");
187188
RegisterColumnType(DbType.Double, "DOUBLE PRECISION");
188-
// Oracle max precision is 39-40, but .Net is limited to 28-29.
189-
RegisterColumnType(DbType.Double, 28, "NUMBER($p,$s)");
189+
RegisterColumnType(DbType.Double, 40, "NUMBER($p,$s)");
190190
RegisterColumnType(DbType.Decimal, "NUMBER(19,5)");
191-
RegisterColumnType(DbType.Decimal, 28, "NUMBER($p,$s)");
191+
// Oracle max precision is 39-40, but .Net is limited to 28-29.
192+
RegisterColumnType(DbType.Decimal, 29, "NUMBER($p,$s)");
192193
}
193194

194195
protected virtual void RegisterDateTimeTypeMappings()

src/NHibernate/Dialect/OracleLiteDialect.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ public OracleLiteDialect()
3939
RegisterColumnType(DbType.Binary, 2147483647, "BLOB");
4040
RegisterColumnType(DbType.Boolean, "NUMBER(1,0)");
4141
RegisterColumnType(DbType.Byte, "NUMBER(3,0)");
42-
RegisterColumnType(DbType.Currency, "NUMBER(19,1)");
42+
// 6.0 TODO: bring down to 18,4 for consistency with other dialects.
43+
RegisterColumnType(DbType.Currency, "NUMBER(22,4)");
4344
RegisterColumnType(DbType.Date, "DATE");
4445
RegisterColumnType(DbType.DateTime, "TIMESTAMP(4)");
4546
RegisterColumnType(DbType.Decimal, "NUMBER(19,5)");
4647
// Oracle max precision is 39-40, but .Net is limited to 28-29.
47-
RegisterColumnType(DbType.Decimal, 28, "NUMBER($p, $s)");
48+
RegisterColumnType(DbType.Decimal, 29, "NUMBER($p, $s)");
4849
// having problems with both ODP and OracleClient from MS not being able
4950
// to read values out of a field that is DOUBLE PRECISION
5051
RegisterColumnType(DbType.Double, "DOUBLE PRECISION"); //"FLOAT(53)" );

src/NHibernate/Dialect/PostgreSQLDialect.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ public PostgreSQLDialect()
4444
RegisterColumnType(DbType.Binary, 2147483647, "bytea");
4545
RegisterColumnType(DbType.Boolean, "boolean");
4646
RegisterColumnType(DbType.Byte, "int2");
47-
RegisterColumnType(DbType.Currency, "decimal(16,4)");
47+
RegisterColumnType(DbType.Currency, "decimal(18,4)");
4848
RegisterColumnType(DbType.Decimal, "decimal(19,5)");
4949
// PostgreSQL max precision is unlimited, but .Net is limited to 28-29.
50-
RegisterColumnType(DbType.Decimal, 28, "decimal($p, $s)");
50+
RegisterColumnType(DbType.Decimal, 29, "decimal($p, $s)");
5151
RegisterColumnType(DbType.Double, "float8");
5252
RegisterColumnType(DbType.Int16, "int2");
5353
RegisterColumnType(DbType.Int32, "int4");

src/NHibernate/Dialect/SybaseASA9Dialect.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public SybaseASA9Dialect()
5050
RegisterColumnType(DbType.Currency, "DECIMAL(18,4)");
5151
RegisterColumnType(DbType.Date, "DATE");
5252
RegisterColumnType(DbType.DateTime, "TIMESTAMP");
53-
RegisterColumnType(DbType.Decimal, "DECIMAL(18,5)"); // NUMERIC(18,5) is equivalent to DECIMAL(18,5)
53+
RegisterColumnType(DbType.Decimal, "DECIMAL(19,5)"); // NUMERIC(18,5) is equivalent to DECIMAL(18,5)
5454
// Sybase max precision is 38, but .Net is limited to 28-29.
55-
RegisterColumnType(DbType.Decimal, 28, "DECIMAL($p,$s)");
55+
RegisterColumnType(DbType.Decimal, 29, "DECIMAL($p,$s)");
5656
RegisterColumnType(DbType.Double, "DOUBLE");
5757
RegisterColumnType(DbType.Guid, "CHAR(16)");
5858
RegisterColumnType(DbType.Int16, "SMALLINT");

src/NHibernate/Dialect/SybaseASE15Dialect.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ public SybaseASE15Dialect()
3636
RegisterColumnType(DbType.Int16, 255, "tinyint");
3737
RegisterColumnType(DbType.Int32, "int");
3838
RegisterColumnType(DbType.Int64, "bigint");
39-
RegisterColumnType(DbType.Decimal, "numeric(18,0)");
39+
// 6.0 TODO: bring down to 19,5 for consistency with other dialects.
40+
RegisterColumnType(DbType.Decimal, "numeric(23,5)");
41+
// Maximal precision is said to be 38, but .Net is limited to 28-29.
42+
RegisterColumnType(DbType.Decimal, 29, "numeric($p,$s)");
4043
RegisterColumnType(DbType.Single, "real");
4144
RegisterColumnType(DbType.Double, "float");
4245
RegisterColumnType(DbType.AnsiStringFixedLength, "char(255)");

src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected virtual void RegisterNumericTypeMappings()
9292
RegisterColumnType(DbType.Double, "DOUBLE");
9393
RegisterColumnType(DbType.Decimal, "NUMERIC(19,5)"); // Precision ranges from 0-127
9494
// Anywhere max precision is 127, but .Net is limited to 28-29.
95-
RegisterColumnType(DbType.Decimal, 28, "NUMERIC($p, $s)"); // Precision ranges from 0-127
95+
RegisterColumnType(DbType.Decimal, 29, "NUMERIC($p, $s)"); // Precision ranges from 0-127
9696
}
9797

9898
protected virtual void RegisterDateTimeTypeMappings()

src/NHibernate/nhibernate-configuration.xsd

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
<xs:annotation>
188188
<xs:documentation>
189189
Set the default precision used in casting when the target type is decimal and
190-
does not specify it. 28 by default, automatically trimmed down according to dialect type registration.
190+
does not specify it. 29 by default, automatically trimmed down according to dialect type registration.
191191
</xs:documentation>
192192
</xs:annotation>
193193
</xs:enumeration>

0 commit comments

Comments
 (0)