Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
milaGGL committed Aug 21, 2023
1 parent 94b0f18 commit 990c245
Showing 1 changed file with 28 additions and 76 deletions.
104 changes: 28 additions & 76 deletions dev/system-test/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2697,9 +2697,9 @@ describe('Query class', () => {
.where('name', '!=', 'room 200')
.orderBy('name');
let docSnap = await collection.doc('doc4').get();
let query_sdk_normalized = query.startAt(docSnap);
let queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc4', 'doc1');
expectDocs(await query_sdk_normalized.get(), 'doc4', 'doc1');
expectDocs(await queryWithCursor.get(), 'doc4', 'doc1');

// ordered by: name desc, field desc, field.dot desc, field\\slash desc, __name__ desc
query = collection
Expand All @@ -2708,9 +2708,9 @@ describe('Query class', () => {
.where('field\\slash', '<', 400)
.orderBy('name', 'desc');
docSnap = await collection.doc('doc2').get();
query_sdk_normalized = query.startAt(docSnap);
queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc2', 'doc3');
expectDocs(await query_sdk_normalized.get(), 'doc2', 'doc3');
expectDocs(await queryWithCursor.get(), 'doc2', 'doc3');
});

it('can use with nested composite filters', async () => {
Expand All @@ -2734,15 +2734,9 @@ describe('Query class', () => {
)
);
let docSnap = await collection.doc('doc1').get();
let query_sdk_normalized = query.startAt(docSnap);
let queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc1', 'doc6', 'doc5', 'doc4');
expectDocs(
await query_sdk_normalized.get(),
'doc1',
'doc6',
'doc5',
'doc4'
);
expectDocs(await queryWithCursor.get(), 'doc1', 'doc6', 'doc5', 'doc4');

// Ordered by: 'sort' desc, 'key' asc, 'v' asc, __name__ asc
query = collection
Expand All @@ -2761,15 +2755,9 @@ describe('Query class', () => {
.orderBy('sort', 'desc')
.orderBy('key');
docSnap = await collection.doc('doc5').get();
query_sdk_normalized = query.startAt(docSnap);
queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc5', 'doc4', 'doc1', 'doc6');
expectDocs(
await query_sdk_normalized.get(),
'doc5',
'doc4',
'doc1',
'doc6'
);
expectDocs(await queryWithCursor.get(), 'doc5', 'doc4', 'doc1', 'doc6');

// Implicitly ordered by: 'key' asc, 'sort' asc, 'v' asc, __name__ asc
query = collection.where(
Expand All @@ -2794,9 +2782,9 @@ describe('Query class', () => {
)
);
docSnap = await collection.doc('doc1').get();
query_sdk_normalized = query.startAt(docSnap);
queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc1', 'doc2');
expectDocs(await query_sdk_normalized.get(), 'doc1', 'doc2');
expectDocs(await queryWithCursor.get(), 'doc1', 'doc2');
});

it('inequality fields will be implicitly ordered lexicographically by the server', async () => {
Expand All @@ -2816,31 +2804,19 @@ describe('Query class', () => {
.where('key', '!=', 'a')
.where('sort', '>', 1)
.where('v', 'in', [1, 2, 3, 4]);
let query_sdk_normalized = query.startAt(docSnap);
let queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc2', 'doc4', 'doc5', 'doc3');
expectDocs(
await query_sdk_normalized.get(),
'doc2',
'doc4',
'doc5',
'doc3'
);
expectDocs(await queryWithCursor.get(), 'doc2', 'doc4', 'doc5', 'doc3');

// Changing filters order will not effect implicit order.
// Implicitly ordered by: 'key' asc, 'sort' asc, __name__ asc
query = collection
.where('sort', '>', 1)
.where('key', '!=', 'a')
.where('v', 'in', [1, 2, 3, 4]);
query_sdk_normalized = query.startAt(docSnap);
queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc2', 'doc4', 'doc5', 'doc3');
expectDocs(
await query_sdk_normalized.get(),
'doc2',
'doc4',
'doc5',
'doc3'
);
expectDocs(await queryWithCursor.get(), 'doc2', 'doc4', 'doc5', 'doc3');
});

it('can use multiple explicit order by field', async () => {
Expand All @@ -2860,31 +2836,19 @@ describe('Query class', () => {
.where('key', '>', 'a')
.where('sort', '>=', 1)
.orderBy('v');
let query_sdk_normalized = query.startAt(docSnap);
let queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc2', 'doc4', 'doc3', 'doc5');
expectDocs(
await query_sdk_normalized.get(),
'doc2',
'doc4',
'doc3',
'doc5'
);
expectDocs(await queryWithCursor.get(), 'doc2', 'doc4', 'doc3', 'doc5');

// Ordered by: 'v asc, 'sort' asc, 'key' asc, __name__ asc
query = collection
.where('key', '>', 'a')
.where('sort', '>=', 1)
.orderBy('v')
.orderBy('sort');
query_sdk_normalized = query.startAt(docSnap);
queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc2', 'doc5', 'doc4', 'doc3');
expectDocs(
await query_sdk_normalized.get(),
'doc2',
'doc5',
'doc4',
'doc3'
);
expectDocs(await queryWithCursor.get(), 'doc2', 'doc5', 'doc4', 'doc3');

docSnap = await collection.doc('doc5').get();

Expand All @@ -2894,31 +2858,19 @@ describe('Query class', () => {
.where('key', '>', 'a')
.where('sort', '>=', 1)
.orderBy('v', 'desc');
query_sdk_normalized = query.startAt(docSnap);
queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc5', 'doc3', 'doc4', 'doc2');
expectDocs(
await query_sdk_normalized.get(),
'doc5',
'doc3',
'doc4',
'doc2'
);
expectDocs(await queryWithCursor.get(), 'doc5', 'doc3', 'doc4', 'doc2');

// Ordered by: 'v desc, 'sort' asc, 'key' asc, __name__ asc
query = collection
.where('key', '>', 'a')
.where('sort', '>=', 1)
.orderBy('v', 'desc')
.orderBy('sort');
query_sdk_normalized = query.startAt(docSnap);
queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc5', 'doc4', 'doc3', 'doc2');
expectDocs(
await query_sdk_normalized.get(),
'doc5',
'doc4',
'doc3',
'doc2'
);
expectDocs(await queryWithCursor.get(), 'doc5', 'doc4', 'doc3', 'doc2');
});

it('can use in aggregate query', async () => {
Expand Down Expand Up @@ -2957,29 +2909,29 @@ describe('Query class', () => {
.where('sort', '>=', 1)
.where('key', '!=', 'a')
.where(FieldPath.documentId(), '<', 'doc5');
let query_sdk_normalized = query.startAt(docSnap);
let queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc2', 'doc4', 'doc3');
expectDocs(await query_sdk_normalized.get(), 'doc2', 'doc4', 'doc3');
expectDocs(await queryWithCursor.get(), 'doc2', 'doc4', 'doc3');

// Changing filters order will not effect implicit order.
// Implicitly ordered by: 'key' asc, 'sort' asc, __name__ asc
query = collection
.where(FieldPath.documentId(), '<', 'doc5')
.where('sort', '>=', 1)
.where('key', '!=', 'a');
query_sdk_normalized = query.startAt(docSnap);
queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc2', 'doc4', 'doc3');
expectDocs(await query_sdk_normalized.get(), 'doc2', 'doc4', 'doc3');
expectDocs(await queryWithCursor.get(), 'doc2', 'doc4', 'doc3');

// Ordered by: 'sort' desc,'key' desc, __name__ desc
query = collection
.where(FieldPath.documentId(), '<', 'doc5')
.where('sort', '>=', 1)
.where('key', '!=', 'a')
.orderBy('sort', 'desc');
query_sdk_normalized = query.startAt(docSnap);
queryWithCursor = query.startAt(docSnap);
expectDocs(await query.get(), 'doc2', 'doc3', 'doc4');
expectDocs(await query_sdk_normalized.get(), 'doc2', 'doc3', 'doc4');
expectDocs(await queryWithCursor.get(), 'doc2', 'doc3', 'doc4');
});
});
});
Expand Down

0 comments on commit 990c245

Please sign in to comment.