realm-js: [5.0.0] Android returns Results with length 1 but no keys or values
Goals
I am trying to fetch some objects from database.
Expected Results
Getting 1 object with all properties.
Actual Results
I get Results of length 1 but when getting the object via index 0, it returns no properties.
Steps to Reproduce
Run the code on Android
Code Sample
const results = realm
.objects<ImporterAuthenticationModel>(ImporterAuthenticationModel.schema.name)
.filtered('importerId = $0', importer.importer.id);
if (results) {
console.log(results.length);
console.log(results[0].id);
}
Output is:
1
undefined
Schema:
export class ImporterAuthenticationModel extends BaseModel {
public static schema = {
...BaseModel.schema,
name: 'ImporterAuthenticationModel',
primaryKey: 'uniqueId',
properties: {
...BaseModel.schema.properties,
uniqueId: 'string',
id: 'string',
title: 'string',
subTitle: 'string?',
imageUrl: 'string?',
importerId: 'string',
additionalDataString: 'string?',
rawStatus: { type: 'int', default: ImporterAuthenticationStatus.AUTHENTICATED },
expiresAt: 'int'
}
};
Version of Realm and Tooling
- Realm JS SDK Version: 5.0.0
- Node or React Native: React Native
- Client OS & Version: Android 9PKQ1.181121.001 (Mi 9 Lite)
- Which debugger for React Native: React Native Debugger (but it also fails if using production build from FireBase)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 33 (14 by maintainers)
I am facing the same issue. Android its not working. iOS Working.
This is the results i am getting in Android Device.
iOS (Simulator) it’s working as expected Realm without any issues…
Same problem is here. But our project uses
realm.objects()
methods everywhere and some method call is fine but others not working.Upon investigation, we found that it worked fine for classes that inherited from
Realm.Object
, but returned an empty object for classes that didn’t. This is odd.Working correctly:
Not working correctly:
“realm”: “^6.0.1” (yarn.lock says 6.0.1) “react-native”: “0.61.5”,
iOS Simulator: iPhone 11 (13.1)
I can confirm the issue on with React Native 0.61.5 and Realm 5.0.2 on Android running in an emulator. Thanks for reporting this @bimusiek!
@MrScorp did you used a debugger when checking that. Could you try without attaching a debugger
Realm JS 5.0.3 is released fixing this. Closing this issue. If it is not fixed for someone for some unexpected reason, just reopen it.
@kraenhansen I am passing
ImporterAuthenticationModel.schema
to realm.where schema & schemaVersion are:
The same code works on both 3.6.5 version and 4.0.0-beta2. 5.0.x works on iOS + Electron + Node Server but it does not return any keys and values on Android. Creating & updating models work though, and it is synced to the Cloud.
I tried bumping JSC to newest version, it did not help.