Skip to content

Commit 036849f

Browse files
committed
Merge branch 'master' into mila/BloomFilter
2 parents eaef9da + 1455bfa commit 036849f

28 files changed

+1002
-481
lines changed

.changeset/nervous-ads-pretend.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/database": patch
3+
---
4+
5+
Fixed issue where connectDatabaseToEmulator can be called twice during a hot reload

.changeset/quick-radios-obey.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/firestore": patch
3+
---
4+
5+
Update canonifyFilter to compute the canonization for flat conjunctions the same as implicit AND queries.

.changeset/stupid-swans-fix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/firestore": patch
3+
---
4+
5+
Fix an issue that stops some performance optimization being applied.

.changeset/wild-geckos-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/util': patch
3+
---
4+
5+
Reformat a comment that causes compile errors in some build toolchains.

.changeset/young-hornets-rescue.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@firebase/util': minor
3+
'firebase': minor
4+
---
5+
6+
Allow users to specify their environment as `node` or `browser` to override Firebase's runtime environment detection and force the SDK to act as if it were in the respective environment.

common/api-review/util.api.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export interface FirebaseDefaults {
193193
config?: Record<string, string>;
194194
// (undocumented)
195195
emulatorHosts?: Record<string, string>;
196+
forceEnvironment?: 'browser' | 'node';
196197
}
197198

198199
// Warning: (ae-missing-release-tag) "FirebaseError" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -221,11 +222,12 @@ export const getDefaultEmulatorHost: (productName: string) => string | undefined
221222
// @public
222223
export const getDefaultEmulatorHostnameAndPort: (productName: string) => [hostname: string, port: number] | undefined;
223224

225+
// @public
226+
export const getDefaults: () => FirebaseDefaults | undefined;
227+
224228
// @public
225229
export const getExperimentalSetting: <T extends ExperimentalKey>(name: T) => FirebaseDefaults[`_${T}`];
226230

227-
// Warning: (ae-missing-release-tag) "getGlobal" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
228-
//
229231
// @public
230232
export function getGlobal(): typeof globalThis;
231233

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"eslint-plugin-unused-imports": "2.0.0",
106106
"express": "4.18.2",
107107
"find-free-port": "2.0.0",
108-
"firebase-tools": "11.2.2",
108+
"firebase-tools": "11.19.0",
109109
"glob": "7.2.3",
110110
"http-server": "14.1.1",
111111
"indexeddbshim": "8.0.0",
@@ -140,7 +140,7 @@
140140
"protractor": "5.4.2",
141141
"request": "2.88.2",
142142
"semver": "7.3.8",
143-
"simple-git": "3.7.1",
143+
"simple-git": "3.15.0",
144144
"sinon": "9.2.4",
145145
"sinon-chai": "3.7.0",
146146
"source-map-loader": "1.1.3",

packages/database/src/api/Database.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,11 @@ export function getDatabase(
320320
const db = _getProvider(app, 'database').getImmediate({
321321
identifier: url
322322
}) as Database;
323-
const emulator = getDefaultEmulatorHostnameAndPort('database');
324-
if (emulator) {
325-
connectDatabaseEmulator(db, ...emulator);
323+
if (!db._instanceStarted) {
324+
const emulator = getDefaultEmulatorHostnameAndPort('database');
325+
if (emulator) {
326+
connectDatabaseEmulator(db, ...emulator);
327+
}
326328
}
327329
return db;
328330
}

packages/database/test/exp/integration.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ describe('Database@exp Tests', () => {
7777
const db = getDatabase(defaultApp);
7878
expect(db).to.be.ok;
7979
});
80+
it("doesn't try to connect to emulator after database has already started", async () => {
81+
const db = getDatabase(defaultApp);
82+
const r = ref(db, '.info/connected');
83+
const deferred = new Deferred();
84+
onValue(r, snapshot => {
85+
if (snapshot.val()) {
86+
deferred.resolve();
87+
}
88+
});
89+
await deferred.promise;
90+
process.env.__FIREBASE_DEFAULTS__ = JSON.stringify({
91+
emulatorHosts: {
92+
database: 'localhost:9000'
93+
}
94+
});
95+
expect(() => getDatabase(defaultApp)).to.not.throw();
96+
delete process.env.__FIREBASE_DEFAULTS__;
97+
});
8098

8199
it('Can get database with custom URL', () => {
82100
const db = getDatabase(defaultApp, 'http://foo.bar.com');

packages/firestore/src/core/filter.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,14 @@ export function canonifyFilter(filter: Filter): string {
325325
filter.op.toString() +
326326
canonicalId(filter.value)
327327
);
328+
} else if (compositeFilterIsFlatConjunction(filter)) {
329+
// Older SDK versions use an implicit AND operation between their filters.
330+
// In the new SDK versions, the developer may use an explicit AND filter.
331+
// To stay consistent with the old usages, we add a special case to ensure
332+
// the canonical ID for these two are the same. For example:
333+
// `col.whereEquals("a", 1).whereEquals("b", 2)` should have the same
334+
// canonical ID as `col.where(and(equals("a",1), equals("b",2)))`.
335+
return filter.filters.map(filter => canonifyFilter(filter)).join(',');
328336
} else {
329337
// filter instanceof CompositeFilter
330338
const canonicalIdsString = filter.filters

0 commit comments

Comments
 (0)