Exemple #1
0
 def test_upsert(self):
     q = (SQLLiteQuery.into("abc").insert(
         1, "b",
         False).as_("aaa").on_conflict(self.table_abc.id).do_update("abc"))
     self.assertEqual(
         'INSERT INTO "abc" VALUES (1,\'b\',false) ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc"',
         str(q),
     )
Exemple #2
0
 def test_insert_or_replace(self):
     query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3")
     expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')"
     self.assertEqual(expected_output, str(query))
Exemple #3
0
 def test_insert_ignore(self):
     q = SQLLiteQuery.into("abc").insert(
         (1, "a", True)).on_conflict().do_nothing()
     self.assertEqual(
         "INSERT INTO \"abc\" VALUES (1,'a',true) ON CONFLICT DO NOTHING",
         str(q))
Exemple #4
0
 def test_replace_subquery(self):
     query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2"))
     expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))'
     self.assertEqual(expected_output, str(query))