realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.78k stars 573 forks source link

Type issues with Unmanaged<T, RequiredProperties> #6037

Open Yupeng-li opened 1 year ago

Yupeng-li commented 1 year ago

How frequently does the bug occur?

Always

Description

When using Realm classes, we noticed a few type issues all related to Unmanaged<T, RequiredKeys>.

  1. When specifying the RequiredProperties in Realm.Object<T, RequiredProperties>, the properties of type Realm.List or Realm.Dictionary are not allowed.
  2. If RequiredProperties is not provided when defining the class, the constructor accepts string as values.
  3. Unmanaged nested Realm.Object is not allowed in Realm.create. It's also reported in #5940

The details are available in the mini repo I attached.

If anyone is interested, I made a patch to resolve the issue 1 & 3 for now. https://gist.github.com/Yupeng-li/655eaf75f46086c4345a78e27dfa3c5e

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

Please check this codesandbox mini repo for details. (Please ignore the browser view on the right hand side. )

Version

11.7 & 11.9

What services are you using?

Local Database only

Are you using encryption?

Yes

Platform OS and version(s)

All

Build environment

Which debugger for React Native: ..

Cocoapods version

No response

takameyer commented 1 year ago

@Yupeng-li Thanks for reporting this and for providing a reproduction and workaround! I'll take a look at your suggestions and decide how best to move forward.

edhage commented 7 months ago

Is this solved yet, I have the same problem. In fact the example https://github.com/mongodb-industry-solutions/Vehicle-Digital-Twin-Feedback-Loop is not working because of this.

kneth commented 4 months ago

@edhage I believe it hasn't been solve yet