-
Notifications
You must be signed in to change notification settings - Fork 1.6k
datastore: Support decoding empty arrays #2755
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
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
|
I signed it! |
|
CLAs look good, thanks! |
|
@udoprog Can you give an example that currently fails, but would work under the changes in this PR? |
|
The python client doesn't permit writing an empty array, so you'll have to do that using another client (we do it using Java). Or, go into the cloud console and add an entity After this, run the following code: from google.cloud import datastore
if __name__ == "__main__":
client = datastore.Client('my-project-1')
k = client.key('test', 'test')
e = client.get(k)
print(e)Without this patch, you should see: |
|
Thanks @udoprog! In order to actually merge this in, we'll need some unit tests. You can write them yourself, or I am happy to write them, since you've allowed maintainers to push commits to your PR branch. |
|
@dhermes won't google CLA bot wig out if multiple people commit? |
|
@daspecster It may, but we the humans can ignore it. |
|
My apologies I can't take a more active part in this right now. Feel free to just see this as a bug report and fix things whatever way suits you best. |
| exclude_values = set(value_pb.exclude_from_indexes | ||
| for value_pb in value_pb.array_value.values) | ||
| if len(exclude_values) != 1: | ||
| if len(exclude_values) > 1: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
See also #3152, where I attempted to fix this problem and hit another problem. We likely do not need two issues for it, though, so I am closing this one. |
…oudPlatform/python-docs-samples#2755) * Add auto-generated Logo Recognition Samples * Add tests Remove boilerplate Update copyright date Blacken Remove unused imports Shorten docstrings Remove CLI Set defaults in function definition * Edit test video to 3 seconds from 35 Reduce quota usage to allow for parallel tests Retain longer version only for tests that require it * Fix bug Co-authored-by: Noah Negrey <nnegrey@users.noreply.github.com> Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com>
When the
array_valueis empty, the set also becomes empty which triggers the existing conditionlen(exclude_values) != 0.This patch changes this condition to permit empty array values to pass through.