Skip to content

Relaxing in restrictions. #6757

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

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
effced9
Add composite filters. Port of https://github.com/firebase/firebase-a…
MarkDuckworth Jun 24, 2022
eba3b84
Cleanup: lint
MarkDuckworth Jun 24, 2022
33a0896
Support encoding and decoding Composite Filters
MarkDuckworth Jun 29, 2022
9f6e216
Formatting
MarkDuckworth Jun 30, 2022
a722abc
Add composite filters in support of OR queries (#6385)
MarkDuckworth Jul 26, 2022
6556240
Merge remote-tracking branch 'origin/markduckworth/or-queries' into m…
MarkDuckworth Jul 26, 2022
78a8900
Fix issue with readonly array.
MarkDuckworth Jul 26, 2022
80fc05d
WIP: serving results from index.
MarkDuckworth Aug 5, 2022
1e33050
Support encoding and decoding Composite Filters (#6402)
MarkDuckworth Aug 5, 2022
8b6f05f
Perform DNF transform
MarkDuckworth Aug 10, 2022
152fc18
Cleanup and tests from https://github.com/firebase/firebase-android-s…
MarkDuckworth Aug 10, 2022
8b0bfbd
Merge branch 'markduckworth/or-queries' of github.com:firebase/fireba…
MarkDuckworth Aug 12, 2022
45be193
Merge branch 'master' of github.com:firebase/firebase-js-sdk into mar…
MarkDuckworth Aug 12, 2022
1c948cb
use index if we have composite filters
MarkDuckworth Aug 12, 2022
2cad46c
Merge branch 'markduckworth/or-queries' into markduckworth/or-queries…
MarkDuckworth Aug 12, 2022
266f7f6
Fix bad import
MarkDuckworth Aug 12, 2022
c2d7cd2
Update the orderBy filtering mechanism for OR queries and steps to se…
MarkDuckworth Aug 15, 2022
41d0e29
Adding tests
MarkDuckworth Aug 15, 2022
90f7c50
Test for DNF computation.
MarkDuckworth Aug 16, 2022
ff52ecc
Fix implementation of isFlatConjunction
MarkDuckworth Aug 16, 2022
dfda9f8
Adding integration tests for validation of composite queries.
MarkDuckworth Aug 17, 2022
9bc3336
IndexDb manager tests for partial and full index.
MarkDuckworth Aug 17, 2022
d66abd4
Test query does not include documents with missing fields
MarkDuckworth Aug 17, 2022
e33263d
Run prettier
MarkDuckworth Aug 17, 2022
01c3487
Add missing awaits
MarkDuckworth Aug 17, 2022
7d56b57
Fixing argument validation for and . Updating tests for asserted err…
MarkDuckworth Aug 17, 2022
d01ff74
Prettier
MarkDuckworth Aug 18, 2022
186fd92
Removing duplicate test cases.
MarkDuckworth Aug 18, 2022
409b19c
Update proto with OR operator.
MarkDuckworth Aug 22, 2022
131f4be
Update protos with OR operator.
MarkDuckworth Aug 23, 2022
a514358
Testing query with indexes
MarkDuckworth Aug 23, 2022
0ab215b
Add compile.sh to compile proto updates.
MarkDuckworth Aug 23, 2022
638b0ad
Adding new script to run browser tests against the emulator.
MarkDuckworth Aug 23, 2022
86c9057
Update stringifyFilter to support CompositeFilters
MarkDuckworth Aug 23, 2022
3501135
Lint and formatting
MarkDuckworth Aug 23, 2022
4adf98d
Refactor core/target.ts, extracting classes Bound, OrderBy, and Filte…
MarkDuckworth Aug 24, 2022
60f4276
Formatting
MarkDuckworth Aug 24, 2022
476be61
Making public API changes to ensure that only QueryFilterConstraints …
MarkDuckworth Aug 24, 2022
a0e5d30
Remove QueryNonFilterConstraint from exports.
MarkDuckworth Aug 25, 2022
77afd20
Add overloads for query and deprecate existing query overload that su…
MarkDuckworth Aug 26, 2022
bf21b93
Merge branch 'master' into markduckworth/or-queries
MarkDuckworth Sep 22, 2022
c15333a
Markduckworth/or queries pr 4 (#6527)
MarkDuckworth Oct 26, 2022
2a20810
Refactor core/target.ts, extracting classes Bound, OrderBy, and Filte…
MarkDuckworth Oct 26, 2022
7c54b30
Making public API changes to ensure that only QueryFilterConstraints …
MarkDuckworth Oct 26, 2022
3862740
Merge branch 'markduckworth/or-queries' of github.com:firebase/fireba…
MarkDuckworth Oct 26, 2022
efd98c7
Implementing public API for OR queries that does not need the depreca…
MarkDuckworth Oct 27, 2022
94250da
Implementing 3rd iteration of the public API for OR queries.
MarkDuckworth Oct 28, 2022
ff0eede
Compute IN expansion.
MarkDuckworth Oct 28, 2022
66bf749
Fix edge case a == 1 && a == 6
MarkDuckworth Nov 3, 2022
968d133
Logic utils tests for in expansion.
MarkDuckworth Nov 3, 2022
934fbef
Relaxing in restrictions.
MarkDuckworth Nov 4, 2022
5f37954
Fixed rogue comment.
MarkDuckworth Nov 8, 2022
ab5cad2
Comment cleanup.
MarkDuckworth Nov 8, 2022
5fa9c76
Comment cleanup.
MarkDuckworth Nov 8, 2022
9c6395b
Test refactoring.
MarkDuckworth Nov 8, 2022
e711f06
Merge branch 'markduckworth/or-queries-pr-9' into markduckworth/or-qu…
MarkDuckworth Nov 8, 2022
838f825
Adding missing tests.
MarkDuckworth Nov 9, 2022
433b283
Adding and fixing tests.
MarkDuckworth Nov 9, 2022
9f5721e
Removing .only
MarkDuckworth Nov 11, 2022
1280052
Merge branch 'master' into markduckworth/or-queries-relaxing-in-restr…
MarkDuckworth Feb 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions packages/firestore/test/integration/api/query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ apiDescribe('Queries', (persistence: boolean) => {

// TODO(orquery): Enable this test when prod supports OR queries.
// eslint-disable-next-line no-restricted-properties
it.skip('supports multiple in ops', () => {
it('supports multiple in ops', () => {
const testDocs = {
doc1: { a: 1, b: 0 },
doc2: { b: 1 },
Expand Down Expand Up @@ -1663,9 +1663,7 @@ apiDescribe('Queries', (persistence: boolean) => {
'doc4',
'doc6'
);
});

return withTestCollection(persistence, testDocs, async coll => {
await checkOnlineAndOfflineResultsMatch(
query(
coll,
Expand All @@ -1676,31 +1674,26 @@ apiDescribe('Queries', (persistence: boolean) => {
),
'doc3'
);
});

return withTestCollection(persistence, testDocs, async coll => {
await checkOnlineAndOfflineResultsMatch(
query(
coll,
or(
where('a', 'in', [2, 3]),
where('c', '==', 10),
and(where('a', 'in', [2, 3]), where('c', '==', 10)),
where('b', 'array-contains-any', [0, 7])
)
),
'doc1',
'doc3',
'doc4'
);
});

return withTestCollection(persistence, testDocs, async coll => {
await checkOnlineAndOfflineResultsMatch(
query(
coll,
and(
where('a', 'in', [2, 3]),
or(where('b', 'array-contains-any', [0, 7]), where('c', '==', 10))
or(where('b', 'array-contains-any', [0, 7]), where('c', '==', 20))
)
),
'doc3',
Expand Down Expand Up @@ -1731,34 +1724,28 @@ apiDescribe('Queries', (persistence: boolean) => {
'doc4',
'doc6'
);
});

return withTestCollection(persistence, testDocs, async coll => {
await checkOnlineAndOfflineResultsMatch(
query(
coll,
and(where('a', 'in', [2, 3]), where('b', 'array-contains', 7))
),
'doc3'
);
});

return withTestCollection(persistence, testDocs, async coll => {
await checkOnlineAndOfflineResultsMatch(
query(
coll,
or(
where('a', 'in', [2, 3]),
and(where('b', 'array-contains', 3), where('b', '==', 1))
and(where('b', 'array-contains', 3), where('a', '==', 1))
)
),
'doc3',
'doc4',
'doc6'
);
});

return withTestCollection(persistence, testDocs, async coll => {
await checkOnlineAndOfflineResultsMatch(
query(
coll,
Expand Down Expand Up @@ -1791,6 +1778,12 @@ apiDescribe('Queries', (persistence: boolean) => {
'doc4',
'doc5'
);

await checkOnlineAndOfflineResultsMatch(
query(coll, where('a', 'in', [2, 3]), orderBy('a')),
'doc6',
'doc3'
);
});
});
});
Expand Down
201 changes: 109 additions & 92 deletions packages/firestore/test/integration/api/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,106 +961,123 @@ apiDescribe('Validation:', (persistence: boolean) => {
);
});

validationIt(persistence, 'with multiple disjunctive filters fail', db => {
expect(() =>
query(
collection(db, 'test'),
where('foo', 'not-in', [1, 2]),
where('foo', 'not-in', [2, 3])
)
).to.throw(
"Invalid query. You cannot use more than one 'not-in' filter."
);
validationIt.only(
Copy link
Contributor

@ehsannas ehsannas Nov 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove .only

persistence,
'with multiple disjunctive filters fail',
db => {
expect(() =>
query(
collection(db, 'test'),
where('foo', 'not-in', [1, 2]),
where('foo', 'not-in', [2, 3])
)
).to.throw(
"Invalid query. You cannot use more than one 'not-in' filter."
);

expect(() =>
query(
collection(db, 'test'),
where('foo', 'array-contains-any', [1, 2]),
where('foo', 'array-contains-any', [2, 3])
)
).to.throw(
"Invalid query. You cannot use more than one 'array-contains-any'" +
' filter.'
);
expect(() =>
query(
collection(db, 'test'),
where('foo', 'array-contains-any', [1, 2]),
where('foo', 'array-contains-any', [2, 3])
)
).to.throw(
"Invalid query. You cannot use more than one 'array-contains-any'" +
' filter.'
);

expect(() =>
query(
collection(db, 'test'),
where('foo', 'not-in', [2, 3]),
where('foo', 'array-contains-any', [2, 3])
)
).to.throw(
"Invalid query. You cannot use 'array-contains-any' filters with " +
"'not-in' filters."
);
expect(() =>
query(
collection(db, 'test'),
where('foo', 'not-in', [2, 3]),
where('foo', 'array-contains-any', [2, 3])
)
).to.throw(
"Invalid query. You cannot use 'array-contains-any' filters with " +
"'not-in' filters."
);

expect(() =>
query(
collection(db, 'test'),
where('foo', 'array-contains-any', [2, 3]),
where('foo', 'not-in', [2, 3])
)
).to.throw(
"Invalid query. You cannot use 'not-in' filters with " +
"'array-contains-any' filters."
);
expect(() =>
query(
collection(db, 'test'),
where('foo', 'array-contains-any', [2, 3]),
where('foo', 'not-in', [2, 3])
)
).to.throw(
"Invalid query. You cannot use 'not-in' filters with " +
"'array-contains-any' filters."
);

expect(() =>
query(
collection(db, 'test'),
where('foo', 'not-in', [2, 3]),
where('foo', 'in', [2, 3])
)
).to.throw(
"Invalid query. You cannot use 'in' filters with 'not-in' filters."
);
expect(() =>
query(
collection(db, 'test'),
where('foo', 'not-in', [2, 3]),
where('foo', 'in', [2, 3])
)
).to.throw(
"Invalid query. You cannot use 'in' filters with 'not-in' filters."
);

expect(() =>
query(
collection(db, 'test'),
where('foo', 'in', [2, 3]),
where('foo', 'not-in', [2, 3])
)
).to.throw(
"Invalid query. You cannot use 'not-in' filters with 'in' filters."
);
expect(() =>
query(
collection(db, 'test'),
where('foo', 'in', [2, 3]),
where('foo', 'not-in', [2, 3])
)
).to.throw(
"Invalid query. You cannot use 'not-in' filters with 'in' filters."
);

expect(() =>
query(
collection(db, 'test'),
where('foo', 'array-contains', 1),
where('foo', 'in', [2, 3]),
where('foo', 'array-contains-any', [2])
)
).to.throw(
"Invalid query. You cannot use 'array-contains-any' filters with " +
"'array-contains' filters."
);
// This is redundant with the above tests, but makes sure our validation
// doesn't get confused.
expect(() =>
query(
collection(db, 'test'),
where('foo', 'in', [2, 3]),
where('foo', 'array-contains', 1),
where('foo', 'array-contains-any', [2])
)
).to.throw(
"Invalid query. You cannot use 'array-contains-any' filters with 'array-contains' filters."
);

expect(() =>
query(
collection(db, 'test'),
where('foo', 'not-in', [2, 3]),
where('foo', 'array-contains', 2),
where('foo', 'array-contains-any', [2])
)
).to.throw(
"Invalid query. You cannot use 'array-contains' filters with " +
"'not-in' filters."
);
expect(() =>
query(
collection(db, 'test'),
where('foo', 'array-contains', 1),
where('foo', 'in', [2, 3]),
where('foo', 'array-contains-any', [2])
)
).to.throw(
"Invalid query. You cannot use 'array-contains-any' filters with " +
"'array-contains' filters."
);

expect(() =>
query(
collection(db, 'test'),
where('foo', 'array-contains', 2),
where('foo', 'in', [2]),
where('foo', 'not-in', [2, 3])
)
).to.throw(
"Invalid query. You cannot use 'not-in' filters with " +
"'array-contains' filters."
);
});
expect(() =>
query(
collection(db, 'test'),
where('foo', 'not-in', [2, 3]),
where('foo', 'array-contains', 2),
where('foo', 'array-contains-any', [2])
)
).to.throw(
"Invalid query. You cannot use 'array-contains' filters with " +
"'not-in' filters."
);

expect(() =>
query(
collection(db, 'test'),
where('foo', 'array-contains', 2),
where('foo', 'in', [2]),
where('foo', 'not-in', [2, 3])
)
).to.throw(
"Invalid query. You cannot use 'not-in' filters with " +
"'array-contains' filters."
);
}
);

validationIt(
persistence,
Expand Down