@@ -416,19 +416,17 @@ - (void)testQueryWithNonPositiveLimitFails {
416416}
417417
418418- (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 );
421421 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);
425424 FSTAssertThrows ([[self collectionRef ] queryWhereField: @" a" arrayContains: [NSNull null ]],
426- @" Invalid Query. Null supports only equality comparisons. " );
425+ expected );
427426
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);
432430}
433431
434432- (void )testQueryCannotBeCreatedFromDocumentsMissingSortValues {
@@ -596,13 +594,13 @@ - (void)testQueryInequalityFieldMustMatchFirstOrderByField {
596594 FIRQuery *base = [coll queryWhereField: @" x" isGreaterThanOrEqualTo: @32 ];
597595
598596 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, "
600598 " lessThanOrEqual, greaterThan, or greaterThanOrEqual) must be on the same "
601599 " field. But you have inequality filters on 'x' and 'y'" );
602600
603601 NSString *reason =
604602 @" 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) "
606604 " on field 'x' and so you must also use 'x' as your first queryOrderedBy field, "
607605 " but your first queryOrderedBy is currently on field 'y' instead." ;
608606 FSTAssertThrows ([base queryOrderedByField: @" y" ], reason);
@@ -611,6 +609,7 @@ - (void)testQueryInequalityFieldMustMatchFirstOrderByField {
611609 FSTAssertThrows ([[[coll queryOrderedByField: @" y" ] queryOrderedByField: @" x" ] queryWhereField: @" x"
612610 isGreaterThan: @32 ],
613611 reason);
612+ FSTAssertThrows ([[coll queryOrderedByField: @" y" ] queryWhereField: @" x" isNotEqualTo: @32 ], reason);
614613
615614 XCTAssertNoThrow ([base queryWhereField: @" x" isLessThanOrEqualTo: @" cat" ],
616615 @" Same inequality fields work" );
@@ -638,6 +637,20 @@ - (void)testQueryInequalityFieldMustMatchFirstOrderByField {
638637 @" array_contains different than orderBy works." );
639638}
640639
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+
641654- (void )testQueriesWithMultipleArrayFiltersFail {
642655 FIRCollectionReference *coll = [self .db collectionWithPath: @" collection" ];
643656 FSTAssertThrows ([[coll queryWhereField: @" foo" arrayContains: @1 ] queryWhereField: @" foo"
@@ -655,6 +668,18 @@ - (void)testQueriesWithMultipleArrayFiltersFail {
655668 @" Invalid Query. You cannot use 'arrayContains' filters with 'arrayContainsAny' filters." );
656669}
657670
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+
658683- (void )testQueriesWithMultipleDisjunctiveFiltersFail {
659684 FIRCollectionReference *coll = [self .db collectionWithPath: @" collection" ];
660685 FSTAssertThrows ([[coll queryWhereField: @" foo" in: @[ @1 ]] queryWhereField: @" foo" in: @[ @2 ]],
@@ -664,6 +689,10 @@ - (void)testQueriesWithMultipleDisjunctiveFiltersFail {
664689 arrayContainsAny: @[ @2 ]],
665690 @" Invalid Query. You cannot use more than one 'arrayContainsAny' filter." );
666691
692+ FSTAssertThrows ([[coll queryWhereField: @" foo" notIn: @[ @1 ]] queryWhereField: @" foo"
693+ notIn: @[ @2 ]],
694+ @" Invalid Query. You cannot use more than one 'notIn' filter." );
695+
667696 FSTAssertThrows ([[coll queryWhereField: @" foo" arrayContainsAny: @[ @1 ]] queryWhereField: @" foo"
668697 in: @[ @2 ]],
669698 @" Invalid Query. You cannot use 'in' filters with 'arrayContainsAny' filters." );
@@ -672,18 +701,44 @@ - (void)testQueriesWithMultipleDisjunctiveFiltersFail {
672701 arrayContainsAny: @[ @2 ]],
673702 @" Invalid Query. You cannot use 'arrayContainsAny' filters with 'in' filters." );
674703
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+
675718 // This is redundant with the above tests, but makes sure our validation doesn't get confused.
676719 FSTAssertThrows ([[[coll queryWhereField: @" foo"
677720 in: @[ @1 ]] queryWhereField: @" foo"
678721 arrayContains: @2 ] queryWhereField: @" foo"
679722 arrayContainsAny: @[ @2 ]],
680723 @" Invalid Query. You cannot use 'arrayContainsAny' filters with 'in' filters." );
681724
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+
682737 FSTAssertThrows ([[[coll queryWhereField: @" foo"
683738 arrayContains: @1 ] queryWhereField: @" foo"
684739 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." );
687742}
688743
689744- (void )testQueriesCanUseInWithArrayContain {
@@ -715,6 +770,9 @@ - (void)testQueriesInAndArrayContainsAnyArrayRules {
715770 FSTAssertThrows ([coll queryWhereField: @" foo" in: @[]],
716771 @" Invalid Query. A non-empty array is required for 'in' filters." );
717772
773+ FSTAssertThrows ([coll queryWhereField: @" foo" notIn: @[]],
774+ @" Invalid Query. A non-empty array is required for 'notIn' filters." );
775+
718776 FSTAssertThrows ([coll queryWhereField: @" foo" arrayContainsAny: @[]],
719777 @" Invalid Query. A non-empty array is required for 'arrayContainsAny' filters." );
720778
@@ -726,6 +784,9 @@ - (void)testQueriesInAndArrayContainsAnyArrayRules {
726784 FSTAssertThrows ([coll queryWhereField: @" foo" arrayContainsAny: values],
727785 @" Invalid Query. 'arrayContainsAny' filters support a maximum of 10 elements"
728786 " 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." );
729790
730791 NSArray *withNullValues = @[ @1 , [NSNull null ] ];
731792 FSTAssertThrows ([coll queryWhereField: @" foo" in: withNullValues],
0 commit comments