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 startAfter/endBefore for orderByKeys queries #4363

Merged
merged 5 commits into from
Feb 1, 2021

Conversation

jmwski
Copy link
Contributor

@jmwski jmwski commented Jan 29, 2021

We should not be passing a fallback key to startAfter if we're querying on a key index. The indexValue is the key in this case.

@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2021

🦋 Changeset detected

Latest commit: ca75e92

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@firebase/database Patch
firebase Patch
@firebase/rules-unit-testing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -101,21 +101,15 @@ export class Query {
'or equalTo() must be a string.';
if (params.hasStart()) {
const startName = params.getIndexStartName();
if (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These just revert a previous change.

childKey = MAX_NAME;
let params: QueryParams;
if (this.index_ === KEY_INDEX) {
if (typeof indexValue === 'string') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check makes it so that startAfter still throws exceptions for incorrectly typed keys.

Copy link
Contributor

Choose a reason for hiding this comment

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

Where does it throw? Should we throw at the callsite to preserve the stacktrace of the original mistake?

Copy link
Contributor Author

@jmwski jmwski Jan 29, 2021

Choose a reason for hiding this comment

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

It throws in validateQueryEndpoints_: https://github.com/firebase/firebase-js-sdk/blob/master/packages/database/src/api/Query.ts#L110 (this behavior is tested), which is the same place that startAt() and endAt() throw for this case.

I think that the way it's done now the original mistake, passing a non-string key to startAfter() should still be clear. I'll also update the error message there.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jan 29, 2021

Size Analysis Report

Affected Products

No changes between base commit (4986a3e) and head commit (7d7eff6).

@jmwski jmwski assigned schmidt-sebastian and unassigned jmwski Jan 29, 2021
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

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

Please add change log entry.

@jmwski jmwski merged commit 0af2bdf into master Feb 1, 2021
@jmwski jmwski deleted the jw/orderbykeys-start-after branch February 1, 2021 20:21
@jmwski jmwski assigned jmwski and unassigned schmidt-sebastian Feb 1, 2021
@google-oss-bot google-oss-bot mentioned this pull request Feb 2, 2021
@firebase firebase locked and limited conversation to collaborators Mar 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants