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

collection.findByIds() accepts chain queries, but does nothing with them #6148

Closed
MrChadMWood opened this issue Jun 25, 2024 · 3 comments
Closed
Labels

Comments

@MrChadMWood
Copy link

MrChadMWood commented Jun 25, 2024

As seen below, I try querying with chained operators in order to add additional conditions to findByIds. In practice, I'm trying to get records from the array of IDs where actual_finish_date=null. For demonstration purposes, I'm searching for 'some-fake-value'.

Following, I convert the returned Map into an array to see the values returned. Based on the accepted query, I would expect all returns to have the value of actual_finish_date='some-fake-value'. However, I'm simply given all records that match the array of IDs, without any filtration done based on the value of actual_finish_date.

This is therefore the wrong result to my query. If findByIds does not support chained queries, I would guess an error should be thrown. The acceptance of the query is what confuses me. Would the bug be the lack of filtration, or the acceptance of the chained query?

12:16:39.715 >>> test = await database.collections.space_task_schedule.findByIds(spaceTaskIds).where('actual_finish_date').eq('some-fake-value').exec()
12:16:39.745 Map(69) { 66 → {…}, 504 → {…}, 940 → {…}, 1377 → {…}, 1814 → {…}, 2251 → {…}, 2688 → {…}, 3125 → {…}, 3564 → {…}, 3999 → {…}, … }

12:16:44.625 >>> Array.from(test).map(d => d[1].actual_finish_date)
12:16:44.650 Array(69) [ null, null, null, null, null, null, null, null, null, null, … ]

Versions:

"rxdb": "15.24.0",
"rxdb-hooks": "5.0.2",
"rxjs": "7.8.1",

This is the case with Dexie and Memory storage.

@pubkey
Copy link
Owner

pubkey commented Jun 25, 2024

Hi @MrChadMWood
This is a good catch. Chained queries cannot be used on RxQuery instances that are created with findByIds. I will add a check to ensure this is properly shown to the developer.

Copy link

stale bot commented Jul 2, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon. Please update it or it may be closed to keep our repository organized. The best way is to add some more information or make a pull request with a test case. Also you might get help in fixing it at the RxDB Community Chat If you know you will continue working on this, just write any message to the issue (like "ping") to remove the stale tag.

@stale stale bot added the stale label Jul 2, 2024
@pubkey
Copy link
Owner

pubkey commented Jul 3, 2024

This check was added. Please check the latest release.

@pubkey pubkey closed this as completed Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants