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

Error in Dexie 4: Failed to execute 'cmp' on 'IDBFactory': The parameter is not a valid key #2064

Open
probert94 opened this issue Sep 2, 2024 · 1 comment

Comments

@probert94
Copy link

probert94 commented Sep 2, 2024

I recently updated Dexie from 3.2.6 to 4.0.8. Since then one of my queries throws the error Failed to execute 'cmp' on 'IDBFactory': The parameter is not a valid key in certain cases.
The query looks like this:

await this.table("table")
    .where({foreignKey1: "1", foreignKey2: "1"})
    .toArray()

After some investigation I found, that the error is thrown, if there are entries for "foreignKey1" where "foreignKey2" is "null".
In my case the foreignKey1 is never "null" so switching order of the fields in "where" solves the error and this code works:

await this.table("table")
    .where({foreignKey2: "1", foreignKey1: "1"})
    .toArray()

As I did not define a compound index for the two fields it shows a warning but returns the correct results.

@dfahlander
Copy link
Collaborator

Thanks. The behaviour should be fixed by switching to using cmp.ts instead of idb.cmp() at this location. By using cmp.ts (which is also much faster that indexedDB.cmp()), a null comparision returns NaN instead of throwing, which is what would be correct here.

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

No branches or pull requests

2 participants