Closed GoogleCodeExporter closed 8 years ago
Interesting bug, thanks for the report. First the bad news: The datastore does
not
support sorting by the id component of the key (or the name component for that
matter). The bug is that we're not detecting that you're trying to sort by the
id
component of the key - we should be throwing an exception. Instead, we just
pass
loID through to the query. As for the intermittent failures, I think I know
what's
going on. If your first access of the list is a call to isEmpty() or size() we
issue a
count() query. A count() query ignores sort orders, so the fact that you're
trying to
order the list by a property that the datastore doesn't know about it doesn't
matter
and you get the correct answer. However, if you then try to access an element
of the
list we reissue the query, this time with the requested sort order. Since none
of the
entities in the datastore have a property named loID, no entities match and the
result
of the query is empty. Wild.
Now the good news. Since User is always a top-level entity for you, there
should be
no difference between sorting by the encoded key and sorting by the id
component
of that string - both orderings are stable and semi-arbitrary. I'll get this
fixed, but if
you switch to sorting by encoded key (as you've already discovered) you should
be
fine.
Thanks,
Max
Original comment by max.r...@gmail.com
on 13 Jan 2010 at 9:32
Updating the issue title to better reflect the underlying problem
Original comment by max.r...@gmail.com
on 13 Jan 2010 at 9:47
Original comment by max.r...@gmail.com
on 14 Jan 2010 at 5:56
Boy, that was quick Max. Thanks!
Original comment by IanMarsh...@gmail.com
on 14 Jan 2010 at 7:32
Original comment by max.r...@gmail.com
on 26 Jan 2010 at 12:17
Original comment by max.r...@gmail.com
on 26 May 2011 at 11:21
Original issue reported on code.google.com by
IanMarsh...@gmail.com
on 13 Jan 2010 at 10:15