Skip to content
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

property has list_value and don't want to index will raise exception #398

Closed
lucemia opened this issue Dec 2, 2014 · 9 comments
Closed
Assignees
Labels
api: datastore Issues related to the Datastore API. 🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@lucemia
Copy link
Contributor

lucemia commented Dec 2, 2014

if a property is list_value and the property name is included in exclude_from_indexes
the following exception will raise.

The protobuf file has describe this behavior

// A list value.
  // Cannot contain another list value.
  // Cannot also have a meaning and indexing set.
  repeated Value list_value = 7;

https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/v1beta2-rev1-2.1.0/proto/datastore_v1.proto#L123

 File "/usr/local/lib/python2.7/dist-packages/gcloud/datastore/entity.py", line 244, in save
    exclude_from_indexes=self.exclude_from_indexes())
  File "/usr/local/lib/python2.7/dist-packages/gcloud/datastore/connection.py", line 425, in save_entity
    result = self.commit(dataset_id, mutation)
  File "/usr/local/lib/python2.7/dist-packages/gcloud/datastore/connection.py", line 329, in commit
    datastore_pb.CommitResponse)
  File "/usr/local/lib/python2.7/dist-packages/gcloud/datastore/connection.py", line 81, in _rpc
    data=request_pb.SerializeToString())
  File "/usr/local/lib/python2.7/dist-packages/gcloud/datastore/connection.py", line 59, in _request
    raise Exception('Request failed. Error was: %s' % content)
Exception: Request failed. Error was: A Value containing a list_value cannot specify indexed.

An example

entity = Dataset(dataset, kind, exclude_from_indexes=('a',))
entity['a'] = [1,2,3]
entity.save()
@dhermes
Copy link
Contributor

dhermes commented Dec 2, 2014

/cc @pcostell

The error message seems strange since a is excluded. Though maybe it is referring to the property in general.

Also I'm curious why lists can't be indexed. IIRC a query like

class Foo(ndb.Model):
    bar = ndb.StringProperty(repeated=True)

q = Foo.query(Foo.bar == 10)

works just fine.

@pcostell
Copy link
Contributor

pcostell commented Dec 2, 2014

Unlike Cloud Datastore, the App Engine datastore just uses repeated values as opposed to a list_value. I believe each value of 'a' should specify if it can be indexed or not, for example:

{  
  key: ...
  data: { 
    list_value {
      value {
        string_value: "hi",
        indexed: False
      },
      value {
         integer_value: 12,
         indexed: False
      }
    }
  }
}

@tseaver
Copy link
Contributor

tseaver commented Dec 3, 2014

The protobuf spec says that items in a list_values "[c]annot also have a meaning and indexing set."

@pcostell
Copy link
Contributor

pcostell commented Dec 3, 2014

I think the spec is actually saying that list_value cannot have a meaning and indexing set. The Value's inside can have indexing set. I'll be sure to tweak the protobuf spec to be more clear.

@tseaver
Copy link
Contributor

tseaver commented Dec 3, 2014

I bow to your knowledge of the backend. Note that having the items in the list declare their indexing directly seems completely counter-intuitive to me.

@dhermes
Copy link
Contributor

dhermes commented Dec 4, 2014

@pcostell ISTM we have a choice here to support a set of repeated values or a list_value. In our current implementation, the user doesn't select, we just imply list_value from the type of the value.

When and where would an end user decide if they wanted to use one or the other?

@pcostell
Copy link
Contributor

pcostell commented Dec 4, 2014

@dhermes -- In Cloud Datastore list_value is the only option. Putting an entity with the same property multiple times will result in an error.

@dhermes
Copy link
Contributor

dhermes commented Dec 30, 2014

@tseaver Did #399 fully fix this? ISTM it did, but want to double-check.

@dhermes dhermes added the api: datastore Issues related to the Datastore API. label Dec 30, 2014
@tseaver
Copy link
Contributor

tseaver commented Dec 31, 2014

Via #399.

@tseaver tseaver closed this as completed Dec 31, 2014
@jgeewax jgeewax modified the milestone: Datastore Stable Jan 30, 2015
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
parthea pushed a commit that referenced this issue Jun 4, 2023
…p/templates/python_library/.kokoro (#398)

Source-Link: https://github.com/googleapis/synthtool/commit/bb171351c3946d3c3c32e60f5f18cee8c464ec51
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f62c53736eccb0c4934a3ea9316e0d57696bb49c1a7c86c726e9bb8a2f87dadf
vchudnov-g pushed a commit that referenced this issue Sep 20, 2023
- [ ] Regenerate this pull request now.

fix: add 'dict' annotation type to 'request'

Committer: @busunkim96
PiperOrigin-RevId: 398509016

Source-Link: googleapis/googleapis@b224dfa

Source-Link: googleapis/googleapis-gen@63a1db7
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNjNhMWRiN2EzOGQ3NGI5NjM5NTkyZjUyMWVkMWRhYWY3Mjk5YWQ5YSJ9
parthea pushed a commit that referenced this issue Sep 22, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Sep 22, 2023
…398)

Source-Link: googleapis/synthtool@395d53a
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:6c1cbc75c74b8bdd71dada2fa1677e9d6d78a889e9a70ee75b93d1d0543f96e1

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Sep 22, 2023
Co-authored-by: meredithslota <[email protected]>
Co-authored-by: Lo Ferris <[email protected]>
parthea pushed a commit that referenced this issue Sep 22, 2023
* docs: Add documentation for enums

fix: Add context manager return types

chore: Update gapic-generator-python to v1.8.1
PiperOrigin-RevId: 503210727

Source-Link: googleapis/googleapis@a391fd1

Source-Link: googleapis/googleapis-gen@0080f83
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDA4MGY4MzBkZWMzN2MzMzg0MTU3MDgyYmNlMjc5ZTM3MDc5ZWE1OCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Oct 21, 2023
* fix: Add async context manager return types

chore: Mock return_value should not populate oneof message fields

chore: Support snippet generation for services that only support REST transport

chore: Update gapic-generator-python to v1.11.0
PiperOrigin-RevId: 545430278

Source-Link: googleapis/googleapis@601b532

Source-Link: googleapis/googleapis-gen@b3f18d0
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjNmMThkMGY2NTYwYTg1NTAyMmZkMDU4ODY1ZTc2MjA0NzlkN2FmOSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea added a commit that referenced this issue Oct 21, 2023
* chore(deps): update all dependencies

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* revert

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

6 participants