Skip to content

Encountering issues with multiqueries ordered by key #629

@Primevenn

Description

@Primevenn

Hi there!

I have encountered an issue trying order by Key where I get the following error:

ValueError: Value protobuf did not have any value set

I've narrowed it down to the _compare method within _datastore_query.py
It seems it does not cater for ordering by key (order.name=__ key __)
Additionally, looking into helpers._get_value_from_value_pb(), a Key object is returned for
key_value properties but they are not compared based on their paths.

Steps to reproduce

  1. Produce a Multiquery and order by key.
query = (
        SomeKind.query()
        .order(SomeKind.key)
        .filter(ndb.OR(SomeKind.foo == 4, SomeKind.foo == 3, SomeKind.foo == 1))
    )

Stack trace

  File "/Users/mwolanski001/.virtualenvs/venn/lib/python2.7/site-packages/google/cloud/ndb/query.py", line 1214, in wrapper
    return wrapped(self, *dummy_args, _options=query_options)
  File "/Users/mwolanski001/.virtualenvs/venn/lib/python2.7/site-packages/google/cloud/ndb/utils.py", line 114, in wrapper
    return wrapped(*args, **new_kwargs)
  File "/Users/mwolanski001/.virtualenvs/venn/lib/python2.7/site-packages/google/cloud/ndb/utils.py", line 146, in positional_wrapper
    return wrapped(*args, **kwds)
  File "/Users/mwolanski001/.virtualenvs/venn/lib/python2.7/site-packages/google/cloud/ndb/query.py", line 1736, in fetch
    return self.fetch_async(_options=kwargs["_options"]).result()
  File "/Users/mwolanski001/.virtualenvs/venn/lib/python2.7/site-packages/google/cloud/ndb/tasklets.py", line 191, in result
    self.check_success()
  File "/Users/mwolanski001/.virtualenvs/venn/lib/python2.7/site-packages/google/cloud/ndb/tasklets.py", line 138, in check_success
    raise self._exception
ValueError: Value protobuf did not have any value set

Thanks for your time!

Metadata

Metadata

Assignees

Labels

api: datastoreIssues related to the googleapis/python-ndb API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions