summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Merge "change the POSTCOMPILE/ SCHEMA symbols to not conflict w mssql ↵mike bayer2021-11-091-2/+2
|\ \ \ | |/ / |/| | | | | quoting" into main
| * | change the POSTCOMPILE/ SCHEMA symbols to not conflict w mssql quotingMike Bayer2021-11-091-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adjusted the compiler's generation of "post compile" symbols including those used for "expanding IN" as well as for the "schema translate map" to not be based directly on plain bracketed strings with underscores, as this conflicts directly with SQL Server's quoting format of also using brackets, which produces false matches when the compiler replaces "post compile" and "schema translate" symbols. The issue created easy to reproduce examples both with the :meth:`.Inspector.get_schema_names` method when used in conjunction with the :paramref:`_engine.Connection.execution_options.schema_translate_map` feature, as well in the unlikely case that a symbol overlapping with the internal name "POSTCOMPILE" would be used with a feature like "expanding in". Fixes: #7300 Change-Id: I6255c850b140522a4aba95085216d0bca18ce230
* | De-emphasize notion of "default driver" (DBAPI)Gord Thompson2021-11-091-7/+9
|/ | | | | | | | | | | Fixes: #6960 Even though a default driver still exists for each dialect, remove most usages of `dialect://` to encourage users to explicitly specify `dialect+driver://` Change-Id: I0ad42167582df509138fca64996bbb53e379b1af
* fully implement future engine and remove legacyMike Bayer2021-11-071-20/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | The major action here is to lift and move future.Connection and future.Engine fully into sqlalchemy.engine.base. This removes lots of engine concepts, including: * autocommit * Connection running without a transaction, autobegin is now present in all cases * most "autorollback" is obsolete * Core-level subtransactions (i.e. MarkerTransaction) * "branched" connections, copies of connections * execution_options() returns self, not a new connection * old argument formats, distill_params(), simplifies calling scheme between engine methods * before/after_execute() events (oriented towards compiled constructs) don't emit for exec_driver_sql(). before/after_cursor_execute() is still included for this * old helper methods superseded by context managers, connection.transaction(), engine.transaction() engine.run_callable() * ancient engine-level reflection methods has_table(), table_names() * sqlalchemy.testing.engines.proxying_engine References: #7257 Change-Id: Ib20ed816642d873b84221378a9ec34480e01e82c
* simplify and publicize the asyncpg JSON(B) codec registrsationMike Bayer2021-11-031-0/+20
| | | | | | | | | | | | Added overridable methods ``PGDialect_asyncpg.setup_asyncpg_json_codec`` and ``PGDialect_asyncpg.setup_asyncpg_jsonb_codec`` codec, which handle the required task of registering JSON/JSONB codecs for these datatypes when using asyncpg. The change is that methods are broken out as individual, overridable methods to support third party dialects that need to alter or disable how these particular codecs are set up. Fixes: #7284 Change-Id: I3eac258fea61f3975bd03c428747f788813ce45e
* First round of removal of python 2Federico Caselli2021-11-012-33/+1
| | | | | References: #4600 Change-Id: I61e35bc93fe95610ae75b31c18a3282558cd4ffe
* Remove deprecated dialects and driversFederico Caselli2021-10-311-2/+0
| | | | | Fixes: #7258 Change-Id: I3577f665eca04f2632b69bcb090f0a4ec9271db9
* Improve array support on pg8000Federico Caselli2021-10-271-9/+19
| | | | | | References: #6023 Change-Id: I0f6cbc34b3c0bfc0b8c86b3ebe4531e23039b6c0
* support bind expressions w/ expanding IN; apply to psycopg2Mike Bayer2021-10-151-38/+185
| | | | | | | | | | | | | | | | | | | | | | | 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
* Handle SSL SYSCALL error: Bad Address in postgresql/pyscopg2Zeke Brechtel2021-10-051-0/+36
| | | | | | | | | | | | 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
* Modernize tests - calling_mapper_directlyGord Thompson2021-09-302-9/+8
| | | | | | | | | | | | | a few changes for py2k: * map_imperatively() includes the check that a class is being sent, this was only working for mapper() before * the test suite didn't place the py2k "autouse" workaround in the correct order, seemingly, tried to adjust the per-test ordering setup in pytestplugin.py Change-Id: I4cc39630724e810953cfda7b2afdadc8b948e3c2
* remove declarative warningsMike Bayer2021-09-291-1/+1
| | | | | | | * sqlalchemy.ext.declarative names * declarative_base(bind) Change-Id: I0ca26894b224458b58e46504c5ff7b5d3031a829
* Surface driver connection object when using a proxied dialectFederico Caselli2021-09-171-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix various lib / test / examples typos (#7017)Kevin Kirsche2021-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-4/+19
| | | | | | | | | | | | | | | 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
* Qualify server version call in PostgreSQLarredond2021-08-241-0/+48
| | | | | | | | | Fixes: #6912 Closes: #6920 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6920 Pull-request-sha: 79af75dfddef25435afd9623698354d280d7c879 Change-Id: Ib6b472452f978378d9f511d17a26988323a89459
* fix linter JOIN logic; fix PostgreSQL ARRAY op comparisonMike Bayer2021-08-151-0/+33
| | | | | | | | | | | | | | | | | | | 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
* Modernize tests - dml_valuesGord Thompson2021-07-261-36/+47
| | | | Change-Id: Ida86ed40c43d91813151621b847376976773a5f9
* Modernize tests - dml_whereclauseGord Thompson2021-07-261-2/+6
| | | | | | | | | Fixed issue where the unit of work would internally use a 2.0-deprecated SQL expression form, emitting a deprecation warning when SQLALCHEMY_WARN_20 were enabled. Fixes: #6812 Change-Id: I0a031e728527a1c3382848b6ddc793939362b128
* Modernize tests - legacy_selectGord Thompson2021-07-211-1/+1
| | | | Change-Id: I04057cc3d3f93de60b02999803e2ba6a23cdf68d
* Merge "Extract format_constraint truncation rules to ON CONFLICT"mike bayer2021-07-131-0/+26
|\
| * Extract format_constraint truncation rules to ON CONFLICTMike Bayer2021-07-131-0/+26
| | | | | | | | | | | | | | | | | | | | | | 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 "implement independent CTEs"mike bayer2021-07-121-1/+25
|\ \
| * | implement independent CTEsMike Bayer2021-07-121-1/+25
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | Added new method :meth:`_sql.HasCTE.add_cte` to each of the :func:`_sql.select`, :func:`_sql.insert`, :func:`_sql.update` and :func:`_sql.delete` constructs. This method will add the given :class:`_sql.CTE` as an "independent" CTE of the statement, meaning it renders in the WITH clause above the statement unconditionally even if it is not otherwise referenced in the primary statement. This is a popular use case on the PostgreSQL database where a CTE is used for a DML statement that runs against database rows independently of the primary statement. Fixes: #6752 Change-Id: Ibf635763e40269cbd10f4c17e208850d8e8d0188
* | Merge "Modernize tests - select(whereclause)"mike bayer2021-07-121-63/+91
|\ \
| * | Modernize tests - select(whereclause)Gord Thompson2021-07-041-63/+91
| |/ | | | | | | Change-Id: I306cfbea9920b35100e3087dcc21d7ffa6c39c55
* | repair schema_translate_map for schema type use casesMike Bayer2021-07-111-0/+48
|/ | | | | | | | | | | | | 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
* Modernize testsGord Thompson2021-07-032-38/+47
| | | | | | Eliminate engine.execute() and engine.scalar() Change-Id: I99f76d0e615ddebab2da4fd07a40a0a2796995c7
* apply quoting to "ON CONSTRAINT" symbolMike Bayer2021-06-301-0/+26
| | | | | | | | | | Fixed issue in :meth:`_postgresql.Insert.on_conflict_do_nothing` and :meth:`_postgresql.Insert.on_conflict_do_update` where the name of a unique constraint passed as the ``constraint`` parameter would not be properly quoted if it contained characters which required quoting. Fixes: #6696 Change-Id: I4ffca9b8c72cef4ed39e2de96831ccc11a620422
* Add impl property to PostgreSQL / Oracle INTERVAL classMajorDallas2021-06-221-0/+4
| | | | | | | | | | | | | | Fixed issue where the ``INTERVAL`` datatype on PostgreSQL and Oracle would produce an ``AttributeError`` when used in the context of a comparison operation against a ``timedelta()`` object. Pull request courtesy MajorDallas. Fixes: #6649 Closes: #6650 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6650 Pull-request-sha: dd217a975e5f0d3157e81c731791225b6a32889f Change-Id: I773caf2673294fdb3c92b42895ad714e944d1bf8
* set autocommit for psycopg2 pre-pingMike Bayer2021-06-111-30/+52
| | | | | | | | | Fixed issue where the pool "pre ping" feature would implicitly start a transaction, which would then interfere with custom transactional flags such as PostgreSQL's "read only" mode when used with the psycopg2 driver. Fixes: #6621 Change-Id: I29117c393e50c090cc2587efcccfe1e986738928
* don't enable "fast insert executemany" for ON CONFLICT etcMike Bayer2021-06-041-0/+29
| | | | | | | | | | | | | Fixed issue where using the PostgreSQL "INSERT..ON CONFLICT" structure would fail to work with the psycopg2 driver if it were used in an "executemany" context along with bound parameters in the "SET" clause, due to the implicit use of the psycopg2 fast execution helpers which are not appropriate for this style of INSERT statement. Additional checks to exclude this kind of statement from that particular extension have been added. Fixes: #6581 Change-Id: I3d6169e7e188dc087d1d1bfba9a42162db183265
* Test some complex update cases in the pg dialectFederico Caselli2021-05-271-0/+154
| | | | Change-Id: I2323e155e78aa8e1e00359b103974fb8d27d80eb
* Update black flak8 and zimportsFederico Caselli2021-05-122-2/+2
| | | | Change-Id: I488c9557eda390e4a88319affd4c8813ee274f80
* don't cache TypeDecorator by defaultMike Bayer2021-05-063-0/+7
| | | | | | | | | | The :class:`.TypeDecorator` class will now emit a warning when used in SQL compilation with caching unless the ``.cache_ok`` flag is set to ``True`` or ``False``. ``.cache_ok`` indicates that all the parameters passed to the object are safe to be used as a cache key, ``False`` means they are not. Fixes: #6436 Change-Id: Ib1bb7dc4b124e38521d615c2e2e691e4915594fb
* Merge "Propertly ignore ``Identity`` in MySQL and MariaDb."mike bayer2021-04-291-3/+35
|\
| * Propertly ignore ``Identity`` in MySQL and MariaDb.Federico Caselli2021-04-281-3/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | have SchemaType inherit schema from metadataMike Bayer2021-04-271-0/+64
|/ | | | | | | | | | Fixed very old issue where the :class:`_types.Enum` datatype would not inherit the :paramref:`_schema.MetaData.schema` parameter of a :class:`_schema.MetaData` object when that object were passed to the :class:`_types.Enum` using :paramref:`_types.Enum.metadata`. Fixes: #6373 Change-Id: Ie77d5e8cbc0bd7bfd0039fb60a4a0bde2df58ca9
* Add pgcode / sqlstate for asyncpg error messageMike Bayer2021-04-051-0/+24
| | | | | | | | | | | Added accessors ``.sqlstate`` and synonym ``.pgcode`` to the ``.orig`` attribute of the SQLAlchemy exception class raised by the asyncpg DBAPI adapter, that is, the intermediary exception object that wraps on top of that raised by the asyncpg library itself, but below the level of the SQLAlchemy dialect. Fixes: #6199 Change-Id: Ie0f1ffaaff47c7a50dd1fbccdbe588cdc5322b70
* unfail test_uuid_array for pg8000Mike Bayer2021-04-031-1/+1
| | | | | | seems to pass as of pg8000 1.19.1 Change-Id: I1c496b6055fd5dfe0df63f92a4f9363938c32aed
* Merge "Apply quoting to render_derived() names"mike bayer2021-04-011-0/+22
|\
| * Apply quoting to render_derived() namesMike Bayer2021-04-011-0/+22
| | | | | | | | | | | | | | | | | | | | Fixed bug in new :meth:`_functions.FunctionElement.render_derived` feature where column names rendered out explicitly in the alias SQL would not have proper quoting applied for case sensitive names and other non-alphanumeric names. Fixes: #6183 Change-Id: I33e2534affc6e1f449f564750028fd027cb0f352
* | Correct for Variant + ARRAY cases in psycopg2Mike Bayer2021-04-011-7/+26
|/ | | | | | | | | | | | | | Fixed regression caused by :ticket:`6023` where the PostgreSQL cast operator applied to elements within an :class:`_types.ARRAY` when using psycopg2 would fail to use the correct type in the case that the datatype were also embedded within an instance of the :class:`_types.Variant` adapter. Additionally, repairs support for the correct CREATE TYPE to be emitted when using a ``Variant(ARRAY(some_schema_type))``. Fixes: #6182 Change-Id: I1b9ba7c876980d4650715a0b0801b46bdc72860d
* Repair PGInspectorMike Bayer2021-03-311-10/+53
| | | | | | | | | | | Fixed issue where the PostgreSQL :class:`.PGInspector`, when generated against an :class:`_engine.Engine`, would fail for ``.get_enums()``, ``.get_view_names()``, ``.get_foreign_table_names()`` and ``.get_table_oid()`` when used against a "future" style engine and not the connection directly. Fixes: #6170 Change-Id: I8c3abdfb758305c2f7a96002d3644729f29c998b
* Refine domain nullable rules for PostgreSQL reflectionMike Bayer2021-03-301-0/+21
| | | | | | | | | Fixed issue in PostgreSQL reflection where a column expressing "NOT NULL" will supersede the nullability of a corresponding domain. Fixes #6161 Change-Id: I1a3de49afcdb952f71bd7a7cc7b264513c93eff5
* Fixed reflection of identity columns in tablesFederico Caselli2021-03-251-21/+25
| | | | | | | with mixed case names in PostgreSQL. Fixes: #6129 Change-Id: I50480cec03fcb44a668c9b0f9c72950803b771d9
* Remove unneeded importMike Bayer2021-03-161-5/+0
| | | | | | | | | | this import forgot to get removed from Ia7519ac4371a635f05ac69a3a4d0f4e6d2f04cad , removing it in post-production. We will need "enum" soon enough when we go to Python 3 only. Change-Id: I28297c2ed9f87fd0841076b861b8eeb610754dc3
* CAST the elements in ARRAYs when using psycopg2Federico Caselli2021-03-152-14/+317
| | | | | | | | | | | | Adjusted the psycopg2 dialect to emit an explicit PostgreSQL-style cast for bound parameters that contain ARRAY elements. This allows the full range of datatypes to function correctly within arrays. The asyncpg dialect already generated these internal casts in the final statement. This also includes support for array slice updates as well as the PostgreSQL-specific :meth:`_postgresql.ARRAY.contains` method. Fixes: #6023 Change-Id: Ia7519ac4371a635f05ac69a3a4d0f4e6d2f04cad
* Fix aggregate_order_by issueGord Thompson2021-03-041-3/+22
| | | | | | | | | | Fixes: #5989 Using array_agg() with aggregate_order_by() in postgresql would sometimes return ARRAY(NullType) instead of ARRAY(actual_type). Change-Id: I05a0b2b7ea59291e3c04575578adcc337296e5a8
* Deprecate and rename schema .copy() methodsGord Thompson2021-02-181-1/+1
| | | | | Fixes: #5953 Change-Id: I1e69a1628e408f06b43efbc0cc52fc0ad1e8cbc4