Skip to content

Commit 0b2d9ad

Browse files
Merge
2 parents bd24bfe + 9ac7870 commit 0b2d9ad

File tree

36 files changed

+779
-645
lines changed

36 files changed

+779
-645
lines changed

firebase-abt/firebase-abt.gradle

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,50 @@
1414

1515
plugins {
1616
id 'firebase-library'
17+
id 'com.google.protobuf'
1718
}
1819

1920
firebaseLibrary {
2021
testLab.enabled = false
2122
publishSources = true
2223
}
2324

25+
// TODO(issue/568): Remove this once legacy logic is removed from Remote Config.
26+
protobuf {
27+
protoc {
28+
artifact = 'com.google.protobuf:protoc:3.4.0'
29+
}
30+
plugins {
31+
javalite {
32+
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
33+
}
34+
}
35+
generateProtoTasks {
36+
all().each { task ->
37+
task.builtins {
38+
remove java
39+
}
40+
task.plugins {
41+
javalite {}
42+
}
43+
}
44+
}
45+
}
46+
2447
android {
2548

2649
lintOptions {
2750
abortOnError false
2851
}
2952
sourceSets {
3053
main {
31-
java {
32-
}
33-
}
34-
test {
35-
java {
54+
proto {
55+
srcDir 'src/proto'
3656
}
57+
58+
resources {
59+
srcDir 'src/proto/com/google/protos'
60+
}
3761
}
3862
}
3963

@@ -61,6 +85,7 @@ dependencies {
6185
implementation ('com.google.firebase:firebase-measurement-connector:18.0.0') {
6286
exclude group: "com.google.firebase", module: "firebase-common"
6387
}
88+
implementation 'com.google.protobuf:protobuf-lite:3.0.1'
6489
testImplementation 'org.mockito:mockito-core:2.25.0'
6590
testImplementation 'com.google.truth:truth:0.44'
6691
testImplementation 'junit:junit:4.13-beta-2'

firebase-config/firebase-config.gradle

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ protobuf {
5050
}
5151
}
5252

53-
firebaseLibrary {
54-
testLab.enabled = true
55-
publishSources = true
56-
}
57-
5853
android {
5954
compileSdkVersion project.targetSdkVersion
6055
defaultConfig {

firebase-config/src/proto/com/google/protos/developers/mobile/abt/proto/experiment_payload.proto

Lines changed: 0 additions & 109 deletions
This file was deleted.

firebase-firestore/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Unreleased
2-
- [changed] Improved performance of queries with large result sets by up to
3-
60%.
2+
- [changed] Improved performance of queries with large result sets.
3+
- [changed] Improved performance for queries with filters that only return a
4+
small subset of the documents in a collection.
45
- [changed] Instead of failing silently, Firestore now crashes the client app
56
if it fails to load SSL Ciphers. To avoid these crashes, you must bundle
67
Conscrypt to support non-GMSCore devices on Android KitKat or JellyBean (see

firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/testutil/TestUtil.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import com.google.firebase.firestore.DocumentReference;
3434
import com.google.firebase.firestore.TestAccessHelper;
3535
import com.google.firebase.firestore.UserDataConverter;
36-
import com.google.firebase.firestore.core.Filter;
36+
import com.google.firebase.firestore.core.FieldFilter;
3737
import com.google.firebase.firestore.core.Filter.Operator;
3838
import com.google.firebase.firestore.core.OrderBy;
3939
import com.google.firebase.firestore.core.OrderBy.Direction;
@@ -175,21 +175,21 @@ public static SnapshotVersion version(long versionMicros) {
175175

176176
public static Document doc(String key, long version, Map<String, Object> data) {
177177
return new Document(
178-
key(key), version(version), wrapObject(data), Document.DocumentState.SYNCED);
178+
key(key), version(version), Document.DocumentState.SYNCED, wrapObject(data));
179179
}
180180

181181
public static Document doc(DocumentKey key, long version, Map<String, Object> data) {
182-
return new Document(key, version(version), wrapObject(data), Document.DocumentState.SYNCED);
182+
return new Document(key, version(version), Document.DocumentState.SYNCED, wrapObject(data));
183183
}
184184

185185
public static Document doc(
186186
String key, long version, ObjectValue data, Document.DocumentState documentState) {
187-
return new Document(key(key), version(version), data, documentState);
187+
return new Document(key(key), version(version), documentState, data);
188188
}
189189

190190
public static Document doc(
191191
String key, long version, Map<String, Object> data, Document.DocumentState documentState) {
192-
return new Document(key(key), version(version), wrapObject(data), documentState);
192+
return new Document(key(key), version(version), documentState, wrapObject(data));
193193
}
194194

195195
public static NoDocument deletedDoc(String key, long version) {
@@ -220,8 +220,8 @@ public static ImmutableSortedSet<DocumentKey> keySet(DocumentKey... keys) {
220220
return keySet;
221221
}
222222

223-
public static Filter filter(String key, String operator, Object value) {
224-
return Filter.create(field(key), operatorFromString(operator), wrap(value));
223+
public static FieldFilter filter(String key, String operator, Object value) {
224+
return FieldFilter.create(field(key), operatorFromString(operator), wrap(value));
225225
}
226226

227227
public static Operator operatorFromString(String s) {

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

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.firebase.firestore;
1616

17+
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.isRunningAgainstEmulator;
1718
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.querySnapshotToIds;
1819
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.querySnapshotToValues;
1920
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollection;
@@ -38,7 +39,7 @@
3839
import java.util.Map;
3940
import java.util.concurrent.Semaphore;
4041
import org.junit.After;
41-
import org.junit.Ignore;
42+
import org.junit.Assume;
4243
import org.junit.Test;
4344
import org.junit.runner.RunWith;
4445

@@ -428,33 +429,56 @@ public void testQueriesCanUseArrayContainsFilters() {
428429
// much of anything else interesting to test.
429430
}
430431

431-
// TODO(in-queries): Re-enable once emulator support is added to travis.
432432
@Test
433-
@Ignore
434433
public void testQueriesCanUseInFilters() {
435-
Map<String, Object> docA = map("zip", 98101);
436-
Map<String, Object> docB = map("zip", 91102);
437-
Map<String, Object> docC = map("zip", 98103);
438-
Map<String, Object> docD = map("zip", asList(98101));
439-
Map<String, Object> docE = map("zip", asList("98101", map("zip", 98101)));
440-
Map<String, Object> docF = map("zip", map("code", 500));
434+
// TODO(in-queries): Re-enable in prod once feature lands in backend.
435+
Assume.assumeTrue(isRunningAgainstEmulator());
436+
437+
Map<String, Object> docA = map("zip", 98101L);
438+
Map<String, Object> docB = map("zip", 91102L);
439+
Map<String, Object> docC = map("zip", 98103L);
440+
Map<String, Object> docD = map("zip", asList(98101L));
441+
Map<String, Object> docE = map("zip", asList("98101", map("zip", 98101L)));
442+
Map<String, Object> docF = map("zip", map("code", 500L));
441443
CollectionReference collection =
442444
testCollectionWithDocs(
443445
map("a", docA, "b", docB, "c", docC, "d", docD, "e", docE, "f", docF));
444446

445447
// Search for zips matching [98101, 98103].
446-
QuerySnapshot snapshot = waitFor(collection.whereIn("zip", asList(98101, 98103)).get());
448+
QuerySnapshot snapshot = waitFor(collection.whereIn("zip", asList(98101L, 98103L)).get());
447449
assertEquals(asList(docA, docC), querySnapshotToValues(snapshot));
448450

449451
// With objects.
450-
snapshot = waitFor(collection.whereIn("zip", asList(map("code", 500))).get());
452+
snapshot = waitFor(collection.whereIn("zip", asList(map("code", 500L))).get());
451453
assertEquals(asList(docF), querySnapshotToValues(snapshot));
452454
}
453455

454-
// TODO(in-queries): Re-enable once emulator support is added to travis.
455456
@Test
456-
@Ignore
457+
public void testQueriesCanUseInFiltersWithDocIds() {
458+
// TODO(in-queries): Re-enable in prod once feature lands in backend.
459+
Assume.assumeTrue(isRunningAgainstEmulator());
460+
461+
Map<String, String> docA = map("key", "aa");
462+
Map<String, String> docB = map("key", "ab");
463+
Map<String, String> docC = map("key", "ba");
464+
Map<String, String> docD = map("key", "bb");
465+
Map<String, Map<String, Object>> testDocs =
466+
map(
467+
"aa", docA,
468+
"ab", docB,
469+
"ba", docC,
470+
"bb", docD);
471+
CollectionReference collection = testCollectionWithDocs(testDocs);
472+
QuerySnapshot docs =
473+
waitFor(collection.whereIn(FieldPath.documentId(), asList("aa", "ab")).get());
474+
assertEquals(asList(docA, docB), querySnapshotToValues(docs));
475+
}
476+
477+
@Test
457478
public void testQueriesCanUseArrayContainsAnyFilters() {
479+
// TODO(in-queries): Re-enable in prod once feature lands in backend.
480+
Assume.assumeTrue(isRunningAgainstEmulator());
481+
458482
Map<String, Object> docA = map("array", asList(42L));
459483
Map<String, Object> docB = map("array", asList("a", 42L, "c"));
460484
Map<String, Object> docC = map("array", asList(41.999, "42", map("a", asList(42))));

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

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,11 +701,6 @@ public void queriesFilteredByDocumentIDMustUseStringsOrDocumentReferences() {
701701
+ "a valid String or DocumentReference, but it was of type: java.lang.Integer";
702702
expectError(() -> collection.whereGreaterThanOrEqualTo(FieldPath.documentId(), 1), reason);
703703

704-
reason =
705-
"Invalid query. When querying with FieldPath.documentId() you must provide "
706-
+ "a valid String or DocumentReference, but it was of type: java.util.Arrays$ArrayList";
707-
expectError(() -> collection.whereIn(FieldPath.documentId(), asList(1, 2)), reason);
708-
709704
reason =
710705
"Invalid query. When querying a collection group by FieldPath.documentId(), the value "
711706
+ "provided must result in a valid document path, but 'foo' is not because it has "
@@ -726,6 +721,38 @@ public void queriesFilteredByDocumentIDMustUseStringsOrDocumentReferences() {
726721
() -> collection.whereArrayContainsAny(FieldPath.documentId(), asList(1, 2)), reason);
727722
}
728723

724+
@Test
725+
public void queriesUsingInAndDocumentIdMustHaveProperDocumentReferencesInArray() {
726+
CollectionReference collection = testCollection();
727+
collection.whereIn(FieldPath.documentId(), asList(collection.getPath()));
728+
729+
String reason =
730+
"Invalid query. When querying with FieldPath.documentId() you must provide "
731+
+ "a valid document ID, but it was an empty string.";
732+
expectError(() -> collection.whereIn(FieldPath.documentId(), asList("")), reason);
733+
734+
reason =
735+
"Invalid query. When querying a collection by FieldPath.documentId() you must provide "
736+
+ "a plain document ID, but 'foo/bar/baz' contains a '/' character.";
737+
expectError(() -> collection.whereIn(FieldPath.documentId(), asList("foo/bar/baz")), reason);
738+
739+
reason =
740+
"Invalid query. When querying with FieldPath.documentId() you must provide "
741+
+ "a valid String or DocumentReference, but it was of type: java.lang.Integer";
742+
expectError(() -> collection.whereIn(FieldPath.documentId(), asList(1, 2)), reason);
743+
744+
reason =
745+
"Invalid query. When querying a collection group by FieldPath.documentId(), the value "
746+
+ "provided must result in a valid document path, but 'foo' is not because it has "
747+
+ "an odd number of segments (1).";
748+
expectError(
749+
() ->
750+
testFirestore()
751+
.collectionGroup("collection")
752+
.whereIn(FieldPath.documentId(), asList("foo")),
753+
reason);
754+
}
755+
729756
// Helpers
730757

731758
/** Performs a write using each write API and makes sure it fails with the expected reason. */

0 commit comments

Comments
 (0)