Title: datastore: Nested entity parsing fails · Issue #616 · googleapis/google-cloud-python · GitHub
Open Graph Title: datastore: Nested entity parsing fails · Issue #616 · googleapis/google-cloud-python
X Title: datastore: Nested entity parsing fails · Issue #616 · googleapis/google-cloud-python
Description: https://cloud.google.com/appengine/docs/python/ndb/properties#structured In order to write entities with structured properties, I tried to read them first, to figure out the format. First StructuredProperty. class Item_Meta(ndb.Model): x...
Open Graph Description: https://cloud.google.com/appengine/docs/python/ndb/properties#structured In order to write entities with structured properties, I tried to read them first, to figure out the format. First Structure...
X Description: https://cloud.google.com/appengine/docs/python/ndb/properties#structured In order to write entities with structured properties, I tried to read them first, to figure out the format. First Structure...
Opengraph URL: https://github.com/googleapis/google-cloud-python/issues/616
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"datastore: Nested entity parsing fails","articleBody":"https://cloud.google.com/appengine/docs/python/ndb/properties#structured\n\nIn order to write entities with structured properties, I tried to read them first, to figure out the format.\n\nFirst `StructuredProperty`.\n\n``` Python\nclass Item_Meta(ndb.Model):\n xy = ndb.IntegerProperty(repeated = True)\n\nclass Item(ndb.Model):\n meta = ndb.StructuredProperty(Item_Meta)\n\nitem = Item()\nitem.meta = Item_Meta(xy = [100, 200])\nitem.put() # 5710239819104256\n```\n\n``` Python\n\u003e\u003e\u003e datastore.api.get([datastore.Key('Item', 5710239819104256)])\n[\u003cEntity[{'kind': u'Item', 'id': 5710239819104256L}] {u'meta.xy': [100L, 200L]}\u003e]\n```\n\nNext `LocalStructuredProperty`.\n\n\u003e Although a `StructuredProperty` can be repeated and a `StructuredProperty` can contain another `StructuredProperty`, beware: if one structured property contains another, only one of them can be repeated. A work-around is to use `LocalStructuredProperty`, which does not have this constraint.\n\n``` Python\nclass Item_Meta(ndb.Model):\n xy = ndb.IntegerProperty(repeated = True)\n\nclass Item(ndb.Model):\n meta = ndb.LocalStructuredProperty(Item_Meta, repeated = True)\n\nitem = Item()\nitem.meta = [Item_Meta(xy = [100, 200])]\nitem.put() # 6217263929622528\n```\n\n``` Python\n\u003e\u003e\u003e datastore.api.get([datastore.Key('Item', 6217263929622528)])\nTraceback (most recent call last):\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n File \"/home/user/.local/lib/python2.7/site-packages/gcloud/datastore/api.py\", line 229, in get\n entities.append(helpers.entity_from_protobuf(entity_pb))\n File \"/home/user/.local/lib/python2.7/site-packages/gcloud/datastore/helpers.py\", line 53, in entity_from_protobuf\n value = _get_value_from_property_pb(property_pb)\n File \"/home/user/.local/lib/python2.7/site-packages/gcloud/datastore/helpers.py\", line 237, in _get_value_from_property_pb\n return _get_value_from_value_pb(property_pb.value)\n File \"/home/user/.local/lib/python2.7/site-packages/gcloud/datastore/helpers.py\", line 217, in _get_value_from_value_pb\n result = [_get_value_from_value_pb(x) for x in value_pb.list_value]\n File \"/home/user/.local/lib/python2.7/site-packages/gcloud/datastore/helpers.py\", line 214, in _get_value_from_value_pb\n result = entity_from_protobuf(value_pb.entity_value)\n File \"/home/user/.local/lib/python2.7/site-packages/gcloud/datastore/helpers.py\", line 48, in entity_from_protobuf\n key = key_from_protobuf(pb.key)\n File \"/home/user/.local/lib/python2.7/site-packages/gcloud/datastore/helpers.py\", line 105, in key_from_protobuf\n return Key(*path_args, namespace=namespace, dataset_id=dataset_id)\n File \"/home/user/.local/lib/python2.7/site-packages/gcloud/datastore/key.py\", line 76, in __init__\n self._path = self._combine_args()\n File \"/home/user/.local/lib/python2.7/site-packages/gcloud/datastore/key.py\", line 133, in _combine_args\n child_path = self._parse_path(self._flat_path)\n File \"/home/user/.local/lib/python2.7/site-packages/gcloud/datastore/key.py\", line 94, in _parse_path\n raise ValueError('Key path must not be empty.')\nValueError: Key path must not be empty.\n```\n","author":{"url":"https://github.com/pdknsk","@type":"Person","name":"pdknsk"},"datePublished":"2015-02-11T00:18:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/616/google-cloud-python/issues/616"}
| 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:cce4745e-107c-75de-a0f5-b67aa4319482 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 81C4:354450:2DF91A:3D283D:6A4D8CE2 |
| html-safe-nonce | 79f86e87777708ea09feb67fcc142dedbc44ccf06570113c837586d3565d1aff |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MUM0OjM1NDQ1MDoyREY5MUE6M0QyODNEOjZBNEQ4Q0UyIiwidmlzaXRvcl9pZCI6Ijg2NzY2NTEzNDkyODkzMDczNjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 94b01ecb46d6762ceb019d757c23b56a3e5b3abdbb7c61b1aed7c0f353583c12 |
| hovercard-subject-tag | issue:57259312 |
| 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/616/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e72c76d2607b85b0007acff8a7a512e5ae712aed6a8ef779a99c848f74bd01a8/googleapis/google-cloud-python/issues/616 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e72c76d2607b85b0007acff8a7a512e5ae712aed6a8ef779a99c848f74bd01a8/googleapis/google-cloud-python/issues/616 |
| og:image:alt | https://cloud.google.com/appengine/docs/python/ndb/properties#structured In order to write entities with structured properties, I tried to read them first, to figure out the format. First Structure... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pdknsk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9f8758a3953dfe943439713a6fa4f90d542a3431f10e861ca03dd7f39009f320 |
| 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 | bffd5484f01713a661b03469b77678f72b6574ed |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width