You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LiteDB 5.0.1 and the latest from repo, Windows 10, net45
Describe the bug
In the expression IIF(X, IfTrue, IfFalse), both IfTrue and IfFalse seem to be evaluated.
As a result, evaluation of one of them may fail when X is supposed to avoid this evaluation with invalid arguments.
Code to Reproduce
varex1=BsonExpression.Create("IIF(LENGTH($.x) >= 5, SUBSTRING($.x, 0, 5), \"too-short\")");vardoc1=newBsonDocument();// OK ("12345")doc1["x"]="123456789";varr1=ex1.ExecuteScalar(doc1);Console.WriteLine($"{r1}");// KO (expected: "too-short", actual: System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.)doc1["x"]="123";varr2=ex1.ExecuteScalar(doc1);Console.WriteLine($"{r2}");
Expected behavior
See code comments.
Screenshots/Stacktrace
Output of the above code:
"12345"
Unhandled Exception: System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
at System.String.Substring(Int32 startIndex, Int32 length)
at LiteDB.BsonExpressionMethods.SUBSTRING(BsonValue value, BsonValue startIndex, BsonValue length)
at lambda_method(Closure , IEnumerable`1 , BsonDocument , BsonValue , Collation , BsonDocument )
at LiteDB.BsonExpression.ExecuteScalar(IEnumerable`1 source, BsonDocument root, BsonValue current, Collation collation)
at LiteDB.BsonExpression.ExecuteScalar(BsonDocument root, Collation collation)
The text was updated successfully, but these errors were encountered:
Version
LiteDB 5.0.1 and the latest from repo, Windows 10, net45
Describe the bug
In the expression
IIF(X, IfTrue, IfFalse)
, bothIfTrue
andIfFalse
seem to be evaluated.As a result, evaluation of one of them may fail when
X
is supposed to avoid this evaluation with invalid arguments.Code to Reproduce
Expected behavior
See code comments.
Screenshots/Stacktrace
Output of the above code:
The text was updated successfully, but these errors were encountered: