]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix unit tests
authorCristian Sabaila <cristian.sabaila@geotogether.com>
Tue, 2 Nov 2021 23:01:42 +0000 (01:01 +0200)
committerCristian Sabaila <cristian.sabaila@geotogether.com>
Tue, 2 Nov 2021 23:01:42 +0000 (01:01 +0200)
test/dialect/mysql/test_compiler.py
test/dialect/mysql/test_on_duplicate.py

index a6ead333fa5062609c051fe3ff2577b3bfee43cf..ad1c16edfdf4e04ce5e88875699bed202ca9e1a5 100644 (file)
@@ -1115,7 +1115,7 @@ class InsertOnDuplicateTest(fixtures.TestBase, AssertsCompiledSQL):
         expected_sql = (
             "INSERT INTO foos (id, bar) VALUES (%s, %s), (%s, %s) ON "
             "DUPLICATE KEY UPDATE bar = coalesce(VALUES(bar)), "
-            "baz = (concat(VALUES(bar), %s, VALUES(baz)))"
+            "baz = (concat(VALUES(baz), %s, VALUES(bar)))"
         )
         self.assert_compile(
             stmt,
index 4c8307d9077bd8aca6823fed4fe6fac353063bd1..544227af705152109fe86da306892d5d305a62bc 100644 (file)
@@ -101,17 +101,19 @@ class OnDuplicateTest(fixtures.TablesTest):
         stmt = insert(foos).values([dict(id=1, bar="ab"), dict(id=2, bar="b")])
         stmt = stmt.on_duplicate_key_update(
             bar=func.concat(stmt.inserted.bar, "_foo"),
-            baz=func.concat(stmt.inserted.bar, foos.baz),
+            baz=func.concat(stmt.inserted.bar, "_", foos.c.baz),
         )
         result = conn.execute(stmt)
         eq_(result.inserted_primary_key, (None,))
+        # first entry triggers ON DUPLICATE
         eq_(
             conn.execute(foos.select().where(foos.c.id == 1)).fetchall(),
             [(1, "ab_foo", "ab_bz", False)],
         )
+        # second entry should be an insert
         eq_(
-            conn.execute(foos.select().where(foos.c.id == 1)).fetchall(),
-            [(2, "b_foo", "b_bz", False)],
+            conn.execute(foos.select().where(foos.c.id == 2)).fetchall(),
+            [(2, "b", None, False)],
         )
 
     def test_on_duplicate_key_update_preserve_order(self, connection):