ReferenceField query chaining fails #234

Closed
rozza opened this Issue Feb 20, 2013 · 2 comments

Projects

None yet

2 participants

@rozza
Contributor
rozza commented Feb 20, 2013

See: http://stackoverflow.com/questions/14901598/mongoengine-chaining-filter-and-referencefield-causes-typeerror-collectio

def test_reference_query_chaining(self):

    class A(Document):
        a = StringField()

    class B(Document):
        b = StringField()
        boolfield = BooleanField(default=False)
        ref = ReferenceField(A)

    A.drop_collection()
    B.drop_collection()

    a = A(a='test').save()
    B(b="hi", boolfield=True, ref=a).save()

    a_objects = A.objects(a='test')
    query = B.objects(ref__in=a_objects)
    query = query.filter(boolfield=True)
    self.assertEquals(query.count(), 1)
@Gerrrr
Contributor
Gerrrr commented Mar 18, 2013
@rozza
Contributor
rozza commented Apr 12, 2013

Merged fix

@rozza rozza closed this Apr 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment