amnextking / typhoonae

Automatically exported from code.google.com/p/typhoonae
0 stars 0 forks source link

GQL query on list properties fails with MongoDB #40

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run a GQL query on a list property that uses an embeded object

What is the expected output? What do you see instead?

For example:

class MyModel(db.Model):
  emails = db.ListProperty(db.Email)

query = db.GqlQuery('SELECT * FROM MyModel WHERE emails = :1', 
'foo@example.com')

The mongo backend translates this query to the following filter spec:

{'emails.list': 'foo@example.com'}

which returns no results (assuming you already have an entity with 
foo@example.com in your MongoDB). For the case of a list of db.Emails the 
filter spec should be

{'emails.list.value': 'foo@example.com'}

to find the entities.

What version of the product are you using? On what operating system?

Current typhoonae checkout (2010-03-24).

Please provide any additional information below.

I've encountered this problem while experimenting with the Rietveld 
example. The issue list of a user executes such a query ("Issue reviewable 
by me").

Original issue reported on code.google.com by albrecht.andi on 24 Mar 2010 at 11:11

GoogleCodeExporter commented 9 years ago
Many thanks for reporting this and the excellent analysis! I'm planning to fix 
this compatibility issue soon.

As a workaround one can do following query:

db.GqlQuery('SELECT * FROM MyModel WHERE emails = :1', 
db.Email('foo@example.com'))

Original comment by tobias.r...@gmail.com on 24 Mar 2010 at 2:12

GoogleCodeExporter commented 9 years ago

Original comment by tobias.r...@gmail.com on 24 Mar 2010 at 2:12

GoogleCodeExporter commented 9 years ago
Thanks for the workaround! It works :)

Original comment by albrecht.andi on 24 Mar 2010 at 2:36