Skip to content

Commit 00d28bf

Browse files
committed
Fixed wrong parameter on ROUND call
1 parent 0be3dd6 commit 00d28bf

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

LiteDB.Tests/Expressions/Expressions_Exec_Tests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ BsonValue S(string s, params BsonValue[] args)
234234
S("LENGTH(b)").ExpectValue(3);
235235
S("LENGTH(arr)").ExpectValue(3);
236236
S("LENGTH($)").ExpectValue(5);
237+
238+
S("ROUND(DECIMAL(123.45678), 3)").ExpectValue(123.457m);
239+
S("ROUND(DOUBLE(123.45678), 3)").ExpectValue(123.457d);
237240
}
238241

239242
[Fact]
@@ -259,7 +262,7 @@ BsonValue P(string s, params BsonValue[] args)
259262
P("ARRAY(arr[@ > @0])", 3).ExpectArray(4, 5);
260263

261264
// using map
262-
P("ARRAY(MAP(ITEMS(@0) => (@ + @1)))", new BsonArray(new BsonValue[] {10, 11, 12}), 5)
265+
P("ARRAY(MAP(ITEMS(@0) => (@ + @1)))", new BsonArray(new BsonValue[] { 10, 11, 12 }), 5)
263266
.ExpectArray(15, 16, 17);
264267

265268
// sort ascending

LiteDB/Document/Expression/Methods/Math.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public static BsonValue ROUND(BsonValue value, BsonValue digits)
3737
{
3838
case BsonType.Int32: return value.AsInt32;
3939
case BsonType.Int64: return value.AsInt64;
40-
case BsonType.Double: return Math.Round(value.AsDouble, value.AsInt32);
41-
case BsonType.Decimal: return Math.Round(value.AsDecimal, value.AsInt32);
40+
case BsonType.Double: return Math.Round(value.AsDouble, digits.AsInt32);
41+
case BsonType.Decimal: return Math.Round(value.AsDecimal, digits.AsInt32);
4242
}
4343

4444
}

0 commit comments

Comments
 (0)