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");
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Mehta
  • 1,228
  • 1
  • 9
  • 27
  • Actually, I am getting wrong values after converting to realm database. So I want to print my realm query to identify the issue – Mehta Apr 20 '18 at 07:33
  • 1
    refer this link go to the end of this website and read about SQLite and Realm https://www.androidhive.info/2016/05/android-working-with-realm-database-replacing-sqlite-core-data/ @Mehta – Ali Apr 20 '18 at 07:38
  • I don't see any reason why that shouldn't work if you are using latest Realm (5.0.1) – EpicPandaForce Apr 20 '18 at 08:08

1 Answers1

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.

Marcel Hofgesang
  • 951
  • 1
  • 15
  • 36