realm-kotlin icon indicating copy to clipboard operation
realm-kotlin copied to clipboard

RealmSingleQuery with flow doesn't provide latest updates

Open gauravbordoloi opened this issue 1 year ago • 1 comments

How frequently does the bug occur?

Always

Description

When we use the below code for getting object change results, it doesn't work.

dbModule.getRealm()
            .query(SaleModel::class, "_id == $0", RealmUUID.from(id))
            .first()
            .asFlow()
            .cancellable()
            .mapLatest {
                it.obj
            }

I have to do like below to get the results

dbModule.getRealm()
            .query(SaleModel::class, "_id == $0", RealmUUID.from(id))
            .asFlow()
            .cancellable()
            .mapLatest {
                it.list.firstOrNull()
            }

Do RealmSingleQuery not support object change?

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

1.13.0

What Atlas App Services are you using?

Local Database only

Are you using encryption?

Yes

Platform OS and version(s)

Android 13

Build environment

No response

gauravbordoloi avatar Jan 09 '24 14:01 gauravbordoloi

Hi @gauravbordoloi We have a test for this scenario here: https://github.com/realm/realm-kotlin/blob/8046324f8da33b57d5457f5d3e27b43dacf8ab66/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/QueryTests.kt#L1841

So it should work.

Can you provide a fully working sample where it doesn't work?

cmelchior avatar Jan 09 '24 15:01 cmelchior