Skip to content

Commit 31c2133

Browse files
committed
Update local_store_indexeddb.test.ts
1 parent f932645 commit 31c2133

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

packages/firestore/test/unit/local/local_store_indexeddb.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,4 +892,49 @@ describe('LocalStore w/ IndexedDB Persistence (Non generic)', () => {
892892
test.assertRemoteDocumentsRead(0, 1);
893893
test.assertQueryReturned('coll/a');
894894
});
895+
896+
it('index auto creation does not work with multiple inequality', async () => {
897+
const query_ = query(
898+
'coll',
899+
filter('field1', '<', 5),
900+
filter('field2', '<', 5)
901+
);
902+
903+
const targetId = await test.allocateQuery(query_);
904+
test.configureIndexAutoCreation({
905+
isEnabled: true,
906+
indexAutoCreationMinCollectionSize: 0,
907+
relativeIndexReadCostPerDocument: 2
908+
});
909+
910+
await test.applyRemoteEvents(
911+
docAddedRemoteEvent(doc('coll/a', 10, { field1: 1, field2: 2 }), [
912+
targetId
913+
]),
914+
docAddedRemoteEvent(doc('coll/b', 10, { field1: 8, field2: 2 }), [
915+
targetId
916+
]),
917+
docAddedRemoteEvent(doc('coll/c', 10, { field1: 'string', field2: 2 }), [
918+
targetId
919+
]),
920+
docAddedRemoteEvent(doc('coll/d', 10, { field1: 1 }), [targetId]),
921+
docAddedRemoteEvent(doc('coll/e', 10, { field1: 4, field2: 4 }), [
922+
targetId
923+
])
924+
);
925+
926+
// First time query runs without indexes.
927+
// Based on current heuristic, collection document counts (5) >
928+
// 2 * resultSize (2).
929+
// Full matched index will not be created since FieldIndex does not
930+
// support multiple inequality.
931+
await test.executeQuery(query_);
932+
test.assertRemoteDocumentsRead(0, 2);
933+
test.assertQueryReturned('coll/a', 'coll/e');
934+
935+
await test.backfillIndexes();
936+
await test.executeQuery(query_);
937+
test.assertRemoteDocumentsRead(0, 2);
938+
test.assertQueryReturned('coll/a', 'coll/e');
939+
});
895940
});

0 commit comments

Comments
 (0)