diff options
author | Lukas Banic <luko@lingea.cz> | 2019-06-10 11:24:53 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-06-10 13:26:34 -0400 |
commit | 59e9276f04beef4459571cba4226f9d4eaef6be9 (patch) | |
tree | e7eb8655f83f3da7a067e527cc0ae43ce6d5ce72 /test/dialect/mysql/test_on_duplicate.py | |
parent | e2521b595ae8b5b4ca8147c5ee13e2fc0f597e63 (diff) | |
download | sqlalchemy-59e9276f04beef4459571cba4226f9d4eaef6be9.tar.gz |
Accommodate value of None for ON DUPLICATE KEY UPDATE
Fixed bug where MySQL ON DUPLICATE KEY UPDATE would not accommodate setting
a column to the value NULL. Pull request courtesy Lukáš Banič.
Fixes: #4715
Closes: #4716
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4716
Pull-request-sha: bfad6e6bdfb7d6dd5176deaf30d875f3d0f15e06
Change-Id: Ia8831cc171d131bf3824be8db4fd1d231231bba3
Diffstat (limited to 'test/dialect/mysql/test_on_duplicate.py')
-rw-r--r-- | test/dialect/mysql/test_on_duplicate.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/dialect/mysql/test_on_duplicate.py b/test/dialect/mysql/test_on_duplicate.py index 0c6f47929..077e5ba98 100644 --- a/test/dialect/mysql/test_on_duplicate.py +++ b/test/dialect/mysql/test_on_duplicate.py @@ -62,6 +62,21 @@ class OnDuplicateTest(fixtures.TablesTest): [(1, "ab", "bz", False)], ) + def test_on_duplicate_key_update_null(self): + foos = self.tables.foos + with testing.db.connect() as conn: + conn.execute(insert(foos, 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(updated_once=None) + result = conn.execute(stmt) + eq_(result.inserted_primary_key, [2]) + eq_( + conn.execute(foos.select().where(foos.c.id == 1)).fetchall(), + [(1, "b", "bz", None)], + ) + def test_on_duplicate_key_update_preserve_order(self): foos = self.tables.foos with testing.db.connect() as conn: |