Skip to content

Commit 16948bf

Browse files
committed
format
1 parent 7ce1711 commit 16948bf

File tree

4 files changed

+9
-40
lines changed

4 files changed

+9
-40
lines changed

packages/firestore/src/model/path.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ import { Integer } from '@firebase/webchannel-wrapper/bloom-blob';
1919

2020
import { debugAssert, fail } from '../util/assert';
2121
import { Code, FirestoreError } from '../util/error';
22+
import { primitiveComparator } from '../util/misc';
2223

23-
import { compareUtf8Strings } from './comparator';
24+
import { compareUtf8Strings } from './byteComparator';
2425

2526
export const DOCUMENT_KEY_NAME = '__name__';
2627

@@ -183,7 +184,7 @@ abstract class BasePath<B extends BasePath<B>> {
183184
return comparison;
184185
}
185186
}
186-
return Math.sign(p1.length - p2.length);
187+
return primitiveComparator(p1.length, p2.length);
187188
}
188189

189190
private static compareSegments(lhs: string, rhs: string): number {

packages/firestore/src/model/values.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { arrayEquals, primitiveComparator } from '../util/misc';
2929
import { forEach, objectSize } from '../util/obj';
3030
import { isNegativeZero } from '../util/types';
3131

32-
import { compareBlobs, compareUtf8Strings } from './comparator';
32+
import { compareBlobs, compareUtf8Strings } from './byteComparator';
3333
import { DocumentKey } from './document_key';
3434
import {
3535
normalizeByteString,
@@ -253,7 +253,6 @@ export function valueCompare(left: Value, right: Value): number {
253253
);
254254
case TypeOrder.StringValue:
255255
return compareUtf8Strings(left.stringValue!, right.stringValue!);
256-
// return primitiveComparator(left.stringValue!, right.stringValue!);
257256
case TypeOrder.BlobValue:
258257
return compareBlobs(left.bytesValue!, right.bytesValue!);
259258
case TypeOrder.RefValue:

packages/firestore/test/integration/api/database.test.ts

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,6 +2426,7 @@ apiDescribe('Database', persistence => {
24262426
});
24272427

24282428
describe('Unicode strings', () => {
2429+
const expectedResult = ['b', 'a', 'c', 'f', 'e', 'd', 'g'];
24292430
it('snapshot listener sorts unicode strings the same as server', async () => {
24302431
const testDocs = {
24312432
'a': { value: 'Łukasiewicz' },
@@ -2441,15 +2442,7 @@ apiDescribe('Database', persistence => {
24412442
const orderedQuery = query(collectionRef, orderBy('value'));
24422443

24432444
const getSnapshot = await getDocsFromServer(orderedQuery);
2444-
expect(toIds(getSnapshot)).to.deep.equal([
2445-
'b',
2446-
'a',
2447-
'c',
2448-
'f',
2449-
'e',
2450-
'd',
2451-
'g'
2452-
]);
2445+
expect(toIds(getSnapshot)).to.deep.equal(expectedResult);
24532446

24542447
const storeEvent = new EventsAccumulator<QuerySnapshot>();
24552448
const unsubscribe = onSnapshot(orderedQuery, storeEvent.storeEvent);
@@ -2475,15 +2468,7 @@ apiDescribe('Database', persistence => {
24752468
const orderedQuery = query(collectionRef, orderBy('value'));
24762469

24772470
const getSnapshot = await getDocsFromServer(orderedQuery);
2478-
expect(toIds(getSnapshot)).to.deep.equal([
2479-
'b',
2480-
'a',
2481-
'c',
2482-
'f',
2483-
'e',
2484-
'd',
2485-
'g'
2486-
]);
2471+
expect(toIds(getSnapshot)).to.deep.equal(expectedResult);
24872472

24882473
const storeEvent = new EventsAccumulator<QuerySnapshot>();
24892474
const unsubscribe = onSnapshot(orderedQuery, storeEvent.storeEvent);
@@ -2509,15 +2494,7 @@ apiDescribe('Database', persistence => {
25092494
const orderedQuery = query(collectionRef, orderBy('value'));
25102495

25112496
const getSnapshot = await getDocsFromServer(orderedQuery);
2512-
expect(toIds(getSnapshot)).to.deep.equal([
2513-
'b',
2514-
'a',
2515-
'c',
2516-
'f',
2517-
'e',
2518-
'd',
2519-
'g'
2520-
]);
2497+
expect(toIds(getSnapshot)).to.deep.equal(expectedResult);
25212498

25222499
const storeEvent = new EventsAccumulator<QuerySnapshot>();
25232500
const unsubscribe = onSnapshot(orderedQuery, storeEvent.storeEvent);
@@ -2543,15 +2520,7 @@ apiDescribe('Database', persistence => {
25432520
const orderedQuery = query(collectionRef, orderBy('value'));
25442521

25452522
const getSnapshot = await getDocsFromServer(orderedQuery);
2546-
expect(toIds(getSnapshot)).to.deep.equal([
2547-
'b',
2548-
'a',
2549-
'c',
2550-
'f',
2551-
'e',
2552-
'd',
2553-
'g'
2554-
]);
2523+
expect(toIds(getSnapshot)).to.deep.equal(expectedResult);
25552524

25562525
const storeEvent = new EventsAccumulator<QuerySnapshot>();
25572526
const unsubscribe = onSnapshot(orderedQuery, storeEvent.storeEvent);

0 commit comments

Comments
 (0)