Skip to content

Commit

Permalink
CR: just use class method (Query().into -> Query.into)
Browse files Browse the repository at this point in the history
  • Loading branch information
edvardm committed Feb 26, 2024
1 parent 8822c88 commit 1d8b141
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pypika/tests/test_inserts.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,24 @@ class InsertIntoWithDict(unittest.TestCase):
table_abc = Table("abc")

def test_inserting_simple_dictionary(self):
q = Query().into(self.table_abc).insert_dict({"c1": "value", "c2": 1})
q = Query.into(self.table_abc).insert_dict({"c1": "value", "c2": 1})
self.assertEqual("INSERT INTO \"abc\" (\"c1\",\"c2\") VALUES ('value',1)", str(q))

def test_inserting_dictionary_goes_through_value_quoting_logic(self):
q = Query().into(self.table_abc).insert_dict({"num": 1, "timestamp": datetime(2023, 4, 18)})
q = Query.into(self.table_abc).insert_dict({"num": 1, "timestamp": datetime(2023, 4, 18)})
self.assertEqual("INSERT INTO \"abc\" (\"num\",\"timestamp\") VALUES (1,'2023-04-18T00:00:00')", str(q))

def test_inserting_dictionary_produces_builder(self):
q = Query().into(self.table_abc).insert_dict({"num": 1, "timestamp": datetime(2023, 4, 18)})
q = Query.into(self.table_abc).insert_dict({"num": 1, "timestamp": datetime(2023, 4, 18)})
q = q.insert(2, datetime(2023, 4, 19))
self.assertEqual("INSERT INTO \"abc\" (\"num\",\"timestamp\") VALUES (1,'2023-04-18T00:00:00'),(2,'2023-04-19T00:00:00')", str(q))

def test_columns_is_not_allowed_with_insert_dict(self):
with self.assertRaises(QueryException):
Query().into(self.table_abc).columns("a", "b").insert_dict({"num": 1})
Query.into(self.table_abc).columns("a", "b").insert_dict({"num": 1})

with self.assertRaises(QueryException):
Query().into(self.table_abc).insert_dict({"num": 1}).columns("a", "b")
Query.into(self.table_abc).insert_dict({"num": 1}).columns("a", "b")

class PostgresInsertIntoOnConflictTests(unittest.TestCase):
table_abc = Table("abc")
Expand Down

0 comments on commit 1d8b141

Please sign in to comment.