@@ -1735,21 +1735,34 @@ export class Query implements firestore.Query {
1735
1735
}
1736
1736
1737
1737
private validateNewFilter ( filter : Filter ) : void {
1738
- if ( filter instanceof RelationFilter && filter . isInequality ( ) ) {
1739
- const existingField = this . _query . getInequalityFilterField ( ) ;
1740
- if ( existingField !== null && ! existingField . isEqual ( filter . field ) ) {
1741
- throw new FirestoreError (
1742
- Code . INVALID_ARGUMENT ,
1743
- 'Invalid query. All where filters with an inequality' +
1744
- ' (<, <=, >, or >=) must be on the same field. But you have' +
1745
- ` inequality filters on '${ existingField . toString ( ) } '` +
1746
- ` and '${ filter . field . toString ( ) } '`
1747
- ) ;
1748
- }
1738
+ if ( filter instanceof RelationFilter ) {
1739
+ if ( filter . isInequality ( ) ) {
1740
+ const existingField = this . _query . getInequalityFilterField ( ) ;
1741
+ if ( existingField !== null && ! existingField . isEqual ( filter . field ) ) {
1742
+ throw new FirestoreError (
1743
+ Code . INVALID_ARGUMENT ,
1744
+ 'Invalid query. All where filters with an inequality' +
1745
+ ' (<, <=, >, or >=) must be on the same field. But you have' +
1746
+ ` inequality filters on '${ existingField . toString ( ) } '` +
1747
+ ` and '${ filter . field . toString ( ) } '`
1748
+ ) ;
1749
+ }
1749
1750
1750
- const firstOrderByField = this . _query . getFirstOrderByField ( ) ;
1751
- if ( firstOrderByField !== null ) {
1752
- this . validateOrderByAndInequalityMatch ( filter . field , firstOrderByField ) ;
1751
+ const firstOrderByField = this . _query . getFirstOrderByField ( ) ;
1752
+ if ( firstOrderByField !== null ) {
1753
+ this . validateOrderByAndInequalityMatch (
1754
+ filter . field ,
1755
+ firstOrderByField
1756
+ ) ;
1757
+ }
1758
+ } else if ( filter . op === RelationOp . ARRAY_CONTAINS ) {
1759
+ if ( this . _query . hasArrayContainsFilter ( ) ) {
1760
+ throw new FirestoreError (
1761
+ Code . INVALID_ARGUMENT ,
1762
+ 'Invalid query. Queries only support a single array-contains ' +
1763
+ 'filter.'
1764
+ ) ;
1765
+ }
1753
1766
}
1754
1767
}
1755
1768
}
0 commit comments