-
Type: Task
-
Resolution: Fixed
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
The recently released realm-core caused a test failure in the Dart SDK:
The important part of the test is:
final results = realmObject.list.query(r"nullableDecimalProp IN $0 || stringProp IN $0", [ ['text1', null, 2.2, 3] // Searching by different type of values and null ]);
where realmObject.list is a list of embedded objects with a nullableDecimalProp (with type Decimal128?) and a stringProp (with type String).
This query now throws an error, since you cannot compare nullableDecimalProp with 'text1' because of the type mismatch.
This a change in semantics, and I believe one we should avoid. Let me try to explain.
From a mathematical point of view, if x in X and y in Y, then both x and y in X union Y. If x can never be in Y does not change that fact. For the example above, just because nullabeDecimalProp can never be a String does not imply that it cannot be a member of a set, that happens to also contain {{String}}s.
As I can understand this issue arise from the fact that IN in realm, semantically behave like a gigantic OR clause, so {{x in
{y, z}}} is equivalent to x == z OR x == y. But I would argue that even such an expression should not throw as long as one of the sides can be true.
Expected results
Test should pass
Actual Results
00:02 +27 ~1 -1: Query embedded objects list with list argument with different type of values [E] RealmException: Cannot convert 'text1' to a unknown. Error code: 3015. package:realm_dart/src/native/realm_core.dart 142:11 _RealmCore.throwLastError.<fn> ...
Steps & Code to Reproduce
run dart test -j1 test/embedded_test.dart (on fx. release/2.2.1 branch)
Core version
Core version: v14.7.0