Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operator IN behaviour #7714

Closed
nielsenko opened this issue May 21, 2024 · 1 comment · Fixed by #7715
Closed

Operator IN behaviour #7714

nielsenko opened this issue May 21, 2024 · 1 comment · Fixed by #7715
Assignees

Comments

@nielsenko
Copy link
Contributor

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 Strings.

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

Copy link

sync-by-unito bot commented May 21, 2024

➤ PM Bot commented:

Jira ticket: RCORE-2131

@jedelbo jedelbo self-assigned this May 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants