summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/mysql
Commit message (Collapse)AuthorAgeFilesLines
* Remove deprecated dialects and driversFederico Caselli2021-10-313-278/+3
| | | | | Fixes: #7258 Change-Id: I3577f665eca04f2632b69bcb090f0a4ec9271db9
* add additional "oracle mode" reserved wordsMike Bayer2021-10-261-3/+19
| | | | | | | | | | despite mariadb's docs, the word "system" must be quoted in plain mariadb 10.5, not sure if that's "oracle mode" but it is > 10.3. observed keystone tests failing on a column of this name. Fixes: #7167 Change-Id: I153b79809e7da007bcceecec96c1340d1641f0de
* fix: Update reserved words list of MySQL / MariaDB dialectKevin Kirsche2021-10-205-308/+563
| | | | | | | | | | | | | | | | | | | | | | | Reorganized the list of reserved words into two separate lists, one for MySQL and one for MariaDB, so that these diverging sets of words can be managed more accurately; adjusted the MySQL/MariaDB dialect to switch among these lists based on either explicitly configured or server-version-detected "MySQL" or "MariaDB" backend. Added all current reserved words through MySQL 8 and current MariaDB versions including recently added keywords like "lead" . Pull request courtesy Kevin Kirsche. 1. Move reserved words to it's own file. 2. Add missing reserved words from https://mariadb.com/kb/en/reserved-words/ * Note: this only adds MariaDB though links to MySQL, it also does not include the reserved words for Oracle mode, as listed in the link. Fixes: #7167 Supercedes: #7197 Closes: #7207 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7207 Pull-request-sha: 5a682e331069520ccad9e6bf3cc5e4a77a889ef0 Change-Id: Ib25be8148568899f56b5c9b42d4f530ade8a04e3
* re-enable asnycmy >= 0.2.3; disable aiomysql totallyMike Bayer2021-10-151-3/+6
| | | | Change-Id: I94bc22db0462509003c8241d0ccef915fe6513c6
* Bugfix: MySQL expression: may be bindparam or other expressionAnton Kovalevich2021-10-051-1/+1
| | | | | | | | | | | | | Fixed issue in MySQL :func:`_mysql.match` construct where passing a clause expression such as :func:`_sql.bindparam` or other SQL expression for the "against" parameter would fail. Pull request courtesy Anton Kovalevich. Fixes: #7144 Closes: #7145 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7145 Pull-request-sha: 3757ffa51a3ff5919278165aaf906c8d2f9940c0 Change-Id: I7bb95f338afe3a17296a7b60e8c973f93b4f5e62
* correct charset for mariadb connector with mdb 10.6Georg Richter2021-10-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Updated test suite to pass correctly for MariaDB 10.6 when using the mariadb-connector driver, which made some adjustments to default encoding. Pull request courtesy Georg Richter. Use character set utf8mb4 instead of utf8: 1) Character set for mariadb connector is utf8mb4 and cannot be changed. 2) Since MariaDB 10.6.1 utf8 is mapped to utf8mb3, and will be mapped to utf8mb4 in 10.7, see [MDEV-8334](https://jira.mariadb.org/browse/MDEV-8334) (rename utf8 to utf8mb3) utf8mb4 character set support was added 12 years ago and will work with all non eoled MariaDB server versions. Fixes: #7115 Closes: #7116 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7116 Pull-request-sha: 79516ccce2dead11e6658596c9ad400b964d24c9 Change-Id: I86c30fb636c46307cb551080641e324d2bbc1cb3
* Fixes: #2937jonathan vanasco2021-09-281-1/+35
| | | | | | | * docs for event listen kwargs * docs for mysql to use `listen` for changing the sql_mode` Change-Id: I7c1678488658edda3c5baaf0f7648108e93a4be1
* Merge "pin asyncmy>=0.2.0 and remove cursor close workarounds"mike bayer2021-09-181-18/+4
|\
| * pin asyncmy>=0.2.0 and remove cursor close workaroundsMike Bayer2021-09-181-18/+4
| | | | | | | | Change-Id: I9426e09e4fd21f9c94f3c89b199a7784d33b949f
* | Surface driver connection object when using a proxied dialectFederico Caselli2021-09-173-5/+13
|/ | | | | | | | | | | | | | | | | | | | | | | | | | Improve the interface used by adapted drivers, like the asyncio ones, to access the actual connection object returned by the driver. The :class:`_engine._ConnectionRecord` and :class:`_engine._ConnectionFairy` now have two new attributes: * ``dbapi_connection`` always represents a DBAPI compatible object. For pep-249 drivers, this is the DBAPI connection as it always has been, previously accessed under the ``.connection`` attribute. For asyncio drivers that SQLAlchemy adapts into a pep-249 interface, the returned object will normally be a SQLAlchemy adaption object called :class:`_engine.AdaptedConnection`. * ``driver_connection`` always represents the actual connection object maintained by the third party pep-249 DBAPI or async driver in use. For standard pep-249 DBAPIs, this will always be the same object as that of the ``dbapi_connection``. For an asyncio driver, it will be the underlying asyncio-only connection object. The ``.connection`` attribute remains available and is now a legacy alias of ``.dbapi_connection``. Fixes: #6832 Change-Id: Ib72f97deefca96dce4e61e7c38ba430068d6a82e
* vendor asynccontextmanagerMike Bayer2021-09-171-3/+2
| | | | | | | while we still support python 3.6 vendor a simple version of this for now in the one place we currently use it. Change-Id: Ibcfc8b004b17e2ac79f9123ccb76c5eb25243f90
* Add `asyncmy` supportlong2ice2021-09-174-10/+350
| | | | | | | | | | | | | | | Added initial support for the ``asyncmy`` asyncio database driver for MySQL and MariaDB. This driver is very new, however appears to be the only current alternative to the ``aiomysql`` driver which currently appears to be unmaintained and is not working with current Python versions. Much thanks to long2ice for the pull request for this dialect. Fixes: #6993 Closes: #7000 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7000 Pull-request-sha: f7d6c811fc72324a83c8af635bbca8b268b0098e Change-Id: I4ef54b43334feff7e3a710fc4de6821437f3bb68
* Replace all http:// links to https://Federico Caselli2021-07-0414-25/+25
| | | | | | Also replace http://pypi.python.org/pypi with https://pypi.org/project Change-Id: I84b5005c39969a82140706472989f2a30b0c7685
* Modernize testsGord Thompson2021-07-031-3/+4
| | | | | | Eliminate engine.execute() and engine.scalar() Change-Id: I99f76d0e615ddebab2da4fd07a40a0a2796995c7
* Merge "Update link for mysql case sensitivity"mike bayer2021-07-031-1/+1
|\
| * Update link for mysql case sensitivityGord Thompson2021-07-031-1/+1
| | | | | | | | Change-Id: Ia4ff3e86d944bd5cfaa0ae2086b1d20fa027ba14
* | Don't require space after MySQL pk commentDaniël van Eeden2021-06-281-1/+1
|/ | | | | | | | | | | | | | | | Made a small adjustment in the table reflection feature of the MySQL dialect to accommodate for alternate MySQL-oriented databases such as TiDB which include their own "comment" directives at the end of a constraint directive within "CREATE TABLE" where the format doesn't have the additional space character after the comment, in this case the TiDB "clustered index" feature. Pull request courtesy Daniël van Eeden. Fixes: #6659 Closes: #6660 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6660 Pull-request-sha: 98791a441b2e3d26aa7cef9d3e2907fac113e30f Change-Id: I20d206e0cdb809e4c6997b87159edf41249f7cd9
* Implement MySQL-specific MATCHAnton Kovalevich2021-06-213-4/+202
| | | | | | | | | | | | | Added new construct :class:`_mysql.match`, which provides for the full range of MySQL's MATCH operator including multiple column support and modifiers. Pull request courtesy Anton Kovalevich. Fixes: #6132 Closes: #6133 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6133 Pull-request-sha: dc6842f13688849a848e2ecbb81600e6edf8b3a9 Change-Id: I66bbfd7947aa2e43a031772e9b5ae238d94e5223
* document missing ColumnCollection methodsMike Bayer2021-06-131-0/+11
| | | | | | | | add additional notes regarding the methods that are on this object. Fixes: #6629 Change-Id: I68446cb16cbfcef9af9c2998687b3b536607cf0d
* Remove pep484 type comments from the codeFederico Caselli2021-05-161-5/+0
| | | | | | | | | | | | | Current effort is around the stub package, and having typing in two places makes thing worse, since the types here are usually outdated compared to the version in the stubs. Once v2 gets under way we can start consolidating the types here. Fixes: #6461 Change-Id: I7132a444bd7138123074bf5bc664b4bb119a85ce
* Update black flak8 and zimportsFederico Caselli2021-05-121-1/+1
| | | | Change-Id: I488c9557eda390e4a88319affd4c8813ee274f80
* add ssl_check_hostname option in mysqldbJerry Zhao2021-05-072-3/+68
| | | | | | | | | | | | | Added support for the ``ssl_check_hostname=`` parameter in mysql connection URIs and updated the mysql dialect documentation regarding secure connections. Original pull request courtesy of Jerry Zhao. Fixes: #5397 Closes: #5759 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5759 Pull-request-sha: 75f4bdc68d4b5745c518472e8bc2b02cec0f81e6 Change-Id: I964bfa7a4c15e215a3ad6e2b907cb78f5b3e5036
* Propertly ignore ``Identity`` in MySQL and MariaDb.Federico Caselli2021-04-281-1/+4
| | | | | | | | | | | | | | Ensure that the MySQL and MariaDB dialect ignore the :class:`_sql.Identity` construct while rendering the ``AUTO_INCREMENT`` keyword in a create table. The Oracle and PostgreSQL compiler was updated to not render :class:`_sql.Identity` if the database version does not support it (Oracle < 12 and PostgreSQL < 10). Previously it was rendered regardless of the database version. Fixes: #6338 Change-Id: I2ca0902fdd7b4be4fc1a563cf5585504cbea9360
* pass asfrom correctly in compilersMike Bayer2021-04-171-2/+4
| | | | | | | | | | | | Fixed an argument error in the default and PostgreSQL compilers that would interfere with an UPDATE..FROM or DELETE..FROM..USING statement that was then SELECTed from as a CTE. The incorrect pattern was also fixed in the mysql and sybase dialects. MySQL supports CTEs but not "returning". Fixes: #6303 Change-Id: Ic94805611a5ec443749fb6b1fd8a1326b0d83ef7
* Merge "Support DEFAULT VALUES and VALUES(DEFAULT) individually"mike bayer2021-04-141-0/+5
|\
| * Support DEFAULT VALUES and VALUES(DEFAULT) individuallyMike Bayer2021-04-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression where the introduction of the INSERT syntax "INSERT... VALUES (DEFAULT)" was not supported on some backends that do however support "INSERT..DEFAULT VALUES", including SQLite. The two syntaxes are now each individually supported or non-supported for each dialect, for example MySQL supports "VALUES (DEFAULT)" but not "DEFAULT VALUES". Support for Oracle is still not enabled as there are unresolved issues in using RETURNING at the same time. Fixes: #6254 Change-Id: I47959bc826e3d9d2396ccfa290eb084841b02e77
* | Explicitly test for Connection in dialect.has_table()Mike Bayer2021-04-141-0/+2
|/ | | | | | | | | | | | | | The :meth:`_engine.Dialect.has_table` method now raises an informative exception if a non-Connection is passed to it, as this incorrect behavior seems to be common. This method is not intended for external use outside of a dialect. Please use the :meth:`.Inspector.has_table` method or for cross-compatibility with older SQLAlchemy versions, the :meth:`_engine.Engine.has_table` method. Fixes: #5780 Fixes: #6062 Fixes: #6260 Change-Id: I9b2439675167019b68d682edee3dcdcfce836987
* mariadb+pymsql -> mariadb+pymysqlMike Bayer2021-04-071-2/+2
| | | | | Fixes: #6217 Change-Id: Icd8275c49f30ea77d00f76209fb71fb2b8fa9528
* Merge "Add ``omit_aliases`` in ``Enum``."mike bayer2021-04-021-0/+1
|\
| * Add ``omit_aliases`` in ``Enum``.Federico Caselli2021-04-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a new parameter :paramref:`_types.Enum.omit_aliases` in :class:`_types.Enum` type allow filtering aliases when using a pep435 Enum. Previous versions of SQLAlchemy kept aliases in all cases, creating database enum type with additional states, meaning that they were treated as different values in the db. For backward compatibility this flag defaults to ``False`` in the 1.4 series, but will be switched to ``True`` in a future version. A deprecation warning is raise if this flag is not specified and the passed enum contains aliases. Fixes: #6146 Change-Id: I547322ffa90d0273d91bb3bf8bfea6ec934d48b9
* | Default caching to opt-out for 3rd party dialectsMike Bayer2021-04-0110-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added a new flag to the :class:`_engine.Dialect` class called :attr:`_engine.Dialect.supports_statement_cache`. This flag now needs to be present directly on a dialect class in order for SQLAlchemy's :ref:`query cache <sql_caching>` to take effect for that dialect. The rationale is based on discovered issues such as :ticket:`6173` revealing that dialects which hardcode literal values from the compiled statement, often the numerical parameters used for LIMIT / OFFSET, will not be compatible with caching until these dialects are revised to use the parameters present in the statement only. For third party dialects where this flag is not applied, the SQL logging will show the message "dialect does not support caching", indicating the dialect should seek to apply this flag once they have verified that no per-statement literal values are being rendered within the compilation phase. Fixes: #6184 Change-Id: I6fd5b5d94200458d4cb0e14f2f556dbc25e27e22
* | Fix has table reflection on MySQL 5.0 5.1Federico Caselli2021-04-011-1/+1
|/ | | | | | | | Fixed regression in the MySQL dialect where the reflection query used to detect if a table exists would fail on very old MySQL 5.0 and 5.1 versions. Fixes: #6151 Change-Id: I48e98542c3a1a49519a5d113e43ba6f917e8580e
* Add support for aiosqliteFederico Caselli2021-03-241-0/+7
| | | | | | | | Added support for the aiosqlite database driver for use with the SQLAlchemy asyncio extension. Fixes: #5920 Change-Id: Id11a320516a44e886a6f518d2866a0f992413e55
* Add supported database version for internal dialectsFederico Caselli2021-03-071-0/+3
| | | | Change-Id: I08d150f1780a0f3a848c0edcd40013b5593d18f0
* mutex asyncpg / aiomysql connection state changesMike Bayer2021-02-251-14/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | Added an ``asyncio.Lock()`` within SQLAlchemy's emulated DBAPI cursor, local to the connection, for the asyncpg dialect, so that the space between the call to ``prepare()`` and ``fetch()`` is prevented from allowing concurrent executions on the connection from causing interface error exceptions, as well as preventing race conditions when starting a new transaction. Other PostgreSQL DBAPIs are threadsafe at the connection level so this intends to provide a similar behavior, outside the realm of server side cursors. Apply the same idea to the aiomysql dialect which also would otherwise be subject to corruption if the connection were used concurrently. While this is an issue which can also occur with the threaded connection libraries, we anticipate asyncio users are more likely to attempt using the same connection in multiple awaitables at a time, even though this won't achieve concurrency for that use case, as the asyncio programming style is very encouraging of this. As the failure modes are also more complicated under asyncio, we'd rather not have this being reported. Fixes: #5967 Change-Id: I3670ba0c8f0b593c587c5aa7c6c61f9e8c5eb93a
* Typo stream_resuls -> stream_resultsCharlie Denton2021-02-191-1/+1
|
* Accept ColumnCollection in update_on_conflict(set_=Gord Thompson2021-02-151-2/+14
| | | | | Fixes: #5939 Change-Id: I21d7125765028e2a98d5ef4c32d8e7e457aa2d12
* Merge "Add identifier_preparer per-execution context for schema translates"mike bayer2021-02-081-1/+6
|\
| * Add identifier_preparer per-execution context for schema translatesMike Bayer2021-02-081-1/+6
| | | | | | | | | | | | | | | | | | | | | | Fixed bug where the "schema_translate_map" feature failed to be taken into account for the use case of direct execution of :class:`_schema.DefaultGenerator` objects such as sequences, which included the case where they were "pre-executed" in order to generate primary key values when implicit_returning was disabled. Fixes: #5929 Change-Id: I3fed1d0af28be5ce9c9bb572524dcc8411633f60
* | Use slots in the aiomysql proxy classesFederico Caselli2021-02-061-1/+9
|/ | | | | | Add slots in the proxy cursor and connection classes in the aiomysql dialect Change-Id: If72fccf0cc16557a7e3a0c9450733c8337bec15a
* set identifier length for MySQL constraints to 64Mike Bayer2021-01-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | The rule to limit index names to 64 also applies to all DDL names, such as those coming from naming conventions. Add another limiting variable for constraint names and create test cases against all constraint types. Additionally, codified in the test suite MySQL's lack of support for naming of a FOREIGN KEY constraint after the name was given, which apparently assigns the name to an associated KEY but not the constraint itself, until MySQL 8 and MariaDB 10.5 which appear to have resolved the behavior. However it's not clear how Alembic hasn't had issues reported with this so far. Fixed long-lived bug in MySQL dialect where the maximum identifier length of 255 was too long for names of all types of constraints, not just indexes, all of which have a size limit of 64. As metadata naming conventions can create too-long names in this area, apply the limit to the identifier generator within the DDL compiler. Fixes: #5898 Change-Id: I79549474845dc29922275cf13321c07598dcea08
* Fix many spell glitches in docstrings and commentsLele Gaifax2021-01-244-5/+5
| | | | | | | | | | These were revealed by running `pylint --disable all --enable spelling --spelling-dict en_US` over all sources. Closes: #5868 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5868 Pull-request-sha: bb249195d92e3b806e81ecf1192d5a1b3cd5db48 Change-Id: I96080ec93a9fbd20ce21e9e16265b3c77f22bb14
* include negation symbol in numeric default matchMike Bayer2021-01-231-2/+2
| | | | | | | | Fixed bug where MySQL server default reflection would fail for numeric values with a negation symbol present. Fixes: #5860 Change-Id: I02cacdb4f9ec7d9113c27bf0d9214c4e14f4d4f9
* introduce generalized decorator to prevent invalid method callsMike Bayer2021-01-161-0/+8
| | | | | | | | | | | | | | | | | | | This introduces the ``_exclusive_against()`` utility decorator that can be used to prevent repeated invocations of methods that typically should only be called once. An informative error message is now raised for a selected set of DML methods (currently all part of :class:`_dml.Insert` constructs) if they are called a second time, which would implicitly cancel out the previous setting. The methods altered include: :class:`_sqlite.Insert.on_conflict_do_update`, :class:`_sqlite.Insert.on_conflict_do_nothing` (SQLite), :class:`_postgresql.Insert.on_conflict_do_update`, :class:`_postgresql.Insert.on_conflict_do_nothing` (PostgreSQL), :class:`_mysql.Insert.on_duplicate_key_update` (MySQL) Fixes: #5169 Change-Id: I9278fa87cd3470dcf296ff96bb0fb17a3236d49d
* Update connect args for pymysql 1.0.0; aiomysql fixesMike Bayer2021-01-073-8/+17
| | | | | | | | | | | | | Fixed deprecation warnings that arose as a result of the release of PyMySQL 1.0, including deprecation warnings for the "db" and "passwd" parameters now replaced with "database" and "password". For the 1.4 version of this patch, we are also changing tox.ini to refer to a local branch of aiomysql that fixes pymysql compatibility issues. Fixes: #5821 Change-Id: I93876b52b2d96b52308f22aeb4f244ac5766a82f
* happy new yearMike Bayer2021-01-0414-14/+14
| | | | Change-Id: Ic5bb19ca8be3cb47c95a0d3315d84cb484bac47c
* Merge "Support casting to ``FLOAT`` in MySQL and MariaDb."mike bayer2021-01-011-1/+17
|\
| * Support casting to ``FLOAT`` in MySQL and MariaDb.Federico Caselli2020-12-301-1/+17
| | | | | | | | | | Fixes: #5808 Change-Id: I8106ddcf681eec3cb3a67d853586702f6e844b9d
* | Support testing of async drivers without fallback modeFederico Caselli2020-12-301-3/+12
|/ | | | Change-Id: I4940d184a4dc790782fcddfb9873af3cca844398
* narrow the check for double-paren exprs in mysql create_indexMike Bayer2020-12-261-4/+6
| | | | | | | | | | | | | | Fixed regression from SQLAlchemy 1.3.20 caused by the fix for :ticket:`5462` which adds double-parenthesis for MySQL functional expressions in indexes, as is required by the backend, this inadvertently extended to include arbitrary :func:`_sql.text` expressions as well as Alembic's internal textual component, which are required by Alembic for arbitrary index expressions which don't imply double parenthesis. The check has been narrowed to include only binary/ unary/functional expressions directly. Fixes: #5800 Change-Id: I40f83c6f9dd04b984d0c86eba632a588570709a1