Skip to content

Commit 251ed3b

Browse files
committed
NH-3586
Fixed Decimals with precisions larger than 18
1 parent 2948d6d commit 251ed3b

File tree

2 files changed

+232
-126
lines changed

2 files changed

+232
-126
lines changed

src/NHibernate.Test/DialectTest/FirebirdDialectFixture.cs

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,65 @@ namespace NHibernate.Test.DialectTest
66
{
77
[TestFixture]
88
public class FirebirdDialectFixture
9-
{
10-
[Test]
11-
public void GetLimitString()
12-
{
13-
FirebirdDialect d = new FirebirdDialect();
9+
{
10+
#region Tests
11+
[Test]
12+
public void GetLimitString()
13+
{
14+
FirebirdDialect d = MakeDialect();
1415

15-
SqlString str = d.GetLimitString(new SqlString("SELECT * FROM fish"), null, new SqlString("10"));
16-
Assert.AreEqual("SELECT first 10 * FROM fish", str.ToString());
16+
SqlString str = d.GetLimitString(new SqlString("SELECT * FROM fish"), null, new SqlString("10"));
17+
Assert.AreEqual("SELECT first 10 * FROM fish", str.ToString());
1718

18-
str = d.GetLimitString(new SqlString("SELECT * FROM fish ORDER BY name"), new SqlString("5"), new SqlString("15"));
19-
Assert.AreEqual("SELECT first 15 skip 5 * FROM fish ORDER BY name", str.ToString());
19+
str = d.GetLimitString(new SqlString("SELECT * FROM fish ORDER BY name"), new SqlString("5"), new SqlString("15"));
20+
Assert.AreEqual("SELECT first 15 skip 5 * FROM fish ORDER BY name", str.ToString());
2021

21-
str = d.GetLimitString(new SqlString("SELECT * FROM fish ORDER BY name DESC"), new SqlString("7"), new SqlString("28"));
22-
Assert.AreEqual("SELECT first 28 skip 7 * FROM fish ORDER BY name DESC", str.ToString());
22+
str = d.GetLimitString(new SqlString("SELECT * FROM fish ORDER BY name DESC"), new SqlString("7"), new SqlString("28"));
23+
Assert.AreEqual("SELECT first 28 skip 7 * FROM fish ORDER BY name DESC", str.ToString());
2324

24-
str = d.GetLimitString(new SqlString("SELECT DISTINCT fish.family FROM fish ORDER BY name DESC"), null, new SqlString("28"));
25-
Assert.AreEqual("SELECT first 28 DISTINCT fish.family FROM fish ORDER BY name DESC", str.ToString());
25+
str = d.GetLimitString(new SqlString("SELECT DISTINCT fish.family FROM fish ORDER BY name DESC"), null, new SqlString("28"));
26+
Assert.AreEqual("SELECT first 28 DISTINCT fish.family FROM fish ORDER BY name DESC", str.ToString());
2627

27-
str = d.GetLimitString(new SqlString("SELECT DISTINCT fish.family FROM fish ORDER BY name DESC"), new SqlString("7"), new SqlString("28"));
28-
Assert.AreEqual("SELECT first 28 skip 7 DISTINCT fish.family FROM fish ORDER BY name DESC", str.ToString());
29-
}
30-
}
28+
str = d.GetLimitString(new SqlString("SELECT DISTINCT fish.family FROM fish ORDER BY name DESC"), new SqlString("7"), new SqlString("28"));
29+
Assert.AreEqual("SELECT first 28 skip 7 DISTINCT fish.family FROM fish ORDER BY name DESC", str.ToString());
30+
}
31+
32+
[Test]
33+
public void GetTypeName_DecimalWithoutPrecisionAndScale_ReturnsDecimalWithPrecisionOf18AndScaleOf5()
34+
{
35+
var fbDialect = MakeDialect();
36+
37+
var result = fbDialect.GetTypeName(NHibernateUtil.Decimal.SqlType);
38+
39+
Assert.AreEqual("DECIMAL(18, 5)", result);
40+
}
41+
42+
[Test]
43+
public void GetTypeName_DecimalWithPrecisionAndScale_ReturnsPrecisedAndScaledDecimal()
44+
{
45+
var fbDialect = MakeDialect();
46+
47+
var result = fbDialect.GetTypeName(NHibernateUtil.Decimal.SqlType, 0, 17, 2);
48+
49+
Assert.AreEqual("DECIMAL(17, 2)", result);
50+
}
51+
52+
[Test]
53+
public void GetTypeName_DecimalWithPrecisionGreaterThanFbMaxPrecision_ReturnsDecimalWithFbMaxPrecision()
54+
{
55+
var fbDialect = MakeDialect();
56+
57+
var result = fbDialect.GetTypeName(NHibernateUtil.Decimal.SqlType, 0, 19, 2); //Firebird allows a maximum precision of 18
58+
59+
Assert.AreEqual("DECIMAL(18, 2)", result);
60+
}
61+
#endregion
62+
63+
#region Private Members
64+
private static FirebirdDialect MakeDialect()
65+
{
66+
return new FirebirdDialect();
67+
}
68+
#endregion
69+
}
3170
}

0 commit comments

Comments
 (0)