[GH-ISSUE #73] Indexed query with double filter on key fails #52

Closed
opened 2026-05-23 08:28:24 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @appy-one on GitHub (Feb 21, 2022).
Original GitHub issue: https://github.com/appy-one/acebase/issues/73

Originally assigned to: @appy-one on GitHub.

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

Originally created by @appy-one on GitHub (Feb 21, 2022). Original GitHub issue: https://github.com/appy-one/acebase/issues/73 Originally assigned to: @appy-one on GitHub. 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: ```js 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_
gitea-mirror 2026-05-23 08:28:24 -06:00
Author
Owner

@appy-one commented on GitHub (Feb 21, 2022):

Published fix in v1.15.0

<!-- gh-comment-id:1047155677 --> @appy-one commented on GitHub (Feb 21, 2022): Published fix in v1.15.0
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase#52
No description provided.