Skip to content

Commit

Permalink
Add warning message when passing DcoumentReference in cursor (#1883)
Browse files Browse the repository at this point in the history
  • Loading branch information
milaGGL committed Aug 17, 2023
1 parent ac35b37 commit cc622fc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dev/src/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,15 @@ export class Query<T = firestore.DocumentData> implements firestore.Query<T> {
return this._queryOptions.fieldOrders;
}

// TODO(b/296435819): Remove this warning message.
if (cursorValuesOrDocumentSnapshot[0] instanceof DocumentReference) {
// eslint-disable-next-line no-console
console.warn(
`Warning: Passing DocumentReference into a cursor without orderBy clause is not an intended
behavior. Please use DocumentSnapshot or add an explicit orderBy on document key field.`
);
}

const fieldOrders = this._queryOptions.fieldOrders.slice();

// If no explicit ordering is specified, use the first inequality to
Expand Down

0 comments on commit cc622fc

Please sign in to comment.