This repository was archived by the owner on Nov 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
This repository was archived by the owner on Nov 13, 2021. It is now read-only.
order_by datetime #20
Copy link
Copy link
Open
Description
When I have a model like:
class Entry(Model):
published = props.DateTime(indexed=True)
My query (following the example @ https://anom.defn.io/quickstart.html?highlight=order_by)
return Entry.query().with_ancestor(Key(Feed, str(feed_id))) \
.order_by(Entry.published).run(limit=toreturn_count)
Will crash with:
...
File "/env/lib/python3.7/site-packages/anom/query.py", line 110, in __next__
return next(self._entities)
File "/env/lib/python3.7/site-packages/anom/query.py", line 149, in _get_entities
for batch in self._get_batches():
File "/env/lib/python3.7/site-packages/anom/query.py", line 118, in _get_batches
entities, self._options.cursor = adapter.query(self._query, self._options)
File "/env/lib/python3.7/site-packages/anom/adapters/datastore_adapter.py", line 179, in query
for entity in result_iterator:
File "/env/lib/python3.7/site-packages/google/api_core/page_iterator.py", line 212, in _items_iter
for page in self._page_iter(increment=False):
File "/env/lib/python3.7/site-packages/google/api_core/page_iterator.py", line 243, in _page_iter
page = self._next_page()
File "/env/lib/python3.7/site-packages/google/cloud/datastore/query.py", line 525, in _next_page
query_pb = self._build_protobuf()
File "/env/lib/python3.7/site-packages/google/cloud/datastore/query.py", line 464, in _build_protobuf
pb = _pb_from_query(self._query)
File "/env/lib/python3.7/site-packages/google/cloud/datastore/query.py", line 595, in _pb_from_query
if prop.startswith("-"):
AttributeError: 'DateTime' object has no attribute 'startswith'"
timestamp: "2020-02-13T03:54:57.553739Z"
}
I need to change my query to:
return Entry.query().with_ancestor(Key(Feed, str(feed_id))) \
.order_by('published').run(limit=toreturn_count)
or
return Entry.query().with_ancestor(Key(Feed, str(feed_id))) \
.order_by('-published').run(limit=toreturn_count)
Metadata
Metadata
Assignees
Labels
No labels