Skip to content

Commit

Permalink
Checking in test for complex subqueries
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed Nov 25, 2010
1 parent 575b83f commit 7417297
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests.py
Expand Up @@ -940,6 +940,26 @@ def test_subquery(self):
# this should work the same
some_tags = EntryTag.select().where(entry__in=some_entries)
self.assertEqual(list(some_tags), [a_tag, b_tag])

def test_complex_subquery(self):
a_blog = Blog.create(title='a blog')
b_blog = Blog.create(title='b blog')
c_blog = Blog.create(title='c blog')

a = User.create(username='a', blog=a_blog)
b = User.create(username='b', blog=b_blog)
c = User.create(username='c', blog=c_blog)

some_users = User.select().where(username__in=['a', 'b'])

c_blog_qr = Blog.select().join(User).where(~Q(id__in=some_users))
self.assertEqual(list(c_blog_qr), [c_blog])

ac_blog_qr = Blog.select().join(User).where(
~Q(id__in=some_users) |
Q(username='a')
)
self.assertEqual(list(ac_blog_qr), [a_blog, c_blog])


class FieldTypeTests(BasePeeweeTestCase):
Expand Down

0 comments on commit 7417297

Please sign in to comment.