question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[5.0.0] Android returns Results with length 1 but no keys or values

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:33 (14 by maintainers)

github_iconTop GitHub Comments

8reactions
saravanakumargncommented, Mar 26, 2020

I am facing the same issue. Android its not working. iOS Working.

    "realm": "^5.0.2",

This is the results i am getting in Android Device.

{"0": {}, "1": {}, "2": {}, "3": {}, "4": {}, "5": {}, "6": {}, "7": {}, "8": {}}

iOS (Simulator) it’s working as expected Realm without any issues…

4reactions
keimacommented, Jun 9, 2020

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:

export class RealmPlayLog extends Realm.Object {
  static readonly schema: ObjectSchema = schema

  ...
}

Not working correctly:

export class RealmPlayLog {
  static readonly schema: ObjectSchema = schema

  ...
}

“realm”: “^6.0.1” (yarn.lock says 6.0.1) “react-native”: “0.61.5”,

iOS Simulator: iPhone 11 (13.1)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android 5.0 Compatibility Definition
A value chosen by the device implementer containing the name of the device as known to the end user. This SHOULD be the...
Read more >
Array Length returns 0 - Stack Overflow
Your Array needs a numeric input, you're currently using an empty string as an Index, which is invalid. You can either specify an...
Read more >
Voice Android SDK Changelog | Twilio
The SDK compileSDKVersion and targetSDKVersion were updated to 30 from 28. No changes are required to migrate to this version in an existing...
Read more >
Android Developers Guide | Parse
Values can be strings, numbers, booleans, or even arrays and objects - anything that can be JSON-encoded. Each ParseObject has a class name...
Read more >
Realm: Create reactive mobile apps in a fraction ... - MongoDB
findAll(); puppies.size(); // => 0 because no dogs have been added to the ... You can use the standalone Realm Browser Mac application...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found