Skip to content

Commit

Permalink
Removed some instances where I as prematurely normalizing field names…
Browse files Browse the repository at this point in the history
…, causing a failure to resolve a name when db_field is set
  • Loading branch information
Jeff Jenkins committed Dec 15, 2010
1 parent 9d27a35 commit 6ce34a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions mongoalchemy/query_expression.py
Expand Up @@ -108,15 +108,15 @@ def in_(self, *values):
in ``values``. Produces a MongoDB ``$in`` expression.
'''
return QueryExpression({
str(self) : { '$in' : [self.get_type().wrap_value(value) for value in values] }
self : { '$in' : [self.get_type().wrap_value(value) for value in values] }
})

def nin(self, *values):
''' A query to check if this query field is not one of the values
in ``values``. Produces a MongoDB ``$nin`` expression.
'''
return QueryExpression({
str(self) : { '$nin' : [self.get_type().wrap_value(value) for value in values] }
self : { '$nin' : [self.get_type().wrap_value(value) for value in values] }
})

def __str__(self):
Expand Down
11 changes: 10 additions & 1 deletion test/test_query.py
Expand Up @@ -298,4 +298,13 @@ def qr_test_clone():
it2.next()
except StopIteration:
pass


def test_resolve_fields():
class Resolver(Document):
i = IntField(db_field='j')
k = IntField()
s = get_session()
s.clear_collection(Resolver)

q = s.query(Resolver).filter(Resolver.i.in_(6))

0 comments on commit 6ce34a7

Please sign in to comment.