strange appengine query result

What am I doing wrong in this query?

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

I am not getting any record and I am sure there are records meeting the where clause conditions. To get the correct records I have to widen the timestamp interval by 1 millisecond. Is it normal? Furthermore, if I modify this query by removing the category filter, I am getting the correct results. This is definitely weird. I also asked on google groups, but I got no answer. Anyway, for details: https://groups.google.com/forum/?fromgroups#!searchin/google-appengine/query/google-appengine/ixPIvmhCS3g/d4OP91yTkrEJ

Upvotes: 0

Views: 100

Answers (3)

stevep
stevep

Reputation: 959

An aside that is not specific to your question: Entity property names count as part of your storage quota. If this is going to be a huge dataset, you might pay more $$ than you'd like for property names like setDoneCalendarEventStartTimestamp.

Upvotes: 1

Guido van Rossum
Guido van Rossum

Reputation: 16890

Let's talk specifically about creating timestamps to go into the query. What code are you using to create the timestamp record? Apparently that's important, because fuzzing with it a little bit affects the query. It may be relevant that in the datastore, timestamps are recorded as integers representing posix timestamps with microseconds, i.e. the number of microseconds since 1/1/1970 UTC (not counting leap seconds). It's also relevant that dates (i.e. without a time) are represented as midnight, i.e. the earliest time on that day. But please show us the exact code. (It may also be important to show the actual content of the record that you're attempting to retrieve.)

Upvotes: 1

koma
koma

Reputation: 6566

Because you write :

if I modify this query by removing the category filter, I am getting the correct results

this probably means that the category was not indexed at the time you write the matching records to the data store. You have to re-write your records to the data store if you want them added to the newly created index.

Upvotes: 0

Related Questions