summaryrefslogtreecommitdiff
path: root/test/dialect/mysql/test_on_duplicate.py
diff options
context:
space:
mode:
authorCristian Sabaila <cristian.sabaila@geotogether.com>2021-11-02 21:39:08 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-11-02 22:27:32 -0400
commit5740a843ed805d0b066b1e56e8bf3c584c32cf6b (patch)
tree601aaf9da436741c2692b08c406c0dd71a1396ee /test/dialect/mysql/test_on_duplicate.py
parent37bc1285c5bddf1e1b3a5830c530139e6fdd4bc4 (diff)
downloadsqlalchemy-5740a843ed805d0b066b1e56e8bf3c584c32cf6b.tar.gz
Fixed issue in visit_on_duplicate_key_update within a composed expression
Fixed issue in MySQL :meth:`_mysql.Insert.on_duplicate_key_update` which would render the wrong column name when an expression were used in a VALUES expression. Pull request courtesy Cristian Sabaila. Fixes: #7281 Closes: #7285 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7285 Pull-request-sha: 3e6ad6f2fecc6ae36a10a5a34b5d3d393483edbb Change-Id: I83377c20eae6358fead9e7e361127938e538a71c
Diffstat (limited to 'test/dialect/mysql/test_on_duplicate.py')
-rw-r--r--test/dialect/mysql/test_on_duplicate.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/test/dialect/mysql/test_on_duplicate.py b/test/dialect/mysql/test_on_duplicate.py
index 65d5b8364..5a4e6ca8d 100644
--- a/test/dialect/mysql/test_on_duplicate.py
+++ b/test/dialect/mysql/test_on_duplicate.py
@@ -100,13 +100,19 @@ class OnDuplicateTest(fixtures.TablesTest):
conn.execute(insert(foos).values(dict(id=1, bar="b", baz="bz")))
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")
+ bar=func.concat(stmt.inserted.bar, "_foo"),
+ baz=func.concat(stmt.inserted.bar, "_", foos.c.baz),
)
result = conn.execute(stmt)
eq_(result.inserted_primary_key, (None,))
eq_(
- conn.execute(foos.select().where(foos.c.id == 1)).fetchall(),
- [(1, "ab_foo", "bz", False)],
+ conn.execute(foos.select()).fetchall(),
+ [
+ # first entry triggers ON DUPLICATE
+ (1, "ab_foo", "ab_bz", False),
+ # second entry must be an insert
+ (2, "b", None, False),
+ ],
)
def test_on_duplicate_key_update_preserve_order(self, connection):