Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Property with empty list 4#512
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
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -218,6 +218,44 @@ def _get_value_from_property_pb(property_pb): | ||
| return _get_value_from_value_pb(property_pb.value) | ||
| def _set_protobuf_property(property_pb, name, value, indexed): | ||
| """Assign 'name', 'value', 'indexed' to the correct 'property_pb'. | ||
| Some value (empty list) cannot be directly assigned; this function handles | ||
| them correctly. | ||
| :type property_pb: :class:`gcloud.datastore.datastore_v1_pb2.Property` | ||
| :param property_pb: The value protobuf to which the value is being | ||
| assigned. | ||
| :type name: string | ||
| :param name: The name to be assigned. | ||
| :type value: `datetime.datetime`, boolean, float, integer, string, | ||
| :class:`gcloud.datastore.key.Key`, | ||
| :class:`gcloud.datastore.entity.Entity`, | ||
| :param value: The value to be assigned. | ||
| :type indexed: boolean | ||
| :param indexed: The flag indicates the property should to be indexed or | ||
| not. | ||
| """ | ||
| if isinstance(value, list) and len(value) == 0: | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| return | ||
| prop = property_pb.add() | ||
| prop.name = name | ||
| _set_protobuf_value(prop.value, value) | ||
| if not indexed: | ||
| if not isinstance(value, list): | ||
| prop.value.indexed = False | ||
| for sub_value in prop.value.list_value: | ||
| sub_value.indexed = False | ||
| def _set_protobuf_value(value_pb, val): | ||
| """Assign 'val' to the correct subfield of 'value_pb'. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.