strange query results

36 views
Skip to first unread message

Nicanor Babula

unread,
Jun 11, 2012, 10:42:28 AM6/11/12
to google-a...@googlegroups.com
Hi everyone,

I am experiencing some problems executing a certain query on the datastore. 

In this particular case, I want to retreieve all TreatmentPlanDetails of with a certain accountId, having the status = 'done', the category = 'chirurgia orale' having been set to 'done' between 6 june 2012 and 11 june 2012 and with deleteStatus = 'notDeleted'.

For instance, if I execute:
SELECT * FROM TreatmentPlanDetails 
WHERE 
   accountId = 'ag5zfmRvbW9kZW50d2ViMnIRCxIIQWNjb3VudHMYtcjdAQw' AND 
   status = 'done' AND 
   setDoneCalendarEventStartTimestamp >= [timestamp for 6 june 2012]  AND 
   setDoneCalendarEventStartTimestamp <= [timestamp for 11 june 2012]  AND 
   deleteStatus = 'notDeleted' 
ORDER BY setDoneCalendarEventStartTimestamp ASC
(not filtering by category)

I will get record A, B and C, where A and B has category = 'chirurgia orale' and C has category = 'altro'.
If I want to get only the records having category = 'chirurgia orale', I would simply run:

SELECT * FROM TreatmentPlanDetails 
WHERE 
   accountId = 'ag5zfmRvbW9kZW50d2ViMnIRCxIIQWNjb3VudHMYtcjdAQw' AND 
   status = 'done' AND 
   category = 'chirurgia orale'
   setDoneCalendarEventStartTimestamp >= [timestamp for 6 june 2012]  AND 
   setDoneCalendarEventStartTimestamp <= [timestamp for 11 june 2012]  AND 
   deleteStatus = 'notDeleted' 
ORDER BY setDoneCalendarEventStartTimestamp ASC
(filtering by category)

Only that in this case I don't get any result. I struggled around for a couple of hours and I found out I would have to substract 1 millisecond to the first timestamp filter and add 1 millisecond to the second one in order to get record A and B. Why is that happening? It doesn't make any sense.

Appid: domodentweb2
datastore: HRD
appengine-java
low-level datastore api.

Thanks in advance,
Cristian.

Nicanor Babula

unread,
Jun 14, 2012, 6:10:58 AM6/14/12
to google-a...@googlegroups.com
Anyone?
Reply all
Reply to author
Forward
0 new messages