diff options
| author | Maxim Bublis <satori@dropbox.com> | 2018-07-18 14:06:07 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-08-13 15:41:58 -0400 |
| commit | dfa47b454a1d873b5746263f638d757c70edd3e1 (patch) | |
| tree | f7e0579fde6157a0bb6313d2835453698280cfe0 /doc | |
| parent | c85378d9841177b067a93c564edb1787703c6595 (diff) | |
| download | sqlalchemy-dfa47b454a1d873b5746263f638d757c70edd3e1.tar.gz | |
Add ability to preserve order in MySQL ON DUPLICATE KEY UPDATE.
Added support for the parameters in an ON DUPLICATE KEY UPDATE statement on
MySQL to be ordered, since parameter order in a MySQL UPDATE clause is
significant, in a similar manner as that described at
:ref:`updates_order_parameters`. Pull request courtesy Maxim Bublis.
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/462
Change-Id: If508d8e26dbd3c55ab1e83cf573fb4021e9d091e
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/build/changelog/migration_13.rst | 24 | ||||
| -rw-r--r-- | doc/build/changelog/unreleased_13/pr462.rst | 11 | ||||
| -rw-r--r-- | doc/build/core/tutorial.rst | 5 |
3 files changed, 40 insertions, 0 deletions
diff --git a/doc/build/changelog/migration_13.rst b/doc/build/changelog/migration_13.rst index c81d95ed9..23a14fca6 100644 --- a/doc/build/changelog/migration_13.rst +++ b/doc/build/changelog/migration_13.rst @@ -333,6 +333,30 @@ pool pre-ping feature, described at :ref:`pool_disconnects_pessimistic`. This is a much more lightweight ping than the previous method of emitting "SELECT 1" on the connection. +.. _change_mysql_ondupordering: + +Control of parameter ordering within ON DUPLICATE KEY UPDATE +------------------------------------------------------------ + +The order of UPDATE parameters in the ``ON DUPLICATE KEY UPDATE`` clause +can now be explcitly ordered by passing a list of 2-tuples:: + + from sqlalchemy.dialects.mysql import insert + + insert_stmt = insert(my_table).values( + id='some_existing_id', + data='inserted value') + + on_duplicate_key_stmt = insert_stmt.on_duplicate_key_update( + [ + ("data", "some data"), + ("updated_at", func.current_timestamp()), + ], + ) + +.. seealso:: + + :ref:`mysql_insert_on_duplicate_key_update` Dialect Improvements and Changes - SQLite ============================================= diff --git a/doc/build/changelog/unreleased_13/pr462.rst b/doc/build/changelog/unreleased_13/pr462.rst new file mode 100644 index 000000000..7d714cf99 --- /dev/null +++ b/doc/build/changelog/unreleased_13/pr462.rst @@ -0,0 +1,11 @@ +.. change:: + :tags: feature, mysql + + Added support for the parameters in an ON DUPLICATE KEY UPDATE statement on + MySQL to be ordered, since parameter order in a MySQL UPDATE clause is + significant, in a similar manner as that described at + :ref:`updates_order_parameters`. Pull request courtesy Maxim Bublis. + + .. seealso:: + + :ref:`change_mysql_ondupordering` diff --git a/doc/build/core/tutorial.rst b/doc/build/core/tutorial.rst index 65410f7ba..baddfc459 100644 --- a/doc/build/core/tutorial.rst +++ b/doc/build/core/tutorial.rst @@ -2108,6 +2108,11 @@ except it is ordered. Using the above form, we are assured that the parameters using the :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order` flag. +.. seealso:: + + :ref:`mysql_insert_on_duplicate_key_update` - background on the MySQL + ``ON DUPLICATE KEY UPDATE`` clause and how to support parameter ordering. + .. _deletes: Deletes |
