Bug in the mongodb datastore stub handling ListProperties

5 views
Skip to first unread message

Joaquin Cuenca Abela

unread,
Nov 19, 2010, 2:42:38 PM11/19/10
to typhoonae
Hi,

I found a bug in the mongodb datastore. In _Dynamic_RunQuery there is
this comment:

# HACK we need to get one Entity from this collection so we know what the
# property types are (because we need to construct queries that depend on
# the types of the properties)...

And we get it with:

prototype = self.__db[collection].find_one()

This fails if we do a query with a filter on a list property on a
collection where the element that find_one returns has no such
property.
For example, if we have:

=====================
class Numbers(db.Model):
values = db.ListProperty(int)

Numbers().put()
Numbers(values=[0, 1, 2, 3]).put()
Numbers(values=[4, 5, 6, 7]).put()
=====================

The first entity "Numbers" doesn't have a values property, and thus
any query that uses values will fail. I updated the test case to make
it fail on this error, but I don't know how to fix it.

Any ideas?

--
Joaquin Cuenca Abela

Tobias

unread,
Nov 19, 2010, 3:39:36 PM11/19/10
to typhoonae
Hi Joaquin,

Unfortunately, this is a serious one. It also makes it impossible to
use Expando.

This problem is due to the fact that we translate Datastore entities
to MongoDB documents. One possible solution might be to introduce
another collection which holds the encoded protocol buffers of our
entities and keep the documents for indexing/querying only. This means
a rewrite of large portions of the Datastore Mongo stub. A very
valuable, though challenging task.

Another way could be to introspect the model class definition.

- Tobias

On Nov 19, 8:42 pm, Joaquin Cuenca Abela <joaq...@cuencaabela.com>
wrote:
Reply all
Reply to author
Forward
0 new messages