Title: Storing an Entity as an indexed property value always fails · Issue #529 · googleapis/google-cloud-python · GitHub
Open Graph Title: Storing an Entity as an indexed property value always fails · Issue #529 · googleapis/google-cloud-python
X Title: Storing an Entity as an indexed property value always fails · Issue #529 · googleapis/google-cloud-python
Description: From the spec: If a value is itself an entity, it cannot have indexed set to true. This means when the entity_value is added we should set indexed to False on the property. (This is currently not easy, see #403, #404 and #512.) Or maybe ...
Open Graph Description: From the spec: If a value is itself an entity, it cannot have indexed set to true. This means when the entity_value is added we should set indexed to False on the property. (This is currently not e...
X Description: From the spec: If a value is itself an entity, it cannot have indexed set to true. This means when the entity_value is added we should set indexed to False on the property. (This is currently not e...
Opengraph URL: https://github.com/googleapis/google-cloud-python/issues/529
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Storing an Entity as an indexed property value always fails","articleBody":"From the [spec](https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/21e029b2657ebb15fef5429c90c4315326855fd1/proto/datastore_v1.proto#L142-L144):\n\n\u003e If a value is itself an entity, it cannot have `indexed` set to `true`.\n\nThis means when the `entity_value` is [added](https://github.com/GoogleCloudPlatform/gcloud-python/blob/0525530ad7a76e408ca2e842b883d49c353ed56d/gcloud/datastore/helpers.py#L245) we should set `indexed` to `False` on the property. (This is currently not easy, see #403, #404 and #512.)\n\nOr maybe we should just document that users need to add a property name to `exclude_from_indexes` if that property is an `Entity`.\n\n---\n\nTo replicate:\n\n``` python\n\u003e\u003e\u003e import os\n\u003e\u003e\u003e from gcloud import datastore\n\u003e\u003e\u003e from gcloud.datastore.entity import Entity\n\u003e\u003e\u003e from gcloud.datastore.key import Key\n\u003e\u003e\u003e \n\u003e\u003e\u003e datastore.set_default_connection()\n\u003e\u003e\u003e dataset_id = os.getenv('GCLOUD_TESTS_DATASET_ID')\n\u003e\u003e\u003e datastore.set_default_dataset_id(dataset_id)\n\u003e\u003e\u003e \n\u003e\u003e\u003e e = Entity(key=Key('Foo', 1))\n\u003e\u003e\u003e e2 = Entity(key=Key('Foo', 2))\n\u003e\u003e\u003e e['bar'] = e2\n\u003e\u003e\u003e e.save()\nTraceback (most recent call last):\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n File \"gcloud/datastore/entity.py\", line 144, in save\n exclude_from_indexes=self.exclude_from_indexes)\n File \"gcloud/datastore/connection.py\", line 495, in save_entity\n result = self.commit(dataset_id, mutation)\n File \"gcloud/datastore/connection.py\", line 376, in commit\n datastore_pb.CommitResponse)\n File \"gcloud/datastore/connection.py\", line 100, in _rpc\n data=request_pb.SerializeToString())\n File \"gcloud/datastore/connection.py\", line 77, in _request\n raise six.moves.http_client.HTTPException(message)\nhttplib.HTTPException: Request failed with status code 400.\n Error was: Entity value is indexed.\n```\n\nand notice it doesn't fail if the property is correctly unindexed:\n\n``` python\n\u003e\u003e\u003e e = Entity(key=Key('Foo', 1), exclude_from_indexes=('bar',))\n\u003e\u003e\u003e e['bar'] = e2\n\u003e\u003e\u003e e.save()\n\u003e\u003e\u003e e.key.delete()\n```\n","author":{"url":"https://github.com/dhermes","@type":"Person","name":"dhermes"},"datePublished":"2015-01-09T18:50:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/529/google-cloud-python/issues/529"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0c554f74-a427-e78c-12e8-df81f19c4e31 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A1A:15BB0E:12601A5:18F9ADD:6A4D6E1D |
| html-safe-nonce | 5a0506cd18b066dd850e09ff17f4e9d62cb7f9ac2419363e14586194a0dd17bc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTFBOjE1QkIwRToxMjYwMUE1OjE4RjlBREQ6NkE0RDZFMUQiLCJ2aXNpdG9yX2lkIjoiNDA1OTAzMjAyNjgxNjAxNTkwMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f014fcf36df9ad2c7da6aacbcd7c0252de645b1c60ed9c0c6fef728ee81698b2 |
| hovercard-subject-tag | issue:53901059 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-cloud-python/529/issue_layout |
| twitter:image | https://opengraph.githubassets.com/549f76b2f17fa831f0a4d452b37dc76929fe8cf78521b10679ca968a4fcba396/googleapis/google-cloud-python/issues/529 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/549f76b2f17fa831f0a4d452b37dc76929fe8cf78521b10679ca968a4fcba396/googleapis/google-cloud-python/issues/529 |
| og:image:alt | From the spec: If a value is itself an entity, it cannot have indexed set to true. This means when the entity_value is added we should set indexed to False on the property. (This is currently not e... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dhermes |
| hostname | github.com |
| expected-hostname | github.com |
| None | c78260c7b3f4ac4b0356c8208537f05406a3a2d46a9ec3f735b372dcc519c39e |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/google-cloud-python git https://github.com/googleapis/google-cloud-python.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 16316451 |
| octolytics-dimension-repository_nwo | googleapis/google-cloud-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16316451 |
| octolytics-dimension-repository_network_root_nwo | googleapis/google-cloud-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 399fff412f48461d435721c009efc17ea44be72f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width