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

Improve error message when inserting a list into a mixed property #3730

Closed
kraenhansen opened this issue May 11, 2021 · 2 comments · Fixed by #3847
Closed

Improve error message when inserting a list into a mixed property #3730

kraenhansen opened this issue May 11, 2021 · 2 comments · Fixed by #3847
Assignees

Comments

@kraenhansen
Copy link
Member

kraenhansen commented May 11, 2021

Goals

Clear and actionable error messages.

Expected Results

An error message such as:

A mixed property doesn't support lists of values

Actual Results

The following error is thrown:

Error: Only Realm instances are supported.

Steps to Reproduce & Code Sample

  1. Open a Realm with a schema declaring a mixed property.
  2. Try inserting a list of values
const realm = new Realm({
  schema: [{
    name: "MixedClass",
    properties: { value: "mixed" },
  }],
});
realm.write(() => {
  realm.create("MixedClass", { value: [123, false, "hello"] });
});

Version of Realm and Tooling

  • Realm JS SDK Version: 10.5.0-beta.1
  • Node or React Native: Tested on Node.js
  • Client OS & Version: N/A
  • Which debugger for React Native: None
@davidaharlow
Copy link

davidaharlow commented Jul 2, 2021

Same For Me with 10.5.0 (not beta) on ReactNative

Expected:
A mixed property doesn't support lists of values

Actual:
Error: Only Realm instances are supported.

Version of Realm and Tooling
Realm JS SDK Version: 10.5.0
Node or React Native: Tested on React Native
Which debugger for React Native: Flipper

@cesarvr cesarvr removed their assignment Jul 5, 2021
@kneth
Copy link
Contributor

kneth commented Jul 9, 2021

The reason is that we have a late type deduction for Mixed values, and the code path followed in this case is that array is interpreted as an object (which is a link when it is stored in Realm) since Array is also an Object in JavaScript.

We should put in an earlier check to guard against array and other not support types.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants