@@ -416,19 +416,17 @@ - (void)testQueryWithNonPositiveLimitFails {
416
416
}
417
417
418
418
- (void )testNonEqualityQueriesOnNullOrNaNFail {
419
- FSTAssertThrows ([[ self collectionRef ] queryWhereField: @" a " isGreaterThan: nil ],
420
- @" Invalid Query. Null supports only equality comparisons. " );
419
+ NSString *expected = @" Invalid Query. Null supports only 'equalTo' and 'notEqualTo' comparisons. " ;
420
+ FSTAssertThrows ([[ self collectionRef ] queryWhereField: @" a " isGreaterThan: nil ], expected );
421
421
FSTAssertThrows ([[self collectionRef ] queryWhereField: @" a" isGreaterThan: [NSNull null ]],
422
- @" Invalid Query. Null supports only equality comparisons." );
423
- FSTAssertThrows ([[self collectionRef ] queryWhereField: @" a" arrayContains: nil ],
424
- @" Invalid Query. Null supports only equality comparisons." );
422
+ expected);
423
+ FSTAssertThrows ([[self collectionRef ] queryWhereField: @" a" arrayContains: nil ], expected);
425
424
FSTAssertThrows ([[self collectionRef ] queryWhereField: @" a" arrayContains: [NSNull null ]],
426
- @" Invalid Query. Null supports only equality comparisons. " );
425
+ expected );
427
426
428
- FSTAssertThrows ([[self collectionRef ] queryWhereField: @" a" isGreaterThan: @(NAN)],
429
- @" Invalid Query. NaN supports only equality comparisons." );
430
- FSTAssertThrows ([[self collectionRef ] queryWhereField: @" a" arrayContains: @(NAN)],
431
- @" Invalid Query. NaN supports only equality comparisons." );
427
+ expected = @" Invalid Query. NaN supports only 'equalTo' and 'notEqualTo' comparisons." ;
428
+ FSTAssertThrows ([[self collectionRef ] queryWhereField: @" a" isGreaterThan: @(NAN)], expected);
429
+ FSTAssertThrows ([[self collectionRef ] queryWhereField: @" a" arrayContains: @(NAN)], expected);
432
430
}
433
431
434
432
- (void )testQueryCannotBeCreatedFromDocumentsMissingSortValues {
@@ -596,13 +594,13 @@ - (void)testQueryInequalityFieldMustMatchFirstOrderByField {
596
594
FIRQuery *base = [coll queryWhereField: @" x" isGreaterThanOrEqualTo: @32 ];
597
595
598
596
FSTAssertThrows ([base queryWhereField: @" y" isLessThan: @" cat" ],
599
- @" Invalid Query. All where filters with an inequality (lessThan, "
597
+ @" Invalid Query. All where filters with an inequality (notEqual, lessThan, "
600
598
" lessThanOrEqual, greaterThan, or greaterThanOrEqual) must be on the same "
601
599
" field. But you have inequality filters on 'x' and 'y'" );
602
600
603
601
NSString *reason =
604
602
@" Invalid query. You have a where filter with "
605
- " an inequality (lessThan, lessThanOrEqual, greaterThan, or greaterThanOrEqual) "
603
+ " an inequality (notEqual, lessThan, lessThanOrEqual, greaterThan, or greaterThanOrEqual) "
606
604
" on field 'x' and so you must also use 'x' as your first queryOrderedBy field, "
607
605
" but your first queryOrderedBy is currently on field 'y' instead." ;
608
606
FSTAssertThrows ([base queryOrderedByField: @" y" ], reason);
@@ -611,6 +609,7 @@ - (void)testQueryInequalityFieldMustMatchFirstOrderByField {
611
609
FSTAssertThrows ([[[coll queryOrderedByField: @" y" ] queryOrderedByField: @" x" ] queryWhereField: @" x"
612
610
isGreaterThan: @32 ],
613
611
reason);
612
+ FSTAssertThrows ([[coll queryOrderedByField: @" y" ] queryWhereField: @" x" isNotEqualTo: @32 ], reason);
614
613
615
614
XCTAssertNoThrow ([base queryWhereField: @" x" isLessThanOrEqualTo: @" cat" ],
616
615
@" Same inequality fields work" );
@@ -638,6 +637,20 @@ - (void)testQueryInequalityFieldMustMatchFirstOrderByField {
638
637
@" array_contains different than orderBy works." );
639
638
}
640
639
640
+ - (void )testQueriesWithMultipleNotEqualAndInequalitiesFail {
641
+ FIRCollectionReference *coll = [self .db collectionWithPath: @" collection" ];
642
+
643
+ FSTAssertThrows ([[coll queryWhereField: @" x" isNotEqualTo: @1 ] queryWhereField: @" x"
644
+ isNotEqualTo: @2 ],
645
+ @" Invalid Query. You cannot use more than one 'notEqual' filter." );
646
+
647
+ FSTAssertThrows ([[coll queryWhereField: @" x" isNotEqualTo: @1 ] queryWhereField: @" y"
648
+ isNotEqualTo: @2 ],
649
+ @" Invalid Query. All where filters with an inequality (notEqual, lessThan, "
650
+ " lessThanOrEqual, greaterThan, or greaterThanOrEqual) must be on "
651
+ " the same field. But you have inequality filters on 'x' and 'y'" );
652
+ }
653
+
641
654
- (void )testQueriesWithMultipleArrayFiltersFail {
642
655
FIRCollectionReference *coll = [self .db collectionWithPath: @" collection" ];
643
656
FSTAssertThrows ([[coll queryWhereField: @" foo" arrayContains: @1 ] queryWhereField: @" foo"
@@ -655,6 +668,18 @@ - (void)testQueriesWithMultipleArrayFiltersFail {
655
668
@" Invalid Query. You cannot use 'arrayContains' filters with 'arrayContainsAny' filters." );
656
669
}
657
670
671
+ - (void )testQueriesWithNotEqualAndNotInFiltersFail {
672
+ FIRCollectionReference *coll = [self .db collectionWithPath: @" collection" ];
673
+
674
+ FSTAssertThrows ([[coll queryWhereField: @" foo" notIn: @[ @1 ]] queryWhereField: @" foo"
675
+ isNotEqualTo: @2 ],
676
+ @" Invalid Query. You cannot use 'notEqual' filters with 'notIn' filters." );
677
+
678
+ FSTAssertThrows ([[coll queryWhereField: @" foo" isNotEqualTo: @2 ] queryWhereField: @" foo"
679
+ notIn: @[ @1 ]],
680
+ @" Invalid Query. You cannot use 'notIn' filters with 'notEqual' filters." );
681
+ }
682
+
658
683
- (void )testQueriesWithMultipleDisjunctiveFiltersFail {
659
684
FIRCollectionReference *coll = [self .db collectionWithPath: @" collection" ];
660
685
FSTAssertThrows ([[coll queryWhereField: @" foo" in: @[ @1 ]] queryWhereField: @" foo" in: @[ @2 ]],
@@ -664,6 +689,10 @@ - (void)testQueriesWithMultipleDisjunctiveFiltersFail {
664
689
arrayContainsAny: @[ @2 ]],
665
690
@" Invalid Query. You cannot use more than one 'arrayContainsAny' filter." );
666
691
692
+ FSTAssertThrows ([[coll queryWhereField: @" foo" notIn: @[ @1 ]] queryWhereField: @" foo"
693
+ notIn: @[ @2 ]],
694
+ @" Invalid Query. You cannot use more than one 'notIn' filter." );
695
+
667
696
FSTAssertThrows ([[coll queryWhereField: @" foo" arrayContainsAny: @[ @1 ]] queryWhereField: @" foo"
668
697
in: @[ @2 ]],
669
698
@" Invalid Query. You cannot use 'in' filters with 'arrayContainsAny' filters." );
@@ -672,18 +701,44 @@ - (void)testQueriesWithMultipleDisjunctiveFiltersFail {
672
701
arrayContainsAny: @[ @2 ]],
673
702
@" Invalid Query. You cannot use 'arrayContainsAny' filters with 'in' filters." );
674
703
704
+ FSTAssertThrows (
705
+ [[coll queryWhereField: @" foo" arrayContainsAny: @[ @1 ]] queryWhereField: @" foo" notIn: @[ @2 ]],
706
+ @" Invalid Query. You cannot use 'notIn' filters with 'arrayContainsAny' filters." );
707
+
708
+ FSTAssertThrows (
709
+ [[coll queryWhereField: @" foo" notIn: @[ @1 ]] queryWhereField: @" foo" arrayContainsAny: @[ @2 ]],
710
+ @" Invalid Query. You cannot use 'arrayContainsAny' filters with 'notIn' filters." );
711
+
712
+ FSTAssertThrows ([[coll queryWhereField: @" foo" in: @[ @1 ]] queryWhereField: @" foo" notIn: @[ @2 ]],
713
+ @" Invalid Query. You cannot use 'notIn' filters with 'in' filters." );
714
+
715
+ FSTAssertThrows ([[coll queryWhereField: @" foo" notIn: @[ @1 ]] queryWhereField: @" foo" in: @[ @2 ]],
716
+ @" Invalid Query. You cannot use 'in' filters with 'notIn' filters." );
717
+
675
718
// This is redundant with the above tests, but makes sure our validation doesn't get confused.
676
719
FSTAssertThrows ([[[coll queryWhereField: @" foo"
677
720
in: @[ @1 ]] queryWhereField: @" foo"
678
721
arrayContains: @2 ] queryWhereField: @" foo"
679
722
arrayContainsAny: @[ @2 ]],
680
723
@" Invalid Query. You cannot use 'arrayContainsAny' filters with 'in' filters." );
681
724
725
+ FSTAssertThrows (
726
+ [[[coll queryWhereField: @" foo"
727
+ arrayContains: @1 ] queryWhereField: @" foo" in: @[ @2 ]] queryWhereField: @" foo"
728
+ arrayContainsAny: @[ @2 ]],
729
+ @" Invalid Query. You cannot use 'arrayContainsAny' filters with 'arrayContains' filters." );
730
+
731
+ FSTAssertThrows ([[[coll queryWhereField: @" foo"
732
+ notIn: @[ @1 ]] queryWhereField: @" foo"
733
+ arrayContains: @2 ] queryWhereField: @" foo"
734
+ arrayContainsAny: @[ @2 ]],
735
+ @" Invalid Query. You cannot use 'arrayContains' filters with 'notIn' filters." );
736
+
682
737
FSTAssertThrows ([[[coll queryWhereField: @" foo"
683
738
arrayContains: @1 ] queryWhereField: @" foo"
684
739
in: @[ @2 ]] queryWhereField: @" foo"
685
- arrayContainsAny : @[ @2 ]],
686
- @" Invalid Query. You cannot use 'arrayContainsAny ' filters with 'in ' filters." );
740
+ notIn : @[ @2 ]],
741
+ @" Invalid Query. You cannot use 'notIn ' filters with 'arrayContains ' filters." );
687
742
}
688
743
689
744
- (void )testQueriesCanUseInWithArrayContain {
@@ -715,6 +770,9 @@ - (void)testQueriesInAndArrayContainsAnyArrayRules {
715
770
FSTAssertThrows ([coll queryWhereField: @" foo" in: @[]],
716
771
@" Invalid Query. A non-empty array is required for 'in' filters." );
717
772
773
+ FSTAssertThrows ([coll queryWhereField: @" foo" notIn: @[]],
774
+ @" Invalid Query. A non-empty array is required for 'notIn' filters." );
775
+
718
776
FSTAssertThrows ([coll queryWhereField: @" foo" arrayContainsAny: @[]],
719
777
@" Invalid Query. A non-empty array is required for 'arrayContainsAny' filters." );
720
778
@@ -726,6 +784,9 @@ - (void)testQueriesInAndArrayContainsAnyArrayRules {
726
784
FSTAssertThrows ([coll queryWhereField: @" foo" arrayContainsAny: values],
727
785
@" Invalid Query. 'arrayContainsAny' filters support a maximum of 10 elements"
728
786
" in the value array." );
787
+ FSTAssertThrows (
788
+ [coll queryWhereField: @" foo" notIn: values],
789
+ @" Invalid Query. 'notIn' filters support a maximum of 10 elements in the value array." );
729
790
730
791
NSArray *withNullValues = @[ @1 , [NSNull null ] ];
731
792
FSTAssertThrows ([coll queryWhereField: @" foo" in: withNullValues],
0 commit comments