Skip to content

Indexed query with double filter on key fails #73

@appy-one

Description

@appy-one

When executing a query with multiple filters on an indexed key, execution will return wrong results if the index has include keys, or crash with an TypeError: Cannot read properties of undefined (reading '[key]') if the index has no include keys.

Example:

await db.indexes.create('meteorites', 'name'); // Create index on name, no additional included keys
const snaps = await db.query('meteorites')
    .filter('name', '!like', 'L*')
    .filter('name', '!=', 'Acapulco') // Another filter on name causes the crash
    .get();

This is caused by initial index results being filtered on metadata (include) filters, but the index' key is (obviously) not in the metadata. Solution: filter index results on the indexed value if key equals index.key

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingindexes

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions