Skip to content

Commit

Permalink
use raw sql for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
circulon committed Sep 10, 2024
1 parent 7e07531 commit 10e6478
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/mysql/model/test_model_scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ class User(Model, SoftDeletesMixin):

class TestModelScopes(unittest.TestCase):
def test_find_with_global_scope(self):
user_where = User.where("id", 1).to_sql()
user_find = User.find("1", query=True)
self.assertEqual(user_where, user_find)
find_sql = User.find("1", query=True).to_sql()
raw_sql = """SELECT * FROM `users` WHERE `users`.`id` = '1' AND `users`.`deleted_at` IS NULL"""
self.assertEqual(find_sql, raw_sql)

def test_find_with_trashed_scope(self):
user_where = User.with_trashed().where("id", 1).to_sql()
user_find = User.with_trashed().find("1", query=True)
self.assertEqual(user_where, user_find)
find_sql = User.with_trashed().find("1", query=True).to_sql()
raw_sql = """SELECT * FROM `users` WHERE `users`.`id` = '1'"""
self.assertEqual(find_sql, raw_sql)

def test_find_with_only_trashed_scope(self):
user_where = User.only_trashed().where("id", 1).to_sql()
user_find = User.only_trashed().find("1", query=True)
self.assertEqual(user_where, user_find)
find_sql = User.only_trashed().find("1", query=True).to_sql()
raw_sql = """SELECT * FROM `users` WHERE `users`.`deleted_at` IS NOT NULL AND `users`.`id` = '1'"""
self.assertEqual(find_sql, raw_sql)

0 comments on commit 10e6478

Please sign in to comment.