Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add warning message when passing single DocumentReference in cursor without orderBy clause #1883

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.`
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please apply this patch to the Node SDK as well.


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

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