cobrateam / flask-mongoalchemy

Flask support for MongoDB using MongoAlchemy.
https://pythonhosted.org/Flask-MongoAlchemy/
BSD 2-Clause "Simplified" License
217 stars 45 forks source link

get and get_or_404 do never return object #14

Closed jkur closed 13 years ago

jkur commented 13 years ago

I don't know exactly if it is in Flask-MongoAlchemy or in MongoAlchemy, but the filtering for mongo_id does not work correctly. To get a single object referenced by it's id, one would use:

 SomeDocument.get_or_404( 'mongoidstring')

This query does always return 'None' (doesn't exists a test for this?) Internally the get method is mapped to .filter( { 'mongo_id': 'mongoidstring'} ).first()

This does somehow not work, not even with pure MongoAlchemy. What actually works is .filter( SomeDocument.mongo_id == 'mongoidstring' )

I'm using MongoAlchemy 0.8 and Flask-MongoAlchemy 0.3 Both installed with easy_install.

fsouza commented 13 years ago

Just confirmed this bug. I'm going to work on this later today :)

Thank you so much.