Skip to content

Compat class for Query and CollectionReference #4065

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

Merged
merged 4 commits into from
Nov 16, 2020

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Nov 13, 2020

This series of PRs is coming to an end.
This PR adds Compat classes for Query and CollectionReference and is split across two commits. The first one creates the Compat classes, the second one moves code from src/api/database.ts to lite/src/api/reference.ts as the helper functions are now no longer needed by the classic API.

@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2020

⚠️ No Changeset found

Latest commit: b5f4490

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 13, 2020

Size Analysis Report

Affected Products

No changes between base commit (6c6c49a) and head commit (bf8a5d9).

Test Logs

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2020

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

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

Basically LGTM

directionStr?: PublicOrderByDirection
): Query<T> {
try {
// The "as string" cast is a little bit of a hack. `orderBy` accepts the
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised that we can't just make this different in our public typings vs are internal actual types. It seems like we could declare this in the .ts file and just omit it from the .d.ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are moving away from manually crafted typings. I still need to iron out some final details in #3790, but once that is merged, we will generate typings from source. All other firebase-exp SDKs are doing the same.

doc(documentPath?: string): DocumentReference<T> {
try {
if (documentPath !== undefined) {
return new DocumentReference(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why doesn't this case work if documentPath is undefined? I thought doc can't tell if you called it as doc(this._delegate, undefined) vs doc(this._delegate).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe we owe this to the genius of @mikelehen.

I added this comment:

        // Call `doc` without `documentPath` if `documentPath` is `undefined`
        // as `doc` validates the number of arguments to prevent users from
        // accidentally passing `undefined`.

Copy link
Contributor

Choose a reason for hiding this comment

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

😱

`use 'x' as your first orderBy(), but your first orderBy() is on ` +
`field 'y' instead.`;
`use 'x' as your first argument to Query.orderBy(), but your first ` +
`orderBy() is on field 'y' instead.`;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's somewhat surprising that we replace the first orderBy but not the second. In other cases where they're not spelled the same this seems like it would allow the implementation to leak out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

JavaScript reg-exp only replace one instance by default. I could use /g here but then the message will be harder to parse (or has to be rewritten even more).

@wilhuff wilhuff assigned schmidt-sebastian and unassigned wilhuff Nov 13, 2020
Copy link
Contributor Author

@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.

Feedback addressed (unfortunately as part of the merge commit: b5f4490, which merges the WriteBatch removal)

doc(documentPath?: string): DocumentReference<T> {
try {
if (documentPath !== undefined) {
return new DocumentReference(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe we owe this to the genius of @mikelehen.

I added this comment:

        // Call `doc` without `documentPath` if `documentPath` is `undefined`
        // as `doc` validates the number of arguments to prevent users from
        // accidentally passing `undefined`.

directionStr?: PublicOrderByDirection
): Query<T> {
try {
// The "as string" cast is a little bit of a hack. `orderBy` accepts the
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are moving away from manually crafted typings. I still need to iron out some final details in #3790, but once that is merged, we will generate typings from source. All other firebase-exp SDKs are doing the same.

`use 'x' as your first orderBy(), but your first orderBy() is on ` +
`field 'y' instead.`;
`use 'x' as your first argument to Query.orderBy(), but your first ` +
`orderBy() is on field 'y' instead.`;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

JavaScript reg-exp only replace one instance by default. I could use /g here but then the message will be harder to parse (or has to be rewritten even more).

@wilhuff wilhuff removed their assignment Nov 16, 2020
@wilhuff
Copy link
Contributor

wilhuff commented Nov 16, 2020

LGTM

Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

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

LGTM for real this time.

@schmidt-sebastian schmidt-sebastian merged commit 6cd65fc into master Nov 16, 2020
@firebase firebase locked and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants