Printing a Realm Query
Asked Answered
E

1

4

I am migrating my existing project's database from SQLite to Realm. So there is a way to print Query like we can get/print in SQLite.

SQL Query:

select * from Patient where "revision=8" and (long_description like="%bone%" or code like="%bone%") order by code

My Realm Query:

realm.where(Patient.class)
     .equalTo("revision", "8")
     .and()
     .beginGroup()
         .like("long_description", "*bone*").or()
         .like("code", "*bone*")
     .endGroup()
     .sort("code");
Emma answered 20/4, 2018 at 7:29 Comment(3)
Actually, I am getting wrong values after converting to realm database. So I want to print my realm query to identify the issueEmma
refer this link go to the end of this website and read about SQLite and Realm androidhive.info/2016/05/… @EmmaRagwort
I don't see any reason why that shouldn't work if you are using latest Realm (5.0.1)Gabriel
H
0

May be a bit late and not exactly what you are looking for, but with

RealmQuery query = realm.where(Patient.class)
                            .equalTo("revision", "8")
                            .and()
                            .beginGroup()
                            .like("long_description", "*bone*").or()
                            .like("code", "*bone*")
                            .endGroup()
                            .sort("code");
query.getDescription()

you are able to see a textual descriptiopn of your query. This may make it easier to compare the SQLite and Realm queries.

Hairspring answered 13/6, 2022 at 11:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.