-
Notifications
You must be signed in to change notification settings - Fork 66
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
Backwards compatibility with older style structured properties. #126
Backwards compatibility with older style structured properties. #126
Conversation
Note that coverage is complaining about an uncovered branch, but it looks to me that it is covered, so I'm not sure what's going on there. Still trying to figure that one out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks!
else: | ||
value.b_val.update({subname: subvalue}) | ||
|
||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've had trouble with coverage in continue statements before. Seems like the python optimizer just skips that and goes to the start of the loop directly, so the line is never reached. Solutions are: 1) Use "# pragma: no branch". 2) Turn off the optimizer. I have gone with 1) when I encounter this problem.
src/google/cloud/ndb/model.py
Outdated
for name, value in ds_entity.items(): | ||
prop = getattr(model_class, name, None) | ||
|
||
# Backwards compatibility shim. NDB previously stored structured | ||
# properties as sets of dotted name proprties. Datastore now has native |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo on "proprties", but the just merged spell checker should catch this before your next push (once you rebase, of course).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it looks like spell checker doesn't find it because comments don't make it into docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, I thought it was in a doc string. Duh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to approve.
When implementing structured properties the first time, I just used Datastore's native embedded entity functionality, not realizing that NDB had originally used dotted property names instead. (Probably GAE Datastore didn't have embedded entities when NDB was originally written.) The problem is that users migrating from GAE NDB can't load entities with structured properties from their existing datastore. This PR makes NDB backwards compatible with older, dotted name style structured properties so that existing repositories still work with the new NDB. Fixes googleapis#122.
Filed a bug for the coverage thing: |
8f94e99
to
83869fa
Compare
Hi Chris! |
No problem. Thanks for the bug report! |
When implementing structured properties the first time, I just used
Datastore's native embedded entity functionality, not realizing that NDB
had originally used dotted property names instead. (Probably GAE
Datastore didn't have embedded entities when NDB was originally
written.) The problem is that users migrating from GAE NDB can't load
entities with structured properties from their existing datastore. This
PR makes NDB backwards compatible with older, dotted name style
structured properties so that existing repositories still work with the
new NDB.
Fixes #122.