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), )
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))
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))
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))