Skip to content

inValues() bug? #1204

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

Open
1 task
udyr-woo opened this issue Mar 31, 2025 · 2 comments
Open
1 task

inValues() bug? #1204

udyr-woo opened this issue Mar 31, 2025 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@udyr-woo
Copy link

Is there an existing issue?

Build info

  • ObjectBox version: 4.0.0
  • OS: Android13
  • Device/ABI/architecture: odroid-m2

Steps to reproduce

Even if an instance with id that is not in compositeIdArray is changed, observeRepeaterInputUiListByStatusAndCompositeIdArray() emits again.

Expected behavior

I hope that don't emit irrelevant items.

Actual behavior

Code

Code
override fun observeRepeaterInputUiListByStatusAndCompositeIdArray(
        compositeIdArray: LongArray,
        vararg statuses: RepeaterInputUiStatus
    ): Flow<List<RepeaterInputUiEntity>> =
        repeaterInputUiBoxProvider.observeBox().flatMapLatest { box ->
            box.query {
                if (statuses.isNotEmpty()) {
                    equal(RepeaterInputUiEntity_.currentStatus, statuses[0].code)
                    for (i in 1 until statuses.size) {
                        or()
                        equal(RepeaterInputUiEntity_.currentStatus, statuses[i].code)
                    }
                }
                inValues(RepeaterInputUiEntity_.compositeId, compositeIdArray)
                eager(RepeaterInputUiEntity_.flt)
            }.flow()
        }.flowOn(ioDispatcher)

Logs, stack traces

Logs
[Paste your logs here]
@udyr-woo udyr-woo added the bug Something isn't working label Mar 31, 2025
@greenrobot-team
Copy link
Member

greenrobot-team commented Mar 31, 2025

Thanks for reporting, however this is by design.

Note that query.flow() is a shortcut for query.subscribe().toFlow(). And for subscribe() the observer will receive new results on any changes to the Box of the Entity this queries, regardless of the conditions of the query. This is because the QueryPublisher used for the subscription observes changes by using BoxStore.subscribe(Class) on the Box this queries.

To customize this or for advanced use cases, consider using BoxStore.subscribe(Class<T> forClass) directly.

I'll keep this open until I have updated the API documentation for this.

@greenrobot-team greenrobot-team added documentation Improvements or additions to documentation and removed bug Something isn't working labels Mar 31, 2025
@greenrobot-team greenrobot-team self-assigned this Mar 31, 2025
@udyr-woo
Copy link
Author

Thanks for reporting, however this is by design.

Note that query.flow() is a shortcut for query.subscribe().toFlow(). And for subscribe() the observer will receive new results on any changes to the Box of the Entity this queries, regardless of the conditions of the query. This is because the QueryPublisher used for the subscription observes changes by using BoxStore.subscribe(Class) on the Box this queries.

To customize this or for advanced use cases, consider using BoxStore.subscribe(Class) directly.

I'll keep this open until I have updated the API documentation for this.

Ok. Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants