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(model): Ensure repeated props have same kind when converting from ds #824

Merged
merged 1 commit into from
Nov 16, 2022

Conversation

rwhogg
Copy link
Contributor

@rwhogg rwhogg commented Nov 14, 2022

Legacy NDB had a bug where, with repeated Expando properties, it could end up writing arrays of different length if some entities had missing values for certain subproperties. When Cloud NDB read this out, it might have only loaded entities corresponding to the shorter array length. See issue #129 .

To fix this, with PR #176 , we made Cloud NDB check if there are length differences and pad out the array as necessary.

However, depending on the order properties are returned from Datastore in, we may have accidentally padded with subentities of the wrong kind, because it was possible to skip over updating the kind if we alternated between updating repeated properties.

(Eg: A.a with 2 elements, B.b with 3 elements, A.c with 3 elements -> A would end up with an element of B's kind)

@rwhogg rwhogg requested review from a team as code owners November 14, 2022 21:02
@product-auto-label product-auto-label bot added the api: datastore Issues related to the googleapis/python-ndb API. label Nov 14, 2022
Legacy NDB had a bug where, with repeated Expando properties, it could
end up writing arrays of different length if some entities had missing
values for certain subproperties. When Cloud NDB read this out, it might
have only loaded entities corresponding to the shorter array length.
See issue googleapis#129 .

To fix this, with PR googleapis#176 , we made Cloud NDB check if there are length
differences and pad out the array as necessary.

However, depending on the order properties are returned from Datastore in,
we may have accidentally padded with subentities of the wrong kind,
because it was possible to skip over updating the kind if we alternated
between updating repeated properties.

(Eg: A.a with 2 elements, B.b with 3 elements, A.c with 3 elements ->
A would end up with an element of B's kind)
@eddavisson
Copy link

LGTM

@parthea parthea added the owlbot:run Add this label to trigger the Owlbot post processor. label Nov 15, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Nov 15, 2022
@parthea parthea merged commit 29f5a85 into googleapis:main Nov 16, 2022
@rwhogg rwhogg deleted the fix-rep-prop-bug branch November 16, 2022 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/python-ndb API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants