diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2020-03-05 04:18:22 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-03-05 04:18:22 +0000 |
commit | d72bda5ed23a46bcbf31d40684200dcb79012a33 (patch) | |
tree | cbed66fd751d44dc49a47b899609e1b7317e63b9 /test/dialect/mysql/test_compiler.py | |
parent | c278900de7a28c98335d870f393328c868e75126 (diff) | |
parent | 57b2aae0d9efe91c2338e5a762e04366f86c2651 (diff) | |
download | sqlalchemy-d72bda5ed23a46bcbf31d40684200dcb79012a33.tar.gz |
Merge "Render VALUES within composed MySQL on duplicate key expressions"
Diffstat (limited to 'test/dialect/mysql/test_compiler.py')
-rw-r--r-- | test/dialect/mysql/test_compiler.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/dialect/mysql/test_compiler.py b/test/dialect/mysql/test_compiler.py index d59c0549f..e74c37d63 100644 --- a/test/dialect/mysql/test_compiler.py +++ b/test/dialect/mysql/test_compiler.py @@ -928,3 +928,28 @@ class InsertOnDuplicateTest(fixtures.TestBase, AssertsCompiledSQL): "ON DUPLICATE KEY UPDATE bar = %s" ) self.assert_compile(stmt, expected_sql) + + def test_update_sql_expr(self): + stmt = insert(self.table).values( + [{"id": 1, "bar": "ab"}, {"id": 2, "bar": "b"}] + ) + stmt = stmt.on_duplicate_key_update( + bar=func.coalesce(stmt.inserted.bar), + baz=stmt.inserted.baz + "some literal", + ) + expected_sql = ( + "INSERT INTO foos (id, bar) VALUES (%s, %s), (%s, %s) ON " + "DUPLICATE KEY UPDATE bar = coalesce(VALUES(bar)), " + "baz = (concat(VALUES(baz), %s))" + ) + self.assert_compile( + stmt, + expected_sql, + checkparams={ + "id_m0": 1, + "bar_m0": "ab", + "id_m1": 2, + "bar_m1": "b", + "baz_1": "some literal", + }, + ) |