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

undefined selector doesn't work in SQLite #6792

Closed
marius-se opened this issue Jan 29, 2025 · 3 comments
Closed

undefined selector doesn't work in SQLite #6792

marius-se opened this issue Jan 29, 2025 · 3 comments

Comments

@marius-se
Copy link

I'm using the Capactior SQLite adapter and noticed that a query like this:

const selector: MangoQuerySelector<ValveDocument> = {
  radiator_id: radiatorId,
  replaced_valve_id: undefined, // <--- this is the troublemaker
};

return this.db.valves
  .findOne({ selector })

doesn't return any results: It does however return the correct result when using the IndexedDB adapter. The document I'm trying to find looks exactly the same in both storages (IndexedDB and Capacitor SQLite): In both cases the replaced_valve_id key/value is not present at all.

This is the document in the IndexedDB (as you can see -> no replaced_valve_id):

Image

This is the document in SQLite (also no replaced_valve_id):

Image

If I remove the replaced_valve_id: undefined it'll work correctly with both storage adapters!

@pubkey
Copy link
Owner

pubkey commented Jan 30, 2025

@marius-se Can you paste your schema or send it to me privately via discord?

@pubkey
Copy link
Owner

pubkey commented Jan 30, 2025

Ok I did some investigations.

I will add a dev-mode check to ensure a query is not allowed to have undefined in it. There is no real reason to ever put this in.

To query for documents where field X does not exists, use the $exists operator or { $eq: null }.

pubkey added a commit that referenced this issue Jan 30, 2025
* ADD test for #6792

* REMOVE logs

* FIX query tests

* FIX reactive query test

* FIX typo

* ADD dev-mode check for `undefined` properties in queries. #6792

* REMOVE logs

* REMOVE logs
@pubkey
Copy link
Owner

pubkey commented Jan 30, 2025

Fixed here: #6795

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

No branches or pull requests

2 participants