summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
Commit message (Collapse)AuthorAgeFilesLines
* Update psycopg2 dialect to use the DBAPI interface to executeFederico Caselli2021-10-312-10/+41
| | | | | | | two phase transactions Fixes: #7238 Change-Id: Ie4f5cf59d29b5bfc142ec2dfdecffb896ee7d708
* Merge "Remove deprecated dialects and drivers" into mainmike bayer2021-10-3118-3597/+5
|\
| * Remove deprecated dialects and driversFederico Caselli2021-10-3118-3597/+5
| | | | | | | | | | Fixes: #7258 Change-Id: I3577f665eca04f2632b69bcb090f0a4ec9271db9
* | The ``has_table`` method now also checks viewsFederico Caselli2021-10-312-4/+14
|/ | | | | | | | | | | | The :meth:`_engine.Inspector.has_table` method will now consistently check for views of the given name as well as tables. Previously this behavior was dialect dependent, with PostgreSQL, MySQL/MariaDB and SQLite supporting it, and Oracle and SQL Server not supporting it. Third party dialects should also seek to ensure their :meth:`_engine.Inspector.has_table` method searches for views as well as tables for the given name. Fixes: #7161 Change-Id: I9e523c76741b19596c81ef577dc6f0823e44183b
* Merge "Improve array support on pg8000" into mainmike bayer2021-10-282-1/+9
|\
| * Improve array support on pg8000Federico Caselli2021-10-272-1/+9
| | | | | | | | | | | | References: #6023 Change-Id: I0f6cbc34b3c0bfc0b8c86b3ebe4531e23039b6c0
* | Fixes: #5020jonathan vanasco2021-10-271-7/+68
| | | | | | | | | | | | Add mike's example to docs Change-Id: I96a79084cccca5c792bee697338422f3de0884fb
* | 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
* Merge "support bind expressions w/ expanding IN; apply to psycopg2" into mainmike bayer2021-10-153-21/+24
|\
| * support bind expressions w/ expanding IN; apply to psycopg2Mike Bayer2021-10-153-21/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where "expanding IN" would fail to function correctly with datatypes that use the :meth:`_types.TypeEngine.bind_expression` method, where the method would need to be applied to each element of the IN expression rather than the overall IN expression itself. Fixed issue where IN expressions against a series of array elements, as can be done with PostgreSQL, would fail to function correctly due to multiple issues within the "expanding IN" feature of SQLAlchemy Core that was standardized in version 1.4. The psycopg2 dialect now makes use of the :meth:`_types.TypeEngine.bind_expression` method with :class:`_types.ARRAY` to portably apply the correct casts to elements. The asyncpg dialect was not affected by this issue as it applies bind-level casts at the driver level rather than at the compiler level. as part of this commit the "bind translate" feature has been simplified and also applies to the names in the POSTCOMPILE tag to accommodate for brackets. Fixes: #7177 Change-Id: I08c703adb0a9bd6f5aeee5de3ff6f03cccdccdc5
* | Fix reflection of FK against a unique indexGord Thompson2021-10-141-24/+135
|/ | | | | | | | Also implement reflection of ON DELETE, ON UPDATE as the data is right there. Fixes: #7160 Change-Id: Ifff871a8cb1d1bea235616042e16ed3b5c5f19f9
* Fix has_table() false negative for #temp tablesGord Thompson2021-10-121-8/+12
| | | | | | | | | | | Fixed issue with :meth:`.Inspector.has_table` where it would return False if a local temp table with the same name from a different session happened to be returned first when querying tempdb. This is a continuation of :ticket:`6910` which accounted for the temp table existing only in the alternate session and not the current one. Fixes: #7168 Change-Id: I19dbb71a63184c6d41822b0e882b7b284ac83786
* Merge "Add autocommit documentation for Azure SQL DW"mike bayer2021-10-061-3/+42
|\
| * Add autocommit documentation for Azure SQL DWGord Thompson2021-09-281-3/+42
| | | | | | | | | | Fixes: #7065 Change-Id: I3666e16f9a8c47f9784ea11f38972cda6b08c146
* | Merge "Bugfix: MySQL expression: may be bindparam or other expression"mike bayer2021-10-051-1/+1
|\ \
| * | 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
* | | Handle SSL SYSCALL error: Bad Address in postgresql/pyscopg2Zeke Brechtel2021-10-051-1/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | Added a "disconnect" condition for the "SSL SYSCALL error: Bad address" error message as reported by psycopg2. Pull request courtesy Zeke Brechtel. Fixes: #5387 Closes: #7087 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7087 Pull-request-sha: 66af76a107a22d9119edc8edcacc1e4ef66dc50d Change-Id: Ia4afc9683b8175a8ca282e07e0f83c65657544ab
* | repair any_() / all_() "implicit flip" behavior for NoneMike Bayer2021-10-041-14/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed an inconsistency in the any_() / all_() functions / methods where the special behavior these functions have of "flipping" the expression such that the "ANY" / "ALL" expression is always on the right side would not function if the comparison were against the None value, that is, "column.any_() == None" should produce the same SQL expression as "null() == column.any_()". Added more docs to clarify this as well, plus mentions that any_() / all_() generally supersede the ARRAY version "any()" / "all()". Fixes: #7140 Change-Id: Ia5d55414ba40eb3fbda3598931fdd24c9b4a4411
* | Merge "Fixes: #3160"mike bayer2021-10-011-6/+25
|\ \
| * | Fixes: #3160jonathan vanasco2021-09-281-6/+25
| |/ | | | | | | | | | | | | Clarify that match() emits `to_tsquery`, which expects input text to be in postgresql's own format. Change-Id: Id723032bca2eededc03ac30681c0dd4ddf76c232
* | organize datetime types for correct implsMike Bayer2021-10-012-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug in SQL Server ``DATETIMEOFFSET`` where the ODBC implementation would not generate the correct DDL, for cases where the type were converted using the ``dialect.type_descriptor()`` method, the usage of which is illustrated in some documented examples for :class:`.TypeDecorator`, though not necessary for most datatypes. Regression was introduced by :ticket:`6366`. As part of this change, the full list of SQL Server date types have been amended to return a "dialect impl" that generates the same DDL name as the supertype. Fixes: #7129 Change-Id: I7d9bea54c0c38e16d1a6ad978cca996006a1b624
* | 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-179-19/+35
|/ | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Merge "Fixes: #5289"mike bayer2021-09-151-1/+2
|\
| * Fixes: #5289jonathan vanasco2021-09-081-1/+2
| | | | | | | | | | | | Clarify Foreign Key support on SQLite must be enabled before `MetaData.create_all` Change-Id: Ic41b86f736be21dd6fc890a915a2ffd572df73a4
* | Merge "Fixes: #6930"mike bayer2021-09-154-0/+12
|\ \
| * | Fixes: #6930jonathan vanasco2021-09-084-0/+12
| |/ | | | | | | | | | | Note in docstrings that ignored kwargs are required for API conformance. Change-Id: Icc9a8c63c0936a7c5255841ef49d10a83496763a
* | Fix various lib / test / examples typos (#7017)Kevin Kirsche2021-09-113-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fix: lib/sqlalchemy/sql/lambdas.py * fix: lib/sqlalchemy/sql/compiler.py * fix: lib/sqlalchemy/sql/selectable.py * fix: lib/sqlalchemy/orm/relationships.py * fix: lib/sqlalchemy/dialects/mssql/base.py * fix: lib/sql/test_compiler.py * fix: lib/sqlalchemy/testing/requirements.py * fix: lib/sqlalchemy/orm/path_registry.py * fix: lib/sqlalchemy/dialects/postgresql/psycopg2.py * fix: lib/sqlalchemy/cextension/immutabledict.c * fix: lib/sqlalchemy/cextension/resultproxy.c * fix: ./lib/sqlalchemy/dialects/oracle/cx_oracle.py * fix: examples/versioned_rows/versioned_rows_w_versionid.py * fix: examples/elementtree/optimized_al.py * fix: test/orm/test_attribute.py * fix: test/sql/test_compare.py * fix: test/sql/test_type_expression.py * fix: capitalization in test/dialect/mysql/test_compiler.py * fix: typos in test/dialect/postgresql/test_reflection.py * fix: typo in tox.ini comment * fix: typo in /lib/sqlalchemy/orm/decl_api.py * fix: typo in test/orm/test_update_delete.py * fix: self-induced typo * fix: typo in test/orm/test_query.py * fix: typos in test/dialect/mssql/test_types.py * fix: typo in test/sql/test_types.py
* | ignore and warn for native_enum=False with pg.ENUM datatypeMike Bayer2021-09-101-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | any UPPERCASE datatype refers to that exact type name rendered on the database. So PG's ENUM must render "ENUM" and is "native" by definition. warn if this flag is passed. The :class:`_postgresql.ENUM` datatype is PostgreSQL-native and therefore should not be used with the ``native_enum=False`` flag. This flag is now ignored if passed to the :class:`_postgresql.ENUM` datatype and a warning is emitted; previously the flag would cause the type object to fail to function correctly. Fixes: #6106 Change-Id: I08e0ec6fcfafd068e1eaf6aec13c8010f09ce94a
* | Fix typo (#6994)Yutian Li2021-09-081-1/+1
| |
* | ensure pysqlite dialect enumerates correct isolation levelsMike Bayer2021-08-302-2/+14
| | | | | | | | | | | | | | | | | | Fixed bug where the error message for SQLite invalid isolation level on the pysqlite driver would fail to indicate that "AUTOCOMMIT" is one of the valid isolation levels. Change-Id: Icbceab9a28af6a560859761fa92320b5473269a9 References: #6959
* | Merge "Qualify server version call in PostgreSQL"mike bayer2021-08-251-1/+1
|\ \ | |/ |/|
| * Qualify server version call in PostgreSQLarredond2021-08-241-1/+1
| | | | | | | | | | | | | | | | | | Fixes: #6912 Closes: #6920 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6920 Pull-request-sha: 79af75dfddef25435afd9623698354d280d7c879 Change-Id: Ib6b472452f978378d9f511d17a26988323a89459
* | Fix has_table() to exclude other sessions' local temp tablesGord Thompson2021-08-231-3/+17
|/ | | | | Fixes: #6910 Change-Id: I9986566e1195d42ad7e9a01f0f84ef2074576257
* CAST Oracle table_name, owner, others to VARCHAR(128)Mike Bayer2021-08-181-11/+17
| | | | | | | | | | | | | | | Added a CAST(VARCHAR2(128)) to the "table name", "owner", and other DDL-name parameters as used in reflection queries against Oracle system views such as ALL_TABLES, ALL_TAB_CONSTRAINTS, etc to better enable indexing to take place against these columns, as they previously would be implicitly handled as NVARCHAR2 due to Python's use of Unicode for strings; these columns are documented in all Oracle versions as being VARCHAR2 with lengths varying from 30 to 128 characters depending on server version. Additionally, test support has been enabled for Unicode-named DDL structures against Oracle databases. Fixes: #4486 Change-Id: I2787e3f8de1f656318692bd535d6a7f1cef1a841
* fix linter JOIN logic; fix PostgreSQL ARRAY op comparisonMike Bayer2021-08-151-3/+3
| | | | | | | | | | | | | | | | | | | Adjusted the "from linter" warning feature to accommodate for a chain of joins more than one level deep where the ON clauses don't explicitly match up the targets, such as an expression such as "ON TRUE". This mode of use is intended to cancel the cartesian product warning simply by the fact that there's a JOIN from "a to b", which was not working for the case where the chain of joins had more than one element. this incurs a bit more compiler overhead that comes out in profiling but is not extensive. Added the "is_comparison" flag to the PostgreSQL "overlaps", "contained_by", "contains" operators, so that they work in relevant ORM contexts as well as in conjunction with the "from linter" feature. Fixes: #6886 Change-Id: I078dc3fe6d4f7871ffe4ebac3e71e62f3f213d12
* cx_oracle patchesMike Bayer2021-07-291-18/+99
| | | | | | provided by cx_oracle developers Change-Id: Ie30b0993d0da2ee1359042816d77d08f762c6b13
* Merge "Extract format_constraint truncation rules to ON CONFLICT"mike bayer2021-07-131-2/+10
|\
| * Extract format_constraint truncation rules to ON CONFLICTMike Bayer2021-07-131-2/+10
| | | | | | | | | | | | | | | | | | | | | | Fixed issue where a too-long constraint name rendered as part of the "ON CONFLICT ON CONSTRAINT" element of the :class:`_postgresql.Insert` construct due to naming convention generation would not correctly truncate the name in the same way that it normally renders within a CREATE TABLE statement, thus producing a non-matching and too-long constraint name. Fixes: #6755 Change-Id: Ib27014a5ecbc9cd5861a396f8bb49fbc60bf49fe
* | Merge "labeling refactor"mike bayer2021-07-133-6/+4
|\ \
| * | labeling refactorMike Bayer2021-07-123-6/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To service #6718 and #6710, the system by which columns are given labels in a SELECT statement as well as the system that gives them keys in a .c or .selected_columns collection have been refactored to provide a single source of truth for both, in constrast to the previous approach that included similar logic repeated in slightly different ways. Main ideas: 1. ColumnElement attributes ._label, ._anon_label, ._key_label are renamed to include the letters "tq", meaning "table-qualified" - these labels are only used when rendering a SELECT that has LABEL_STYLE_TABLENAME_PLUS_COL for its label style; as this label style is primarily legacy, the "tq" names should be isolated so that in a 2.0 style application these aren't being used at all 2. The means by which the "labels" and "proxy keys" for the elements of a SELECT has been centralized to a single source of truth; previously, the three of _generate_columns_plus_names, _generate_fromclause_column_proxies, and _column_naming_convention all had duplicated rules between them, as well as that there were a little bit of labeling rules in compiler._label_select_column as well; by this we mean that the various "anon_label" "anon_key" methods on ColumnElement were called by all four of these methods, where there were many cases where it was necessary that one method comes up with the same answer as another of the methods. This has all been centralized into _generate_columns_plus_names for all the names except the "proxy key", which is generated by _column_naming_convention. 3. compiler._label_select_column has been rewritten to both not make any naming decisions nor any "proxy key" decisions, only whether to label or not to label; the _generate_columns_plus_names method gives it the information, where the proxy keys come from _column_naming_convention; previously, these proxy keys were matched based on restatement of similar (but not really the same) logic in two places. The heuristics of "whether to label or not to label" are also reorganized to be much easier to read and understand. 4. a new method compiler._label_returning_column is added for dialects to use in their "generate returning columns" methods. A github search reveals a small number of third party dialects also doing this using the prior _label_select_column method so we try to make sure _label_select_column continues to work the exact same way for that specific use case; for the "SELECT" use case it now needs 5. After some attempts to do it different ways, for the case where _proxy_key is giving us some kind of anon label, we are hard changing it to "_no_label" right now, as there's not currently a way to fully match anonymized labels from stmt.c or stmt.selected_columns to what will be in the result map. The idea of "_no_label" is to encourage the user to use label('name') for columns they want to be able to target by string name that don't have a natural name. Change-Id: I7a92a66f3a7e459ccf32587ac0a3c306650daf11
* | Correct docs: pg8000 supports PostgreSQL UUIDTony Locke2021-07-121-2/+3
| |
* | repair schema_translate_map for schema type use casesMike Bayer2021-07-111-3/+1
|/ | | | | | | | | | | | | Fixed issue where the PostgreSQL ``ENUM`` datatype as embedded in the ``ARRAY`` datatype would fail to emit correctly in create/drop when the ``schema_translate_map`` feature were also in use. Additionally repairs a related issue where the same ``schema_translate_map`` feature would not work for the ``ENUM`` datatype in combination with a ``CAST``, that's also intrinsic to how the ``ARRAY(ENUM)`` combination works on the PostgreSQL dialect. Fixes: #6739 Change-Id: I44b1ad4db4af3acbf639aa422c46c22dd3b0d3a6