Skip to content

Commit 04a4016

Browse files
authored
Merge 36e971c into a135c51
2 parents a135c51 + 36e971c commit 04a4016

File tree

1 file changed

+42
-0
lines changed
  • firebase-firestore/src/androidTest/java/com/google/firebase/firestore

1 file changed

+42
-0
lines changed

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/QueryTest.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollectionWithDocs;
3939
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testFirestore;
4040
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
41+
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForException;
4142
import static com.google.firebase.firestore.testutil.TestUtil.expectError;
4243
import static com.google.firebase.firestore.testutil.TestUtil.map;
4344
import static java.util.Arrays.asList;
@@ -2193,4 +2194,45 @@ public void testMultipleInequalityFromCacheAndFromServer() {
21932194
Query query5 = collection.where(or(greaterThan("a", 2), lessThan("b", 1)));
21942195
checkOnlineAndOfflineResultsMatch(query5, "doc1", "doc3");
21952196
}
2197+
2198+
@Test
2199+
public void testMultipleInequalityRejectsIfDocumentKeyIsNotTheLastOrderByField() {
2200+
// TODO(MIEQ): Enable this test against production when possible.
2201+
assumeTrue(
2202+
"Skip this test if running against production because multiple inequality is "
2203+
+ "not supported yet.",
2204+
isRunningAgainstEmulator());
2205+
2206+
CollectionReference collection = testCollection();
2207+
2208+
// Implicitly ordered by: __name__ asc, 'key' asc,
2209+
Query query = collection.whereNotEqualTo("key", 42).orderBy(FieldPath.documentId());
2210+
Exception e = waitForException(query.get());
2211+
FirebaseFirestoreException firestoreException = (FirebaseFirestoreException) e;
2212+
assertTrue(
2213+
firestoreException
2214+
.getMessage()
2215+
.contains("order by clause cannot contain more fields after the key"));
2216+
}
2217+
2218+
@Test
2219+
public void testMultipleInequalityRejectsIfDocumentKeyAppearsOnlyInEqualityFilter() {
2220+
// TODO(MIEQ): Enable this test against production when possible.
2221+
assumeTrue(
2222+
"Skip this test if running against production because multiple inequality is "
2223+
+ "not supported yet.",
2224+
isRunningAgainstEmulator());
2225+
2226+
CollectionReference collection = testCollection();
2227+
2228+
Query query =
2229+
collection.whereNotEqualTo("key", 42).whereEqualTo(FieldPath.documentId(), "doc1");
2230+
Exception e = waitForException(query.get());
2231+
FirebaseFirestoreException firestoreException = (FirebaseFirestoreException) e;
2232+
assertTrue(
2233+
firestoreException
2234+
.getMessage()
2235+
.contains(
2236+
"Equality on key is not allowed if there are other inequality fields and key does not appear in inequalities."));
2237+
}
21962238
}

0 commit comments

Comments
 (0)