From dc2f9458925bc071043f2cc2678dea0ed405e967 Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Tue, 10 Dec 2024 10:55:52 -0500 Subject: [PATCH 1/7] handle numeric document ids --- .../src/local/memory_remote_document_cache.ts | 5 +- packages/firestore/src/model/path.ts | 53 +++++-- .../test/integration/api/database.test.ts | 133 +++++++++++++++++- 3 files changed, 178 insertions(+), 13 deletions(-) diff --git a/packages/firestore/src/local/memory_remote_document_cache.ts b/packages/firestore/src/local/memory_remote_document_cache.ts index 2b145acdf9d..180718e5ada 100644 --- a/packages/firestore/src/local/memory_remote_document_cache.ts +++ b/packages/firestore/src/local/memory_remote_document_cache.ts @@ -171,7 +171,10 @@ class MemoryRemoteDocumentCacheImpl implements MemoryRemoteDocumentCache { // Documents are ordered by key, so we can use a prefix scan to narrow down // the documents we need to match the query against. const collectionPath = query.path; - const prefix = new DocumentKey(collectionPath.child('')); + // DocumentId can be numeric ("__id__") or a plain string. Numeric IDs ordered before strings, sorted numerically. + const prefix = new DocumentKey( + collectionPath.child('__id' + Number.MIN_SAFE_INTEGER + '__') + ); const iterator = this.docs.getIteratorFrom(prefix); while (iterator.hasNext()) { const { diff --git a/packages/firestore/src/model/path.ts b/packages/firestore/src/model/path.ts index 3b68a67c68f..b6573ee1a4a 100644 --- a/packages/firestore/src/model/path.ts +++ b/packages/firestore/src/model/path.ts @@ -163,28 +163,59 @@ abstract class BasePath> { return this.segments.slice(this.offset, this.limit()); } + /** + * Compare 2 paths compared segment by segment, prioritizing numeric IDs + * (e.g., "__id123__") in numeric ascending order, followed by string + * segments in lexicographical order. + */ static comparator>( p1: BasePath, p2: BasePath ): number { const len = Math.min(p1.length, p2.length); for (let i = 0; i < len; i++) { - const left = p1.get(i); - const right = p2.get(i); - if (left < right) { - return -1; - } - if (left > right) { - return 1; + const comparison = BasePath.compareSegments(p1.get(i), p2.get(i)); + if (comparison !== 0) { + return comparison; } } - if (p1.length < p2.length) { + return Math.sign(p1.length - p2.length); + } + + private static compareSegments(lhs: string, rhs: string): number { + const isLhsNumeric = BasePath.isNumericId(lhs); + const isRhsNumeric = BasePath.isNumericId(rhs); + + if (isLhsNumeric && !isRhsNumeric) { + // Only lhs is numeric return -1; - } - if (p1.length > p2.length) { + } else if (!isLhsNumeric && isRhsNumeric) { + // Only rhs is numeric return 1; + } else if (isLhsNumeric && isRhsNumeric) { + // both numeric + return Math.sign( + BasePath.extractNumericId(lhs) - BasePath.extractNumericId(rhs) + ); + } else { + // both non-numeric + if (lhs < rhs) { + return -1; + } + if (lhs > rhs) { + return 1; + } + return 0; } - return 0; + } + + // Checks if a segment is a numeric ID (starts with "__id" and ends with "__"). + private static isNumericId(segment: string): boolean { + return segment.startsWith('__id') && segment.endsWith('__'); + } + + private static extractNumericId(segment: string): number { + return parseInt(segment.substring(4, segment.length - 2), 10); } } diff --git a/packages/firestore/test/integration/api/database.test.ts b/packages/firestore/test/integration/api/database.test.ts index 81dc7362a22..882c05b1ecc 100644 --- a/packages/firestore/test/integration/api/database.test.ts +++ b/packages/firestore/test/integration/api/database.test.ts @@ -79,7 +79,8 @@ import { withTestDocAndInitialData, withNamedTestDbsOrSkipUnlessUsingEmulator, toDataArray, - checkOnlineAndOfflineResultsMatch + checkOnlineAndOfflineResultsMatch, + toIds } from '../util/helpers'; import { DEFAULT_SETTINGS, DEFAULT_PROJECT_ID } from '../util/settings'; @@ -2245,4 +2246,134 @@ apiDescribe('Database', persistence => { }); }); }); + + describe('sort documents by DocumentId', () => { + it('snapshot listener sorts query by DocumentId same way as get query', async () => { + const testDocs = { + A: { a: 1 }, + a: { a: 1 }, + Aa: { a: 1 }, + '7': { a: 1 }, + 12: { a: 1 }, + '__id7__': { a: 1 }, + __id12__: { a: 1 }, + '__id-2__': { a: 1 }, + '_id1__': { a: 1 }, + '__id1_': { a: 1 } + }; + + return withTestCollection(persistence, testDocs, async collectionRef => { + const orderedQuery = query(collectionRef, orderBy(documentId())); + const expectedDocs = [ + '__id-2__', + '__id7__', + '__id12__', + '12', + '7', + 'A', + 'Aa', + '__id1_', + '_id1__', + 'a' + ]; + + const getSnapshot = await getDocsFromServer(orderedQuery); + expect(toIds(getSnapshot)).to.deep.equal(expectedDocs); + + const storeEvent = new EventsAccumulator(); + const unsubscribe = onSnapshot(orderedQuery, storeEvent.storeEvent); + const watchSnapshot = await storeEvent.awaitEvent(); + expect(toIds(watchSnapshot)).to.deep.equal(expectedDocs); + unsubscribe(); + }); + }); + + it('snapshot listener sorts filtered query by DocumentId same way as get query', async () => { + const testDocs = { + A: { a: 1 }, + a: { a: 1 }, + Aa: { a: 1 }, + '7': { a: 1 }, + 12: { a: 1 }, + '__id7__': { a: 1 }, + __id12__: { a: 1 }, + '__id-2__': { a: 1 }, + '_id1__': { a: 1 }, + '__id1_': { a: 1 } + }; + + return withTestCollection(persistence, testDocs, async collectionRef => { + const filteredQuery = query( + collectionRef, + orderBy(documentId()), + where(documentId(), '>', '__id7__'), + where(documentId(), '<=', 'Aa') + ); + const expectedDocs = ['__id12__', '12', '7', 'A', 'Aa']; + + const getSnapshot = await getDocsFromServer(filteredQuery); + expect(toIds(getSnapshot)).to.deep.equal(expectedDocs); + + const storeEvent = new EventsAccumulator(); + const unsubscribe = onSnapshot(filteredQuery, storeEvent.storeEvent); + const watchSnapshot = await storeEvent.awaitEvent(); + expect(toIds(watchSnapshot)).to.deep.equal(expectedDocs); + unsubscribe(); + }); + }); + + // eslint-disable-next-line no-restricted-properties + (persistence.gc === 'lru' ? describe : describe.skip)('offline', () => { + it('SDK orders query the same way online and offline', async () => { + const testDocs = { + A: { a: 1 }, + a: { a: 1 }, + Aa: { a: 1 }, + '7': { a: 1 }, + 12: { a: 1 }, + '__id7__': { a: 1 }, + __id12__: { a: 1 }, + '__id-2__': { a: 1 }, + '_id1__': { a: 1 }, + '__id1_': { a: 1 } + }; + + return withTestCollection( + persistence, + testDocs, + async collectionRef => { + const orderedQuery = query(collectionRef, orderBy(documentId())); + let expectedDocs = [ + '__id-2__', + '__id7__', + '__id12__', + '12', + '7', + 'A', + 'Aa', + '__id1_', + '_id1__', + 'a' + ]; + await checkOnlineAndOfflineResultsMatch( + orderedQuery, + ...expectedDocs + ); + + const filteredQuery = query( + collectionRef, + orderBy(documentId()), + where(documentId(), '>', '__id7__'), + where(documentId(), '<=', 'Aa') + ); + expectedDocs = ['__id12__', '12', '7', 'A', 'Aa']; + await checkOnlineAndOfflineResultsMatch( + filteredQuery, + ...expectedDocs + ); + } + ); + }); + }); + }); }); From f8c91ee7aebebffe43fec6537bf85b282d8fcca1 Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:44:57 -0500 Subject: [PATCH 2/7] handle 64bit longs in document key --- .../src/local/memory_remote_document_cache.ts | 11 +++- packages/firestore/src/model/path.ts | 9 +-- .../test/integration/api/database.test.ts | 55 +++++++++++++++++-- 3 files changed, 63 insertions(+), 12 deletions(-) diff --git a/packages/firestore/src/local/memory_remote_document_cache.ts b/packages/firestore/src/local/memory_remote_document_cache.ts index 180718e5ada..42a0010d4ac 100644 --- a/packages/firestore/src/local/memory_remote_document_cache.ts +++ b/packages/firestore/src/local/memory_remote_document_cache.ts @@ -47,6 +47,11 @@ interface MemoryRemoteDocumentCacheEntry { size: number; } +/** + * The smallest value representable by a 64-bit signed integer (long). + */ +const MIN_LONG_VALUE = '-9223372036854775808'; + type DocumentEntryMap = SortedMap; function documentEntryMap(): DocumentEntryMap { return new SortedMap( @@ -171,9 +176,11 @@ class MemoryRemoteDocumentCacheImpl implements MemoryRemoteDocumentCache { // Documents are ordered by key, so we can use a prefix scan to narrow down // the documents we need to match the query against. const collectionPath = query.path; - // DocumentId can be numeric ("__id__") or a plain string. Numeric IDs ordered before strings, sorted numerically. + // Document keys are ordered first by numeric value ("__id__"), + // then lexicographically by string value. Start the iterator at the minimum + // possible Document key value. const prefix = new DocumentKey( - collectionPath.child('__id' + Number.MIN_SAFE_INTEGER + '__') + collectionPath.child('__id' + MIN_LONG_VALUE + '__') ); const iterator = this.docs.getIteratorFrom(prefix); while (iterator.hasNext()) { diff --git a/packages/firestore/src/model/path.ts b/packages/firestore/src/model/path.ts index b6573ee1a4a..2a50564adbb 100644 --- a/packages/firestore/src/model/path.ts +++ b/packages/firestore/src/model/path.ts @@ -17,6 +17,7 @@ import { debugAssert, fail } from '../util/assert'; import { Code, FirestoreError } from '../util/error'; +import { Integer } from '@firebase/webchannel-wrapper/bloom-blob'; export const DOCUMENT_KEY_NAME = '__name__'; @@ -194,8 +195,8 @@ abstract class BasePath> { return 1; } else if (isLhsNumeric && isRhsNumeric) { // both numeric - return Math.sign( - BasePath.extractNumericId(lhs) - BasePath.extractNumericId(rhs) + return BasePath.extractNumericId(lhs).compare( + BasePath.extractNumericId(rhs) ); } else { // both non-numeric @@ -214,8 +215,8 @@ abstract class BasePath> { return segment.startsWith('__id') && segment.endsWith('__'); } - private static extractNumericId(segment: string): number { - return parseInt(segment.substring(4, segment.length - 2), 10); + private static extractNumericId(segment: string): Integer { + return Integer.fromString(segment.substring(4, segment.length - 2)); } } diff --git a/packages/firestore/test/integration/api/database.test.ts b/packages/firestore/test/integration/api/database.test.ts index 882c05b1ecc..3cf00d05d37 100644 --- a/packages/firestore/test/integration/api/database.test.ts +++ b/packages/firestore/test/integration/api/database.test.ts @@ -2259,15 +2259,25 @@ apiDescribe('Database', persistence => { __id12__: { a: 1 }, '__id-2__': { a: 1 }, '_id1__': { a: 1 }, - '__id1_': { a: 1 } + '__id1_': { a: 1 }, + // max safe integer +1, +2 + '__id9007199254740992__': { a: 1 }, + '__id9007199254740993__': { a: 2 }, + // smallest long numbers + '__id-9223372036854775808__': { a: 3 }, + '__id-9223372036854775807__': { a: 4 } }; return withTestCollection(persistence, testDocs, async collectionRef => { const orderedQuery = query(collectionRef, orderBy(documentId())); const expectedDocs = [ + '__id-9223372036854775808__', + '__id-9223372036854775807__', '__id-2__', '__id7__', '__id12__', + '__id9007199254740992__', + '__id9007199254740993__', '12', '7', 'A', @@ -2284,6 +2294,7 @@ apiDescribe('Database', persistence => { const unsubscribe = onSnapshot(orderedQuery, storeEvent.storeEvent); const watchSnapshot = await storeEvent.awaitEvent(); expect(toIds(watchSnapshot)).to.deep.equal(expectedDocs); + unsubscribe(); }); }); @@ -2299,7 +2310,13 @@ apiDescribe('Database', persistence => { __id12__: { a: 1 }, '__id-2__': { a: 1 }, '_id1__': { a: 1 }, - '__id1_': { a: 1 } + '__id1_': { a: 1 }, + // max safe integer +1, +2 + '__id9007199254740992__': { a: 1 }, + '__id9007199254740993__': { a: 2 }, + // smallest long numbers + '__id-9223372036854775808__': { a: 3 }, + '__id-9223372036854775807__': { a: 4 } }; return withTestCollection(persistence, testDocs, async collectionRef => { @@ -2309,7 +2326,15 @@ apiDescribe('Database', persistence => { where(documentId(), '>', '__id7__'), where(documentId(), '<=', 'Aa') ); - const expectedDocs = ['__id12__', '12', '7', 'A', 'Aa']; + const expectedDocs = [ + '__id12__', + '__id9007199254740992__', + '__id9007199254740993__', + '12', + '7', + 'A', + 'Aa' + ]; const getSnapshot = await getDocsFromServer(filteredQuery); expect(toIds(getSnapshot)).to.deep.equal(expectedDocs); @@ -2335,18 +2360,28 @@ apiDescribe('Database', persistence => { __id12__: { a: 1 }, '__id-2__': { a: 1 }, '_id1__': { a: 1 }, - '__id1_': { a: 1 } + '__id1_': { a: 1 }, + // max safe integer +1, +2 + '__id9007199254740992__': { a: 1 }, + '__id9007199254740993__': { a: 2 }, + // smallest long numbers + '__id-9223372036854775808__': { a: 3 }, + '__id-9223372036854775807__': { a: 4 } }; return withTestCollection( - persistence, + persistence.toLruGc(), testDocs, async collectionRef => { const orderedQuery = query(collectionRef, orderBy(documentId())); let expectedDocs = [ + '__id-9223372036854775808__', + '__id-9223372036854775807__', '__id-2__', '__id7__', '__id12__', + '__id9007199254740992__', + '__id9007199254740993__', '12', '7', 'A', @@ -2366,7 +2401,15 @@ apiDescribe('Database', persistence => { where(documentId(), '>', '__id7__'), where(documentId(), '<=', 'Aa') ); - expectedDocs = ['__id12__', '12', '7', 'A', 'Aa']; + expectedDocs = [ + '__id12__', + '__id9007199254740992__', + '__id9007199254740993__', + '12', + '7', + 'A', + 'Aa' + ]; await checkOnlineAndOfflineResultsMatch( filteredQuery, ...expectedDocs From 0c6bd90fbbaca7a19f284f9d14842dedea284886 Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:50:31 -0500 Subject: [PATCH 3/7] format --- packages/firestore/src/model/path.ts | 3 ++- .../test/integration/api/database.test.ts | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/firestore/src/model/path.ts b/packages/firestore/src/model/path.ts index 2a50564adbb..ce362f7c60f 100644 --- a/packages/firestore/src/model/path.ts +++ b/packages/firestore/src/model/path.ts @@ -15,9 +15,10 @@ * limitations under the License. */ +import { Integer } from '@firebase/webchannel-wrapper/bloom-blob'; + import { debugAssert, fail } from '../util/assert'; import { Code, FirestoreError } from '../util/error'; -import { Integer } from '@firebase/webchannel-wrapper/bloom-blob'; export const DOCUMENT_KEY_NAME = '__name__'; diff --git a/packages/firestore/test/integration/api/database.test.ts b/packages/firestore/test/integration/api/database.test.ts index 3cf00d05d37..8140d4590fd 100644 --- a/packages/firestore/test/integration/api/database.test.ts +++ b/packages/firestore/test/integration/api/database.test.ts @@ -2262,10 +2262,10 @@ apiDescribe('Database', persistence => { '__id1_': { a: 1 }, // max safe integer +1, +2 '__id9007199254740992__': { a: 1 }, - '__id9007199254740993__': { a: 2 }, + '__id9007199254740993__': { a: 1 }, // smallest long numbers - '__id-9223372036854775808__': { a: 3 }, - '__id-9223372036854775807__': { a: 4 } + '__id-9223372036854775808__': { a: 1 }, + '__id-9223372036854775807__': { a: 1 } }; return withTestCollection(persistence, testDocs, async collectionRef => { @@ -2313,10 +2313,10 @@ apiDescribe('Database', persistence => { '__id1_': { a: 1 }, // max safe integer +1, +2 '__id9007199254740992__': { a: 1 }, - '__id9007199254740993__': { a: 2 }, + '__id9007199254740993__': { a: 1 }, // smallest long numbers - '__id-9223372036854775808__': { a: 3 }, - '__id-9223372036854775807__': { a: 4 } + '__id-9223372036854775808__': { a: 1 }, + '__id-9223372036854775807__': { a: 1 } }; return withTestCollection(persistence, testDocs, async collectionRef => { @@ -2363,10 +2363,10 @@ apiDescribe('Database', persistence => { '__id1_': { a: 1 }, // max safe integer +1, +2 '__id9007199254740992__': { a: 1 }, - '__id9007199254740993__': { a: 2 }, + '__id9007199254740993__': { a: 1 }, // smallest long numbers - '__id-9223372036854775808__': { a: 3 }, - '__id-9223372036854775807__': { a: 4 } + '__id-9223372036854775808__': { a: 1 }, + '__id-9223372036854775807__': { a: 1 } }; return withTestCollection( From f9a3df1129c290651cf6472909edb6f0ca5923fb Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:51:25 -0500 Subject: [PATCH 4/7] Update path.ts --- packages/firestore/src/model/path.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firestore/src/model/path.ts b/packages/firestore/src/model/path.ts index ce362f7c60f..64cb0376a0e 100644 --- a/packages/firestore/src/model/path.ts +++ b/packages/firestore/src/model/path.ts @@ -166,7 +166,7 @@ abstract class BasePath> { } /** - * Compare 2 paths compared segment by segment, prioritizing numeric IDs + * Compare 2 paths segment by segment, prioritizing numeric IDs * (e.g., "__id123__") in numeric ascending order, followed by string * segments in lexicographical order. */ From 85d78a3b61431c4703ae69b687aa7b4541e9db09 Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:36:45 -0500 Subject: [PATCH 5/7] add largest long numbers --- .../test/integration/api/database.test.ts | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/firestore/test/integration/api/database.test.ts b/packages/firestore/test/integration/api/database.test.ts index 8140d4590fd..c007c44973d 100644 --- a/packages/firestore/test/integration/api/database.test.ts +++ b/packages/firestore/test/integration/api/database.test.ts @@ -2260,9 +2260,9 @@ apiDescribe('Database', persistence => { '__id-2__': { a: 1 }, '_id1__': { a: 1 }, '__id1_': { a: 1 }, - // max safe integer +1, +2 - '__id9007199254740992__': { a: 1 }, - '__id9007199254740993__': { a: 1 }, + // largest long numbers + '__id9223372036854775807__': { a: 1 }, + '__id9223372036854775806__': { a: 1 }, // smallest long numbers '__id-9223372036854775808__': { a: 1 }, '__id-9223372036854775807__': { a: 1 } @@ -2276,8 +2276,8 @@ apiDescribe('Database', persistence => { '__id-2__', '__id7__', '__id12__', - '__id9007199254740992__', - '__id9007199254740993__', + '__id9223372036854775806__', + '__id9223372036854775807__', '12', '7', 'A', @@ -2311,9 +2311,9 @@ apiDescribe('Database', persistence => { '__id-2__': { a: 1 }, '_id1__': { a: 1 }, '__id1_': { a: 1 }, - // max safe integer +1, +2 - '__id9007199254740992__': { a: 1 }, - '__id9007199254740993__': { a: 1 }, + // largest long numbers + '__id9223372036854775807__': { a: 1 }, + '__id9223372036854775806__': { a: 1 }, // smallest long numbers '__id-9223372036854775808__': { a: 1 }, '__id-9223372036854775807__': { a: 1 } @@ -2328,8 +2328,8 @@ apiDescribe('Database', persistence => { ); const expectedDocs = [ '__id12__', - '__id9007199254740992__', - '__id9007199254740993__', + '__id9223372036854775806__', + '__id9223372036854775807__', '12', '7', 'A', @@ -2361,16 +2361,16 @@ apiDescribe('Database', persistence => { '__id-2__': { a: 1 }, '_id1__': { a: 1 }, '__id1_': { a: 1 }, - // max safe integer +1, +2 - '__id9007199254740992__': { a: 1 }, - '__id9007199254740993__': { a: 1 }, + // largest long numbers + '__id9223372036854775807__': { a: 1 }, + '__id9223372036854775806__': { a: 1 }, // smallest long numbers '__id-9223372036854775808__': { a: 1 }, '__id-9223372036854775807__': { a: 1 } }; return withTestCollection( - persistence.toLruGc(), + persistence, testDocs, async collectionRef => { const orderedQuery = query(collectionRef, orderBy(documentId())); @@ -2380,8 +2380,8 @@ apiDescribe('Database', persistence => { '__id-2__', '__id7__', '__id12__', - '__id9007199254740992__', - '__id9007199254740993__', + '__id9223372036854775806__', + '__id9223372036854775807__', '12', '7', 'A', @@ -2403,8 +2403,8 @@ apiDescribe('Database', persistence => { ); expectedDocs = [ '__id12__', - '__id9007199254740992__', - '__id9007199254740993__', + '__id9223372036854775806__', + '__id9223372036854775807__', '12', '7', 'A', From ff546712955ca2625587a4fbf6005f2ba6cd0efe Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:05:35 -0500 Subject: [PATCH 6/7] wrap documentIds into '' --- .../test/integration/api/database.test.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/firestore/test/integration/api/database.test.ts b/packages/firestore/test/integration/api/database.test.ts index c007c44973d..9c2ae8440d1 100644 --- a/packages/firestore/test/integration/api/database.test.ts +++ b/packages/firestore/test/integration/api/database.test.ts @@ -2250,13 +2250,13 @@ apiDescribe('Database', persistence => { describe('sort documents by DocumentId', () => { it('snapshot listener sorts query by DocumentId same way as get query', async () => { const testDocs = { - A: { a: 1 }, - a: { a: 1 }, - Aa: { a: 1 }, + 'A': { a: 1 }, + 'a': { a: 1 }, + 'Aa': { a: 1 }, '7': { a: 1 }, - 12: { a: 1 }, + '12': { a: 1 }, '__id7__': { a: 1 }, - __id12__: { a: 1 }, + '__id12__': { a: 1 }, '__id-2__': { a: 1 }, '_id1__': { a: 1 }, '__id1_': { a: 1 }, @@ -2301,13 +2301,13 @@ apiDescribe('Database', persistence => { it('snapshot listener sorts filtered query by DocumentId same way as get query', async () => { const testDocs = { - A: { a: 1 }, - a: { a: 1 }, - Aa: { a: 1 }, + 'A': { a: 1 }, + 'a': { a: 1 }, + 'Aa': { a: 1 }, '7': { a: 1 }, - 12: { a: 1 }, + '12': { a: 1 }, '__id7__': { a: 1 }, - __id12__: { a: 1 }, + '__id12__': { a: 1 }, '__id-2__': { a: 1 }, '_id1__': { a: 1 }, '__id1_': { a: 1 }, @@ -2351,13 +2351,13 @@ apiDescribe('Database', persistence => { (persistence.gc === 'lru' ? describe : describe.skip)('offline', () => { it('SDK orders query the same way online and offline', async () => { const testDocs = { - A: { a: 1 }, - a: { a: 1 }, - Aa: { a: 1 }, + 'A': { a: 1 }, + 'a': { a: 1 }, + 'Aa': { a: 1 }, '7': { a: 1 }, - 12: { a: 1 }, + '12': { a: 1 }, '__id7__': { a: 1 }, - __id12__: { a: 1 }, + '__id12__': { a: 1 }, '__id-2__': { a: 1 }, '_id1__': { a: 1 }, '__id1_': { a: 1 }, From 32cdcb0519dc657932a9d8b5076cc5721c04caa3 Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:27:15 -0500 Subject: [PATCH 7/7] add "__id" to tests --- packages/firestore/test/integration/api/database.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/firestore/test/integration/api/database.test.ts b/packages/firestore/test/integration/api/database.test.ts index 9c2ae8440d1..1cda49d9229 100644 --- a/packages/firestore/test/integration/api/database.test.ts +++ b/packages/firestore/test/integration/api/database.test.ts @@ -2260,6 +2260,7 @@ apiDescribe('Database', persistence => { '__id-2__': { a: 1 }, '_id1__': { a: 1 }, '__id1_': { a: 1 }, + '__id': { a: 1 }, // largest long numbers '__id9223372036854775807__': { a: 1 }, '__id9223372036854775806__': { a: 1 }, @@ -2282,6 +2283,7 @@ apiDescribe('Database', persistence => { '7', 'A', 'Aa', + '__id', '__id1_', '_id1__', 'a' @@ -2311,6 +2313,7 @@ apiDescribe('Database', persistence => { '__id-2__': { a: 1 }, '_id1__': { a: 1 }, '__id1_': { a: 1 }, + '__id': { a: 1 }, // largest long numbers '__id9223372036854775807__': { a: 1 }, '__id9223372036854775806__': { a: 1 }, @@ -2361,6 +2364,7 @@ apiDescribe('Database', persistence => { '__id-2__': { a: 1 }, '_id1__': { a: 1 }, '__id1_': { a: 1 }, + '__id': { a: 1 }, // largest long numbers '__id9223372036854775807__': { a: 1 }, '__id9223372036854775806__': { a: 1 }, @@ -2386,6 +2390,7 @@ apiDescribe('Database', persistence => { '7', 'A', 'Aa', + '__id', '__id1_', '_id1__', 'a'