]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
add delete limit to mysql; ensure int for update/delete limits
authorPablo Nicolas Estevez <pablo22estevez@gmail.com>
Mon, 9 Dec 2024 19:44:44 +0000 (14:44 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 14 Dec 2024 17:54:57 +0000 (12:54 -0500)
commit134ad3bbdc4bcbee13acc043be0a98cc314fcaec
tree204e3c49e510529010412bd51ebc1716a999d465
parentf1335227c0f5da63f9a4f9179bdb8ef6916bc758
add delete limit to mysql; ensure int for update/delete limits

Added support for the ``LIMIT`` clause with ``DELETE`` for the MySQL and
MariaDB dialects, to complement the already present option for
``UPDATE``. The :meth:`.delete.with_dialect_options` method of the
`:func:`.delete` construct accepts parameters for ``mysql_limit`` and
``mariadb_limit``, allowing users to specify a limit on the number of rows
deleted. Pull request courtesy of Pablo Nicolás Estevez.

Added logic to ensure that the ``mysql_limit`` and ``mariadb_limit``
parameters of :meth:`.update.with_dialect_options` and
:meth:`.delete.with_dialect_options` when compiled to string will only
compile if the parameter is passed as an integer; a ``ValueError`` is
raised otherwise.

corrected mysql documentation for update/delete options which
must be specified using the ``with_dialect_options()`` method.

Fixes: #11764
Closes: #12146
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12146
Pull-request-sha: e34708374c67e016cda88919109fec5e6462eced

Change-Id: I8681ddabaa192b672c7a9b9981c4fe9e4bdc8d03
doc/build/changelog/unreleased_20/11764.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mysql/base.py
lib/sqlalchemy/orm/query.py
lib/sqlalchemy/sql/compiler.py
test/dialect/mysql/test_compiler.py
test/orm/dml/test_update_delete_where.py