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

Trouble query data when query condition has type number on Android #3773

Closed
DuCaoTien opened this issue Jun 2, 2021 · 7 comments
Closed

Comments

@DuCaoTien
Copy link

DuCaoTien commented Jun 2, 2021

Hi guys! The realm library was so useful for our project. Appreciate your team efforts.
According to what we found out. The feature query with number values did not require quotes (" ") to cover the value. But I don't know why when using the realm version 10.4.0. We can't query data as expected. Two points to note:

  1. We didn't change any query statement or code on our project, only update the realm lib (10.2.0 -> 10.4.0).
  2. The trouble is only on Android.
    Right now, We resolved the trouble by adding quotes (" ") to cover the value like this and it worked:
    timestamp >= 1622623523121 AND timestamp <= 162262370312 (not working)
    Screen Shot 2021-06-02 at 03 53 07
    timestamp >= "1622623523121" AND timestamp <= "162262370312" (worked)
    Screen Shot 2021-06-02 at 03 57 21
    Questions:
    I. Will there be any trouble if we change all our related codes (add " " to cover the number value on statements query) to solve this problem?
    II. Can you explain to me why there is such trouble? (The trouble is only on Android with version realm is 10.4.0. It worked fine on IOS)
    Your supports were so helpful to our team. Thanks.

Version of Realm and Tooling

  • Realm JS SDK Version: 10.4.0
  • React Native: 0.64.0
  • Client OS & Version: macOS Catalina (10.15.7)
  • Which debugger for React Native: None
@ironage
Copy link
Contributor

ironage commented Jun 2, 2021

Hi @DuCaoTien, what is the Realm property type of Reading.timestamp? Is this actually a timestamp or is it an integer type or something else?

@DuCaoTien
Copy link
Author

DuCaoTien commented Jun 3, 2021

Hi @ironage. Timestamp type is integer
Screen Shot 2021-06-02 at 21 00 06

@kneth
Copy link
Contributor

kneth commented Jun 3, 2021

@DuCaoTien Can you try the same query in Studio?

@DuCaoTien
Copy link
Author

DuCaoTien commented Jun 3, 2021

Hi @kneth, It works fine when I try the same query in Studio both normal and add " " to cover the number value on statements query.
Screen Shot 2021-06-03 at 05 02 56
Screen Shot 2021-06-03 at 05 03 08

@ironage
Copy link
Contributor

ironage commented Jun 3, 2021

Thanks for the info @DuCaoTien, can you confirm if the Android device that is not working is a 32 bit? It looks like you discovered a regression introduced in our new query parser which affects integer constants which use more than 32 bits of storage. It should be addressed by realm/realm-core#4736. But in the meantime, I would recommend passing argument into the query string with argument substitution instead of trying to do the formatting yourself. That would look like this:
this.realm?.objects('Reading').filtered("timestamp >= $0 AND timestamp <= $1", now - SYNC_INTERVAL * 1000, now)

@DuCaoTien
Copy link
Author

Great. Your idea seems to be correct. I'm working on an emulator 32-bit. I tried to change to a 64-bit and it worked with the old query statements so there is more evidence to confirm that this problem only occurs on 32-bit boards.
I also tried to query with your recommend this format and it worked fine both on 32-bit and 64-bit emulators. Thanks for your help. @ironage

@ironage
Copy link
Contributor

ironage commented Jun 4, 2021

Thanks for confirming the 32 bit issue @DuCaoTien!

@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

No branches or pull requests

3 participants