Skip to content

Treat empty maps correctly in Document.get() #2206

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
Oct 1, 2019
Merged

Conversation

schmidt-sebastian
Copy link
Contributor

Fixes #2204

This fixes the types for MapValue.fields so that tslint catches undefined violations and removes the violation in getProtoField that caused #2204

Note that is seems pretty involved to write a test for this since this code is only hit in Query processing and not in DocumentSnapshot.get() (see

const value = this._document
). If requested, I can add this test next week.

@schmidt-sebastian schmidt-sebastian changed the title Treat empty maps correctly in DocumentSnapshot.get() Treat empty maps correctly in Document.get() Sep 28, 2019
Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Can we not add a test for this?

Also, I don't exactly understand the issue. proto.fields can be missing if the document is empty? Is there a similar issue with empty maps inside a document? Or is only the root of the document an issue for some reason? If you can find a way to add comments to make it clearer, that might be nice. :-)

@schmidt-sebastian
Copy link
Contributor Author

I fixed the browser tests and was now able to write a test that fails on master and succeeds with this PR. I did not add any inline comments as the types should speak for themselves.

As for your questions - I don't think this.proto.fields should ever be missing (but the types allow for it now, since this.proto is a fields?: ApiClientObjectMap<Value>. The issue the customer ran into is a nested empty map that did not contain the fields property when read back from IndexedDb (despite

).

@schmidt-sebastian
Copy link
Contributor Author

I fixed the browser tests and was now able to write a test that fails on master and succeeds with this PR. I did not add any inline comments as the types should speak for themselves.

As for your questions - I don't think this.proto.fields should ever be missing (but the types allow for it now, since this.proto is a fields?: ApiClientObjectMap<Value>. The issue the customer ran into is a nested empty map that did not contain the fields property when read back from IndexedDb (despite

).

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

LGTM

@mikelehen mikelehen merged commit 9be8285 into master Oct 1, 2019
@mikelehen mikelehen deleted the mrschmidt/emptyfields branch October 1, 2019 19:25
@firebase firebase locked and limited conversation to collaborators Nov 1, 2019
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.

Error thrown when empty map is present in firestore document
2 participants