Just to say, the following query gives me the correct result:
entities = mymodel.all().order('myId').fetch(300)
keys = {}
while entities:
for obj in entities:
if obj.myId in keys.keys():
keys[obj.myId] = keys[obj.myId] + 1
else:
keys[obj.myId] = 1
entities = mymodel.all().order('myId').filter('myId >', entities
[-1].myId).fetch(300)
So why does the key-based query not work?
On Nov 15, 3:08 pm, bsb <[email protected]> wrote:
> I have the following code:
>
> entities = db.GqlQuery("SELECT __key__ FROM mymodel").fetch(300)
> keys = {}
> while entities:
> for key in entities:
> if key in keys.keys():
> keys[key] = keys[key] + 1
> else:
> keys[key] = 1
> entities = db.GqlQuery("SELECT __key__ FROM mymodel WHERE __key__
>
> > :1", entities[-1]).fetch(300)
>
> Now, the thing that I don't get is that when I look at the "keys"
> dictionary above, I get something like that:
>
> agxhcHBjYWRkeWxpdmVyHgsSD01vZGVsX21vYmlsZWFwcCIJMzM4Njk0OTU0DA 128
> agxhcHBjYWRkeWxpdmVyHgsSD01vZGVsX21vYmlsZWFwcCIJMzM4NzI2NTg4DA 139
> agxhcHBjYWRkeWxpdmVyHgsSD01vZGVsX21vYmlsZWFwcCIJMjg0OTQ4OTg1DA 1
>
> ie. some keys are fetched multiple times from the db? How is that
> possible? I must be making a simple mistake, but I don't find it. I
> read that all queries without exlicit ordering are ordered by __key__
> asc by default, so that shouldn't be the problem. What's wrong with my
> logic here?!
>
> I should say that all mymodel objects are created with
>
> obj = mymodel( key_name = 'some_unique_id', [...] )
>
> if that's of any significance.
>
> Thanks in advance,
> Benjamin
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=.