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.

RealmQuery between problems with double datatype

See original GitHub issue

I want to get data from Realm Cloud with between filter 2 numbers. Previously I used long type for date column and It will return value if I query this:

long start = calendarStart.getTimeInMillis() / 1000;
long end = calendarEnd.getTimeInMillis() / 1000;

result =  getRealmSyncInstance()
                .where(MyClass.class)
//                .greaterThanOrEqualTo("date", start)
//                .lessThanOrEqualTo("date", end)
                .between("date", start, end)
                .sort("date", Sort.ASCENDING)
                .findAllAsync();

Then I clear Realm Cloud and change local MyClass date, start, end from long to double. Then no result received. I also use greaterThanOrEqualTo and lessThanOrEqualTo but no luck.

Seem like it only happens on realm cloud.

Version of Realm and tooling

Realm version(s): 5.0.0

Realm sync feature enabled: yes

Android Studio version: 3.1

Which Android version and device: Oreo

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
nhachichacommented, Jul 11, 2018

Hi @kainjinez I was able to reproduce your issue, it looks like the Sync query parser failed to parse the mathematical notation .lessThanOrEqualTo("value", 10_000_000d) which result in 1e+07 (full query value >= 0 and value <= 1e+07 SORT(timestamp DESC)). I’m investigating with the Core team to provide a fix

0reactions
nhachichacommented, Sep 6, 2018

closing please follow progress in realm/realm-core#3076

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrate realm field of type double to new sub-object with values
Something like this should work: RealmObjectSchema valueSchema = schema.create("Value") .addField("value", Integer.class) .
Read more >
Realm Query Language - MongoDB
Realm Query Language (RQL) is a string-based query language to constrain searches when retrieving objects from a realm. SDK-specific methods pass queries to ......
Read more >
Difference Between float vs double Data Types [Updated]
Float and double are primitive data types used by programming languages to store floating-point real (decimal) numbers like 10.923455, ...
Read more >
Decimal vs Double in SQL - ObjectRocket
Postgresql supports a wide variety of native data types. Among them are text data types, numeric data types, date and times, Boolean data...
Read more >
Create reactive mobile apps in a fraction of the time - Realm
Build the query looking at all users: RealmQuery<User> query = realm.where(User.class); // Add ... Not all conditions are applicable for all data types....
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