Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Chen committed Mar 29, 2021
1 parent 2cf01c2 commit 68a6ef1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
17 changes: 5 additions & 12 deletions dev/src/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1515,28 +1515,21 @@ export class Query<T = firestore.DocumentData> implements firestore.Query<T> {
}

const fieldOrders = this._queryOptions.fieldOrders.slice();
let hasDocumentId = false;

// If no explicit ordering is specified, use the first inequality to
// define an implicit order.
if (fieldOrders.length === 0) {
// If no explicit ordering is specified, use the first inequality to
// define an implicit order.
for (const fieldFilter of this._queryOptions.fieldFilters) {
if (FieldPath.documentId().isEqual(fieldFilter.field)) {
hasDocumentId = true;
}
if (fieldFilter.isInequalityFilter()) {
fieldOrders.push(new FieldOrder(fieldFilter.field));
break;
}
}
} else {
for (const fieldOrder of fieldOrders) {
if (FieldPath.documentId().isEqual(fieldOrder.field)) {
hasDocumentId = true;
}
}
}

const hasDocumentId = !!fieldOrders.find(fieldOrder =>
FieldPath.documentId().isEqual(fieldOrder.field)
);
if (!hasDocumentId) {
// Add implicit sorting by name, using the last specified direction.
const lastDirection =
Expand Down
2 changes: 1 addition & 1 deletion dev/test/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export function queryEquals(
): void {
queryEqualsWithParentAndReadTime(
actual,
'',
/* parent= */ '',
/* readTime= */ undefined,
...protoComponents
);
Expand Down

0 comments on commit 68a6ef1

Please sign in to comment.