Skip to content

Commit

Permalink
Split test test_where_field_equals_for_update_all into _of_nowait and…
Browse files Browse the repository at this point in the history
… _of_skip_locked
  • Loading branch information
squareapartments committed Jul 15, 2021
1 parent 2e8f822 commit 1c1515b
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions pypika/tests/test_selects.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def test_where_field_equals_for_update_of_multiple_tables(self):
],
)

def test_where_field_equals_for_update_all(self):
def test_where_field_equals_for_update_of_nowait(self):
for query_cls in [
MySQLQuery,
PostgreSQLQuery,
Expand All @@ -479,7 +479,7 @@ def test_where_field_equals_for_update_all(self):
query_cls.from_(self.t)
.select("*")
.where(self.t.foo == self.t.bar)
.for_update(nowait=True, skip_locked=True, of=("abc",))
.for_update(of=("abc",), nowait=True)
)
quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"'
self.assertEqual(
Expand All @@ -492,6 +492,28 @@ def test_where_field_equals_for_update_all(self):
str(q),
)

def test_where_field_equals_for_update_of_skip_locked(self):
for query_cls in [
MySQLQuery,
PostgreSQLQuery,
]:
q = (
query_cls.from_(self.t)
.select("*")
.where(self.t.foo == self.t.bar)
.for_update(of=("abc",), skip_locked=True)
)
quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"'
self.assertEqual(
'SELECT * '
'FROM {quote_char}abc{quote_char} '
'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} '
'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format(
quote_char=quote_char,
),
str(q),
)

def test_where_field_equals_for_update_skip_locked_and_of(self):
for query_cls in [
MySQLQuery,
Expand Down

0 comments on commit 1c1515b

Please sign in to comment.