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

Support v1beta2 indexes API #1014

Merged
merged 28 commits into from
Dec 20, 2018
Merged

Support v1beta2 indexes API #1014

merged 28 commits into from
Dec 20, 2018

Conversation

samtstern
Copy link
Contributor

@samtstern samtstern commented Nov 14, 2018

Enables #889

The new indexes API better supports:

  • Collection group indexes
  • Array indexes
  • Future index types (more flexible)
  • Single-field index controls

Example of pretty-printing index config with some field exemptions:
image

@googlebot googlebot added the cla: yes Manual indication that this has passed CLA. label Nov 14, 2018
@coveralls
Copy link

coveralls commented Nov 14, 2018

Coverage Status

Coverage decreased (-0.4%) to 60.464% when pulling d15521a on ss-indexes-v1beta2 into 296ea48 on master.

@samtstern samtstern changed the title [WIP] v1beta2 indexes API Support v1beta2 indexes API Dec 10, 2018
@samtstern samtstern requested a review from mbleigh December 10, 2018 22:02
@samtstern
Copy link
Contributor Author

@coveralls try again?

@samtstern
Copy link
Contributor Author

Whoops, forgot to assign.

@mbleigh feel free to pass off to someone else.

src/commands/firestore-indexes-list.ts Outdated Show resolved Hide resolved
src/firestore/indexes.ts Outdated Show resolved Hide resolved
src/firestore/indexes.ts Outdated Show resolved Hide resolved
src/firestore/indexes.ts Outdated Show resolved Hide resolved
src/firestore/indexes.ts Outdated Show resolved Hide resolved

// Try to detect use of the old API, warn the users.
if (spec.indexes[0].collectionId) {
utils.logBullet(
Copy link
Contributor

Choose a reason for hiding this comment

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

if you print this message, you still want to continue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is fine for now. Maybe in the future this will be breaking.

src/firestore/validator.js Outdated Show resolved Hide resolved
src/test/firestore/indexes.spec.ts Outdated Show resolved Hide resolved
src/test/firestore/indexes.spec.ts Outdated Show resolved Hide resolved
{ fieldPath: "bar", arrayConfig: "CONTAINS" },
],
state: API.State.READY,
} as API.Index;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is definitely a hole in my TS knowledge - is this equivalent? (with no as API.Index)

const apiIndex: API.Index = {...};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I am not sure what's going on here ... if I do what you suggested it wants me to define all undefined fields as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wait I figured it out.

Copy link
Contributor

@bkendall bkendall left a comment

Choose a reason for hiding this comment

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

This seems reasonable to me as code, but I am not super confident in functional testing it. Is there something I can to do exercise this locally and test it out?

@@ -86,7 +87,7 @@ describe("IndexValidation", () => {
},
],
});
}).to.throw();
}).to.throw(FirebaseError, /Must contain exactly one of "order,arrayConfig"/);
Copy link
Contributor

Choose a reason for hiding this comment

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

, with no space after? Should that have a space?

Copy link
Contributor

Choose a reason for hiding this comment

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

Specifically, in the "Must contain exactly" error message

@samtstern
Copy link
Contributor Author

@bkendall yeah you can do a few things:

Setup

  • Get a hold of a Firestore project.
  • Create a few indexes and single-field exclusions in the console (doesn't matter if they have any relation to any real data)

Tests

  • Try doing firebase init on that project with the CLI at HEAD and the CLI in this PR
  • After doing firebase init with this PR, try editing firebase.indexes.json and doing firebase deploy --only firestore:indexes again to see if the changes are reflected in the console as you expect
  • Try running firebase firestore:indexes with and without --pretty to see your indexes

@samtstern
Copy link
Contributor Author

@bkendall should I be waiting for you to do some integration testing here?

@bkendall
Copy link
Contributor

Looks like 'upgrade' for old-to-new may have a bug, but the functional testing I did looks good :)

@samtstern
Copy link
Contributor Author

Did a test of deploying an old indexes.json with the new code:
image

@bkendall
Copy link
Contributor

huzzah!

One last thing: I think you need some specific logs for indexes. See what happens when I do deploy with no only and when I do? There's nothing telling me what I'm deploying to firestore

image

@samtstern
Copy link
Contributor Author

New more better logging:

image

@samtstern samtstern merged commit 69db5be into master Dec 20, 2018
samtstern added a commit that referenced this pull request Dec 20, 2018
bkendall pushed a commit that referenced this pull request Dec 20, 2018
@samtstern samtstern deleted the ss-indexes-v1beta2 branch April 5, 2019 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Manual indication that this has passed CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants