Skip to content

Commit

Permalink
Fixes #516
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed Jan 31, 2015
1 parent 2b7356c commit ba51659
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion peewee.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,8 @@ def clone_base(self, **kwargs):
if self._is_bound:
inst.name = self.name
inst.model_class = self.model_class
return inst
inst._is_bound = self._is_bound
return inst

def add_to_class(self, model_class, name):
"""
Expand Down
7 changes: 7 additions & 0 deletions playhouse/tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,13 @@ def test_where_negation(self):
sq = SelectQuery(Blog).where(~((Blog.title == 'foo') & (Blog.title == 'bar')) & ((Blog.title == 'baz') & (Blog.title == 'fizz')))
self.assertWhere(sq, '(NOT (("blog"."title" = ?) AND ("blog"."title" = ?)) AND (("blog"."title" = ?) AND ("blog"."title" = ?)))', ['foo', 'bar', 'baz', 'fizz'])

def test_where_negation_single_clause(self):
sq = SelectQuery(Blog).where(~Blog.title)
self.assertWhere(sq, 'NOT "blog"."title"', [])

sq = sq.where(Blog.pk > 1)
self.assertWhere(sq, '(NOT "blog"."title" AND ("blog"."pk" > ?))', [1])

def test_where_chaining_collapsing(self):
sq = SelectQuery(User).where(User.id == 1).where(User.id == 2).where(User.id == 3)
self.assertWhere(sq, '((("users"."id" = ?) AND ("users"."id" = ?)) AND ("users"."id" = ?))', [1, 2, 3])
Expand Down

0 comments on commit ba51659

Please sign in to comment.