summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Repair PGInspectorMike Bayer2021-03-311-9/+17
| | | | | | | | | | | 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-2/+3
| | | | | | | | | 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-4/+3
| | | | | | | with mixed case names in PostgreSQL. Fixes: #6129 Change-Id: I50480cec03fcb44a668c9b0f9c72950803b771d9
* Rename column name that used a reserved wordFederico Caselli2021-03-171-1/+1
| | | | | | | | Rename column name used by a reflection query that used a reserved word in some postgresql compatible databases. Fixes: #6082 Change-Id: Ie81983316b72601a2e34543fa5ee95371e68aaf5
* fix typoMike Bayer2021-03-171-1/+1
| | | | Change-Id: I7afb81cfa4f8041181c24666bb9acd71ff45692b
* Add supported database version for internal dialectsFederico Caselli2021-03-071-0/+3
| | | | Change-Id: I08d150f1780a0f3a848c0edcd40013b5593d18f0
* document TypeDecorator schemes for MONEYMike Bayer2021-02-221-1/+35
| | | | | | | | this type apparently returns strings so document cast/processing options. Change-Id: Idc19527dcf76e1c2d966425716c0fcf60cbba5dc References: #5965
* Typo stream_resuls -> stream_resultsCharlie Denton2021-02-191-1/+1
|
* Add identifier_preparer per-execution context for schema translatesMike Bayer2021-02-081-1/+1
| | | | | | | | | | | 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
* Implement support for functions as FROM with columns clause supportMike Bayer2021-02-031-25/+163
| | | | | | | | | | | | | | | | Implemented support for "table valued functions" along with additional syntaxes supported by PostgreSQL, one of the most commonly requested features. Table valued functions are SQL functions that return lists of values or rows, and are prevalent in PostgreSQL in the area of JSON functions, where the "table value" is commonly referred towards as the "record" datatype. Table valued functions are also supported by Oracle and SQL Server. Moved from I5b093b72533ef695293e737eb75850b9713e5e03 due to accidental push Fixes: #3566 Change-Id: Iea36d04c80a5ed3509dcdd9ebf0701687143fef5
* Fix many spell glitches in docstrings and commentsLele Gaifax2021-01-241-4/+4
| | | | | | | | | | 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
* ``Identity`` implies ``nullable=False``.Federico Caselli2021-01-161-4/+5
| | | | | | | | | | | | | | | Altered the behavior of the :class:`_schema.Identity` construct such that when applied to a :class:`_schema.Column`, it will automatically imply that the value of :paramref:`_sql.Column.nullable` should default to ``False``, in a similar manner as when the :paramref:`_sql.Column.primary_key` parameter is set to ``True``. This matches the default behavior of all supporting databases where ``IDENTITY`` implies ``NOT NULL``. The PostgreSQL backend is the only one that supports adding ``NULL`` to an ``IDENTITY`` column, which is here supported by passing a ``True`` value for the :paramref:`_sql.Column.nullable` parameter at the same time. Fixes: #5775 Change-Id: I0516d506ff327cff35cda605e8897a27440e0373
* update execute() arg formats in modules and testsMike Bayer2021-01-151-3/+11
| | | | | | | | | | | | | continuing with producing a SQLAlchemy 1.4.0b2 that internally does not emit any of its own 2.0 deprecation warnings, migrate the *args and **kwargs passed to execute() methods that now must be a single list or dictionary. Alembic 1.5 is again waiting on this internal consistency to be present so that it can pass all tests with no 2.0 deprecation warnings. Change-Id: If6b792e57c8c5dff205419644ab68e631575a2fa
* happy new yearMike Bayer2021-01-041-1/+1
| | | | Change-Id: Ic5bb19ca8be3cb47c95a0d3315d84cb484bac47c
* Merge "Support IF EXISTS/IF NOT EXISTS for DDL constructs"mike bayer2020-12-141-0/+6
|\
| * Support IF EXISTS/IF NOT EXISTS for DDL constructsRamonWill2020-12-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added parameters :paramref:`_ddl.CreateTable.if_not_exists`, :paramref:`_ddl.CreateIndex.if_not_exists`, :paramref:`_ddl.DropTable.if_exists` and :paramref:`_ddl.DropIndex.if_exists` to the :class:`_ddl.CreateTable`, :class:`_ddl.DropTable`, :class:`_ddl.CreateIndex` and :class:`_ddl.DropIndex` constructs which result in "IF NOT EXISTS" / "IF EXISTS" DDL being added to the CREATE/DROP. These phrases are not accepted by all databases and the operation will fail on a database that does not support it as there is no similarly compatible fallback within the scope of a single DDL statement. Pull request courtesy Ramon Williams. Fixes: #2843 Closes: #5663 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5663 Pull-request-sha: 748b8472345d96efb446e2a444fbe020b313669f Change-Id: I6a2b1f697993ed49c31584f0a31887fb0a868ed3
* | Remove autoload=True referencesGord Thompson2020-12-121-3/+3
| | | | | | | | | | | | | | | | Remove references to deprecated ``autoload=True`` in docs and code samples. Also remove test/dialect/test_firebird.py and test/dialect/test_sybase.py as those tests have already been incorporated into the external dialects. Change-Id: I9788c27c971e3b2357f4cfa2d4698a6af727b073
* | Implement `TypeEngine.as_generic`Gord Thompson2020-12-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added :meth:`_types.TypeEngine.as_generic` to map dialect-specific types, such as :class:`sqlalchemy.dialects.mysql.INTEGER`, with the "best match" generic SQLAlchemy type, in this case :class:`_types.Integer`. Pull request courtesy Andrew Hannigan. Abstract away how we check for "overridden methods" so it is more clear what the intent is and that the methodology can be independently tested. Fixes: #5659 Closes: #5714 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5714 Pull-request-sha: 91afb9a0ba3bfa81a1ded80c025989213cf6e4eb Change-Id: Ic54d6690ecc10dc69e6e72856d5620036cea472a
* | Merge "improve cross-linking between Core /ORM for schema arg"mike bayer2020-12-011-0/+40
|\ \
| * | improve cross-linking between Core /ORM for schema argMike Bayer2020-11-301-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this should be backported to 1.3 as well to as much a degree as possible. Includes a new recipe to set the default schema name on connect. this will only work on 1.4, but also requires that we fix #5708 for it to work fully. Change-Id: I882edd5bbe06ee5b4d0a9c148854a57b2bcd4741
* | | Support Column objects in the SET clause for upsertMike Bayer2020-11-231-13/+19
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Established support for :class:`_schema.Column` objects as well as ORM instrumented attributes as keys in the ``set_`` dictionary passed to the :meth:`_postgresql.Insert.on_conflict_do_update` and :meth:`_sqlite.Insert.on_conflict_do_update` methods, which match to the :class:`_schema.Column` objects in the ``.c`` collection of the target :class:`_schema.Table`. Previously, only string column names were expected; a column expression would be assumed to be an out-of-table expression that would render fully along with a warning. Fixes: #5722 Change-Id: Ice73b501d721c28d978a0277a83cedc6aff756a9
* | Correct versionadded for #5604Mike Bayer2020-11-161-1/+1
| | | | | | | | Change-Id: I840a08253ecba1c8200c2dfd7f2c0b7b3598af0f
* | Add opsclass to exclusion constraintAlonM2020-11-161-7/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | Added new parameter :paramref:`_postgresql.ExcludeConstraint.ops` to the :class:`_postgresql.ExcludeConstraint` object, to support operator class specification with this constraint. Pull request courtesy Alon Menczer. Fixes: #5604 Closes: #5700 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5700 Pull-request-sha: f8613e100792fc0bb3cf300ec6aebc78ecdf0361 Change-Id: Iaf664131ec84f8c2fb05edf799198b8d3bb83597
* | don't check standard_conforming_strings less than server version 8.2Mike Bayer2020-11-131-6/+9
|/ | | | | | | | | | | Fixed a small regression where the query for "show standard_conforming_strings" upon initialization would be emitted even if the server version info were detected as less than version 8.2, previously it would only occur for server version 8.2 or greater. The query fails on Amazon Redshift which reports a PG server version older than this value. Fixes: #5698 Change-Id: Ib27ce4b05106d986a618597e4cf253504f981bf1
* Implement upsert for SQLiteRamonWill2020-11-081-19/+34
| | | | | | | | | | | | Implemented INSERT... ON CONFLICT clause for SQLite. Pull request courtesy Ramon Williams. Fixes: #4010 Closes: #5580 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5580 Pull-request-sha: fb422e0749fac442a455cbce539ef662d9512bc0 Change-Id: Ibeea44f4c2cee8dab5dc22b7ec3ae1ab95c12b65
* Allow dialect-specific stringificationMike Bayer2020-11-081-101/+146
| | | | | | | | | | | | | | | | | | Dialect-specific constructs such as :meth:`_postgresql.Insert.on_conflict_do_update` can now stringify in-place without the need to specify an explicit dialect object. The constructs, when called upon for ``str()``, ``print()``, etc. now have internal direction to call upon their appropriate dialect rather than the "default"dialect which doesn't know how to stringify these. The approach is also adapted to generic schema-level create/drop such as :class:`_schema.AddConstraint`, which will adapt its stringify dialect to one indicated by the element within it, such as the :class:`_postgresql.ExcludeConstraint` object. mostly towards being able to provide doctest-style examples for "on conflict" constructs using print statements. Change-Id: I4b855516fe6dee2df77744c1bb21a373d7fbab93
* Apply underscore naming to several more operatorsjonathan vanasco2020-10-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | The operator changes are: * `isfalse` is now `is_false` * `isnot_distinct_from` is now `is_not_distinct_from` * `istrue` is now `is_true` * `notbetween` is now `not_between` * `notcontains` is now `not_contains` * `notendswith` is now `not_endswith` * `notilike` is now `not_ilike` * `notlike` is now `not_like` * `notmatch` is now `not_match` * `notstartswith` is now `not_startswith` * `nullsfirst` is now `nulls_first` * `nullslast` is now `nulls_last` Because these are core operators, the internal migration strategy for this change is to support legacy terms for an extended period of time -- if not indefinitely -- but update all documentation, tutorials, and internal usage to the new terms. The new terms are used to define the functions, and the legacy terms have been deprecated into aliases of the new terms. Fixes: #5435 Change-Id: Ifbd7cb1cdda5981990243c4fc4b4ff467dc132ac
* Ensure no compiler visit method tries to access .statementMike Bayer2020-10-191-1/+1
| | | | | | | | | | | | Fixed structural compiler issue where some constructs such as MySQL / PostgreSQL "on conflict / on duplicate key" would rely upon the state of the :class:`_sql.Compiler` object being fixed against their statement as the top level statement, which would fail in cases where those statements are branched from a different context, such as a DDL construct linked to a SQL statement. Fixes: #5656 Change-Id: I568bf40adc7edcf72ea6c7fd6eb9d07790de189e
* Fetch first supportFederico Caselli2020-10-021-1/+20
| | | | | | | | | Add support to ``FETCH {FIRST | NEXT} [ count ] {ROW | ROWS} {ONLY | WITH TIES}`` in the select for the supported backends, currently PostgreSQL, Oracle and MSSQL. Fixes: #5576 Change-Id: Ibb5871a457c0555f82b37e354e7787d15575f1f7
* Add reflection for Identity columnsFederico Caselli2020-09-281-12/+43
| | | | | | | | | | | | | | | | | | | | | | | | | Added support for reflecting "identity" columns, which are now returned as part of the structure returned by :meth:`_reflection.Inspector.get_columns`. When reflecting full :class:`_schema.Table` objects, identity columns will be represented using the :class:`_schema.Identity` construct. Fixed compilation error on oracle for sequence and identity column ``nominvalue`` and ``nomaxvalue`` options that require no space in them. Improved test compatibility with oracle 18. As part of the support for reflecting :class:`_schema.Identity` objects, the method :meth:`_reflection.Inspector.get_columns` no longer returns ``mssql_identity_start`` and ``mssql_identity_increment`` as part of the ``dialect_options``. Use the information in the ``identity`` key instead. The mssql dialect will assume that at least MSSQL 2005 is used. There is no hard exception raised if a previous version is detected, but operations may fail for older versions. Fixes: #5527 Fixes: #5324 Change-Id: If039fe637c46b424499e6bac54a2cbc0dc54cb57
* upgrade to black 20.8b1Mike Bayer2020-09-281-6/+8
| | | | | | | It's better, the majority of these changes look more readable to me. also found some docstrings that had formatting / quoting issues. Change-Id: I582a45fde3a5648b2f36bab96bad56881321899b
* Don't change asyncpg's "char" codecMike Bayer2020-09-161-4/+8
| | | | | | | | | | | | | | This codec was used to ensure the "pg_attribute.generated" column comes back as a string and not bytes, matching how other PG drivers treat this datatype. However, this breaks asyncpg's internal implementation of set_type_codec going forward and the "char" datatype is actually a bytes in any case. So at the moment it appears psycopg2/pg8000 are broken for mis-treatment of the datatype and asyncpg is broken in that it was allowing us to change a codec that it appears to rely upon internally. Fixes: #5586 Change-Id: I937eba315904721aa4e2726b95432910a8affe5f
* Deprecate engine-wise ss cursors; repair mariadbconnectorMike Bayer2020-09-131-1/+30
| | | | | | | | | | | | | | | | | | | The server_side_cursors engine-wide feature relies upon regexp parsing of statements a well as general guessing as to when the feature should be used. This is not within the 2.0 way of doing things and should be removed. Additionally, mariadbconnector defaults to unbuffered cursors; add new cursor hooks so that mariadbconnector can specify buffered or unbuffered cursors without too much difficulty. This will also correctly default mariadbconnector to buffered cursors which should repair the segfaults we've been getting. Try to restore the assert_raises that was removed in 5b6dfc0c38bf1f01da4b8 to see if mariadbconnector segfaults are resolved. Change-Id: I77f1c972c742e40694972f578140bb0cac8c39eb
* Merge "Improve handling of covering indexes"mike bayer2020-09-121-7/+36
|\
| * Improve handling of covering indexesGord Thompson2020-09-121-7/+36
| | | | | | | | | | | | | | | | | | | | Improved support for covering indexes (with INCLUDE columns). Added the ability for postgresql to render CREATE INDEX statements with an INCLUDE clause from Core. Index reflection also report INCLUDE columns separately for both mssql and postgresql (11+). Fixes: #4458 Change-Id: If0b82103fbc898cdaeaf6a6d2d421c732744acd6
* | Merge "Do not specify type on mssql by default"mike bayer2020-09-121-1/+0
|\ \
| * | Do not specify type on mssql by defaultFederico Caselli2020-09-121-1/+0
| | | | | | | | | | | | | | | | | | | | | Make optional sequences render as identity in mssql Remove unused dialect option sequence_default_column_type Change-Id: I821eeffcb442f8d1b69186a9b798b15c3d8d6ff3
* | | Merge "Reflect mssql/postgresql filtered/partial indexes"mike bayer2020-09-121-9/+14
|\ \ \
| * | | Reflect mssql/postgresql filtered/partial indexesRamonWill2020-09-121-9/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added support for inspection / reflection of partial indexes / filtered indexes, i.e. those which use the ``mssql_where`` or ``postgresql_where`` parameters, with :class:`_schema.Index`. The entry is both part of the dictionary returned by :meth:`.Inspector.get_indexes` as well as part of a reflected :class:`_schema.Index` construct that was reflected. Pull request courtesy Ramon Williams. **Have a nice day!** Fixes: #4966 Closes: #5504 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5504 Pull-request-sha: b3018bac987081193b2e65cfdb6aeb7d5d270fcd Change-Id: Icbb2f93d1545700718ccb5222097185b815f5dbc
* | | | Update select usage to use the new 1.4 formatFederico Caselli2020-09-081-8/+6
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change includes mainly that the bracketed use within select() is moved to positional, and keyword arguments are removed from calls to the select() function. it does not yet fully address other issues such as keyword arguments passed to the table.select(). Additionally, allows False / None to both be considered as "disable" for all of select.correlate(), select.correlate_except(), query.correlate(), which establishes consistency with passing of ``False`` for the legact select(correlate=False) argument. Change-Id: Ie6c6e6abfbd3d75d4c8de504c0cf0159e6999108
* | | Merge "Create connection characteristics API; implement postgresql flags"mike bayer2020-09-081-0/+85
|\ \ \
| * | | Create connection characteristics API; implement postgresql flagsMike Bayer2020-09-081-0/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added support for PostgreSQL "readonly" and "deferrable" flags for all of psycopg2, asyncpg and pg8000 dialects. This takes advantage of a newly generalized version of the "isolation level" API to support other kinds of session attributes set via execution options that are reliably reset when connections are returned to the connection pool. Fixes: #5549 Change-Id: I0ad6d7a095e49d331618274c40ce75c76afdc7dd
* | | | PostgreSQL dialect-level isolation_level parameter is legacyMike Bayer2020-09-081-17/+29
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | The isolation level section in the docs inadvertently copied the PostgreSQL example using the PGDialect.isolation_level parameter and not the execution_options. ensure only the execution_options version is documented. Change-Id: I94e02ede62d3dded40e3fcbce8d04608dc063108
* | | Add support for regular expression on supported backend.Federico Caselli2020-08-271-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two operations have been defined: * :meth:`~.ColumnOperators.regexp_match` implementing a regular expression match like function. * :meth:`~.ColumnOperators.regexp_replace` implementing a regular expression string replace function. Fixes: #1390 Change-Id: I44556846e4668ccf329023613bd26861d5c674e6
* | | Updates for MariaDB sequencesFederico Caselli2020-08-221-1/+0
| |/ |/| | | | | | | | | | | | | | | | | | | | | MariaDB should not run a Sequence if it has optional=True. Additionally, rework the rules in crud.py to accommodate the new combination MariaDB brings us, which is a dialect that supports both cursor.lastrowid, explicit sequences, *and* no support for returning. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #5528 Change-Id: I9a8ea69a34983affa95dfd22186e2908fdf0d58c
* | Merge "Add support for identity columns"mike bayer2020-08-211-22/+60
|\ \ | |/ |/|
| * Add support for identity columnsFederico Caselli2020-08-191-22/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Added the :class:`_schema.Identity` construct that can be used to configure identity columns rendered with GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY. Currently the supported backends are PostgreSQL >= 10, Oracle >= 12 and MSSQL (with different syntax and a subset of functionalities). Fixes: #5362 Fixes: #5324 Fixes: #5360 Change-Id: Iecea6f3ceb36821e8b96f0b61049b580507a1875
* | Merge "normalize execute style for events, 2.0"mike bayer2020-08-201-8/+12
|\ \
| * | normalize execute style for events, 2.0Mike Bayer2020-08-201-8/+12
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | The _execute_20 and exec_driver_sql methods should wrap up the parameters so that they represent the single list / single dictionary style of invocation into the legacy methods. then the before_ after_ execute event handlers should be receiving the parameter dictionary as a single dictionary. this requires that we break out distill_params to work differently if event handlers are present. additionally, add deprecation warnings for old argument passing styles. Change-Id: I97cb4d06adfcc6b889f10d01cc7775925cffb116
* | Merge "Implement DDL visitor for PG ENUM with schema translate support"mike bayer2020-08-191-10/+47
|\ \