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 query filters with urlsafe() ndb.Keys #9
Conversation
It would be nice to see this also recreated with |
|
||
def _JsonDecodeKey(d): | ||
"""Json decode a ndb.Key object.""" | ||
k_c = d['key_string'] |
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.
Please use something more descriptive than k_c for the var.
Maybe encoded_key?
@AngryBrock Done! Thanks for the feedback. :) |
encoded_key = d['encoded_key'] | ||
if isinstance(encoded_key, (list, tuple)): | ||
return ndb.Key(flat=encoded_key) | ||
return ndb.Key(urlsafe=d['encoded_key']) |
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.
Sorry for not being clear here. I mean on this line you should use the variable 'encoded_key' that you already set on line 103, rather than fetching it from 'd' again.
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.
oh gosh, duh. thanks 👍
Thanks for contributing! Just one small nitpick I have and then I will approve this. |
All set. :) |
Perfect, thanks! |
support query filters with urlsafe() ndb.Keys
Enables the
filters
parameter of the datastore input_readers to supply aurlsafe()
copy of anndb.Key
for andb.KeyProperty
.This support is important for cases where
ndb.Key
is not properly being "JSONified," as it is transformed through pipelines.An alternative user-end fix is to add
ndb.Key
JSONification through monkeypatching. This provides a more 'out of the box' solution for this seemingly common problem. - now included.