summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Render correct DDL for unsetting table commentsMike Bayer2019-01-091-0/+5
| | | | | | | | | Fixed issue where the DDL emitted for :class:`.DropTableComment`, which will be used by an upcoming version of Alembic, was incorrect for the MySQL and Oracle databases. Fixes: #4436 Change-Id: I196de09495a37adface4caa9dcbc29a6d0ad159a
* Post black reformattingMike Bayer2019-01-061-33/+49
| | | | | | | | | | | | | Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
* Run black -l 79 against all source filesMike Bayer2019-01-061-578/+859
| | | | | | | | | | | | | | This is a straight reformat run using black as is, with no edits applied at all. The black run will format code consistently, however in some cases that are prevalent in SQLAlchemy code it produces too-long lines. The too-long lines will be resolved in the following commit that will resolve all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
* Handle PostgreSQL enums in remote schemasMike Bayer2018-12-211-23/+33
| | | | | | | | | | | | | | | | | | Fixed issue where a :class:`.postgresql.ENUM` or a custom domain present in a remote schema would not be recognized within column reflection if the name of the enum/domain or the name of the schema required quoting. A new parsing scheme now fully parses out quoted or non-quoted tokens including support for SQL-escaped quotes. Fixed issue where multiple :class:`.postgresql.ENUM` objects referred to by the same :class:`.MetaData` object would fail to be created if multiple objects had the same name under different schema names. The internal memoization the Postgresql dialect uses to track if it has created a particular :class:`.postgresql.ENUM` in the database during a DDL creation sequence now takes schema name into account. Fixes: #4416 Change-Id: I8cf03069e10b12f409e9b6796e24fc5850979955
* Fix PostgreSQL reflection of domains expressed as arraysJakub Synowiec2018-12-011-3/+10
| | | | | | | | | Fixed issue where reflection of a PostgreSQL domain that is expressed as an array would fail to be recognized. Pull request courtesy Jakub Synowiec. Fixes: #4377 Change-Id: I252c79ca435b87d4d9172b1c84e0e74e789ef676 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4380
* Merge remote-tracking branch 'origin/pr/450'Mike Bayer2018-11-031-18/+19
|\ | | | | | | Change-Id: I50c0dd75199a34f68f9a2fa0f89208a887193969
| * Minor cosmetic tweaks to reST markupLele Gaifax2018-06-151-9/+10
| |
| * Fix typoLele Gaifax2018-06-151-1/+1
| |
| * Consistently use "PostgreSQL", fixing a couple of mistypesLele Gaifax2018-06-151-8/+8
| |
* | Support tuples of heterogeneous types for empty expanding INMike Bayer2018-10-031-5/+8
| | | | | | | | | | | | | | | | | | Pass a list of all the types for the left side of an IN expression to the visit_empty_set_expr() method, so that the "empty expanding IN" can produce clauses for each element. Fixes: #4271 Change-Id: I2738b9df2292ac01afda37f16d4fa56ae7bf9147
* | Add reflection support for Postgresql partitioned tablesMike Bayer2018-10-011-2/+3
| | | | | | | | | | | | | | | | | | Added rudimental support for reflection of Postgresql partitioned tables, e.g. that relkind='p' is added to reflection queries that return table information. Fixes: #4237 Change-Id: I66fd10b002e4ed21ea13b13a7e35a85f66bdea75
* | Propagate **kw in postgresql distinct on compilationMike Bayer2018-08-221-1/+1
| | | | | | | | | | | | | | | | | | Fixed bug in PostgreSQL dialect where compiler keyword arguments such as ``literal_binds=True`` were not being propagated to a DISTINCT ON expression. Fixes: #4325 Change-Id: I9949387dceb7fabe889799f42e92423572368b29
* | Strip quotes from format_type in addition to other charactersMike Bayer2018-08-211-1/+3
| | | | | | | | | | | | | | | | | | | | Fixed bug in PostgreSQL ENUM reflection where a case-sensitive, quoted name would be reported by the query including quotes, which would not match a target column during table reflection as the quotes needed to be stripped off. Fixes: #4323 Change-Id: I668f3acccc578e58f23b70c82d31d5c1ec194913
* | Add support of empty list in exanding of bindparamNicolas Rolin2018-08-071-0/+9
|/ | | | | | | | | | | Added new logic to the "expanding IN" bound parameter feature whereby if the given list is empty, a special "empty set" expression that is specific to different backends is generated, thus allowing IN expressions to be fully dynamic including empty IN expressions. Fixes: #4271 Change-Id: Icc3c73bbd6005206b9d06baaeb14a097af5edd36 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/432
* - add a tl;dr to postgresql search_path section as it's longMike Bayer2018-05-061-0/+3
| | | | | | and will be easier to read if we know where it's going first. Change-Id: I2766cf4655451ed514d4dc95ac60406b9f4a8ddb
* Ensure all visit_sequence accepts **kw argsMike Bayer2018-04-041-1/+1
| | | | | | | | | | Fixed issue where the compilation of an INSERT statement with the "literal_binds" option that also uses an explicit sequence and "inline" generation, as on Postgresql and Oracle, would fail to accommodate the extra keyword argument within the sequence processing routine. Change-Id: Ibdab7d340aea7429a210c9535ccf1a3e85f074fb Fixes: #4231
* Add postgresl.REGCLASS type for casting table names to OIDs and vice versaSebastian Bank2018-04-031-0/+14
| | | | | | Fixes: #4160 Change-Id: Id0bdbad1be3a0950dc8f35895ee13d9264244722 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/435
* Add support for declarative partitioning in PostgreSQL 10Vsevolod Solovyov2018-03-301-1/+12
| | | | | | | | | Added support for "PARTITION BY" in Postgresql table definitions, using "postgresql_partition_by". Pull request courtesy Vsevolod Solovyov. Change-Id: Id74d6882d7193fae1e5fd44b6e12d6852866fcc4 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/430
* Only replace first occurrence for COLLATE/ARRAY syntaxMike Bayer2018-03-051-1/+2
| | | | | | | | | Fixed bug in Postgresql COLLATE / ARRAY adjustment first introduced in :ticket:`4006` where new behaviors in Python 3.7 regular expressions caused the fix to fail. Change-Id: Ied3893d7cac210befa0277b55b3b895b0ba1f0d2 Fixes: #4208
* Add values_callable feature to EnumJon Snyder2018-02-071-0/+1
| | | | | | | | | | | | Added support for :class:`.Enum` to persist the values of the enumeration, rather than the keys, when using a Python pep-435 style enumerated object. The user supplies a callable function that will return the string values to be persisted. This allows enumerations against non-string values to be value-persistable as well. Pull request courtesy Jon Snyder. Pull-request: https://github.com/zzzeek/sqlalchemy/pull/410 Fixes: #3906 Change-Id: Id385465d215d1e5baaad68368b168afdd846b82c
* happy new yearMike Bayer2018-01-121-1/+1
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* Add TRUNCATE to postgres autocommit regexpJacob Hayes2017-12-181-1/+1
| | | | | | | Extends AUTOCOMMIT_REGEXP for the postgres dialect to include `TRUNCATE`. Change-Id: I315e03674b89bb89aae669b8655481e4d890491e Pull-request: https://github.com/zzzeek/sqlalchemy/pull/407
* Allow delete where clause to refer multiple tables.inytar2017-12-051-0/+17
| | | | | | | | | | | | | | | | | | | | | Implemented "DELETE..FROM" syntax for Postgresql, MySQL, MS SQL Server (as well as within the unsupported Sybase dialect) in a manner similar to how "UPDATE..FROM" works. A DELETE statement that refers to more than one table will switch into "multi-table" mode and render the appropriate "USING" or multi-table "FROM" clause as understood by the database. Pull request courtesy Pieter Mulder. For SQL syntaxes see: Postgresql: https://www.postgresql.org/docs/current/static/sql-delete.html MySQL: https://dev.mysql.com/doc/refman/5.7/en/delete.html#multiple-table_syntax MSSQL: https://docs.microsoft.com/en-us/sql/t-sql/statements/delete-transact-sql Sybase: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc00801.1510/html/iqrefso/X315721.htm Co-authored by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I6dfd57b49e44a095d076dc493cd2360bb5d920d3 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/392 Fixes: #959
* Add postgresql.MONEYCleber J Santos2017-11-161-0/+14
| | | | | Change-Id: I2b40faf583a84bc5b416e1ad3aa812896ea67a8c Pull-request: https://github.com/zzzeek/sqlalchemy/pull/395
* - add a note how to generate pg10 IDENTITY for nowMike Bayer2017-10-091-2/+36
| | | | Change-Id: I22dbf6ba322904a80c6df46f6a31daa2fcc1f946
* Accomodate for multidimensional array in rewriting for COLLATEMike Bayer2017-09-271-2/+4
| | | | | | | | | Made further fixes to the :class:`.ARRAY` class in conjunction with COLLATE, as the fix made in :ticket:`4006` failed to accommodate for a multidimentional array. Change-Id: If3e438f8ce94ebae2196671c88a4914f3b743e60 Fixes: #4006
* Make a common approach for "emulated" typesMike Bayer2017-09-251-4/+21
| | | | | | | | | | | | | | Internal refinements to the :class:`.Enum`, :class:`.Interval`, and :class:`.Boolean` types, which now extend a common mixin :class:`.Emulated` that indicates a type that provides Python-side emulation of a DB native type, switching out to the DB native type when a supporting backend is in use. The Postgresql :class:`.INTERVAL` type when used directly will now include the correct type coercion rules for SQL expressions that also take effect for :class:`.sqltypes.Interval` (such as adding a date to an interval yields a datetime). Change-Id: Ifb9f9d7cbd9f5990dcb2abb583193e9e92b789ad Fixes: #4088
* use the stack to get the insert statement in on conflictticket_4074Mike Bayer2017-09-121-1/+3
| | | | | | | | | Fixed bug in Postgresql :meth:`.postgresql.dml.Insert.on_conflict_do_update` which would prevent the insert statement from being used as a CTE, e.g. via :meth:`.Insert.cte`, within another statement. Change-Id: Ie20972a05e194290bc9d92819750845872949ecc Fixes: #4074
* Render ARRAY index embedded between type and COLLATEMike Bayer2017-06-081-3/+9
| | | | | | | | | | | | | | | | Fixed bug where using :class:`.ARRAY` with a string type that features a collation would fail to produce the correct syntax within CREATE TABLE. The "COLLATE" must appear to the right of the array dimensions, so we are using regexp substitution to insert the brackets in the appropriate place. A more heavyweight solution would be that datatypes know how to split up their base type vs. modifiers, but as this is so specific to Postgresql ARRAY it's better to handle these cases more locally. Change-Id: I394c3c673eb60689e51b5301e51651972cfdb4c0 Fixes: #4006
* Parse for Postgresql version w/ "beta"Mike Bayer2017-06-071-1/+1
| | | | | | | | | | | | | Continuing with the fix that correctly handles Postgresql version string "10devel" released in 1.1.8, an additional regexp bump to handle version strings of the form "10beta1". While Postgresql now offers better ways to get this information, we are sticking w/ the regexp at least through 1.1.x for the least amount of risk to compatibility w/ older or alternate Postgresql databases. Change-Id: I12ddb06465f7dcf80563c27632441ef5963f60d4 Fixes: #4005
* Support autocommit for GRANT and REVOKE on postgresqlJacob Hayes2017-05-091-1/+1
| | | | | | | Extends `AUTOCOMMIT_REGEXP` for the postgres dialect to include `GRANT` and `REVOKE`. Change-Id: Iba15f1ebf5bd7bc0fc1193fdf561417e53bf5d57 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/357
* test / document postgresql_ops against a labeled expressionMike Bayer2017-04-241-8/+19
| | | | | | | | | | Since postgresql_ops explicitly states that it expects string keys, to apply to a function call or expression one needs to give the SQL expression a label that can be referred to by name in the dictionary. test / document this. Change-Id: I4bc4ade46dac27f9c1b92e7823433292beab97b9 Fixes: #3970
* Support Postgresql INTERVAL fields spec/reflectionMike Bayer2017-04-051-8/+22
| | | | | | | | | | | | | Added support for all possible "fields" identifiers when reflecting the Postgresql ``INTERVAL`` datatype, e.g. "YEAR", "MONTH", "DAY TO MINUTE", etc.. In addition, the :class:`.postgresql.INTERVAL` datatype itself now includes a new parameter :paramref:`.postgresql.INTERVAL.fields` where these qualifiers can be specified; the qualifier is also reflected back into the resulting datatype upon reflection / inspection. Change-Id: I33816e68c533b023e0632db6f4e73fefd2de4721 Fixes: #3959
* Support Postgresql development version numbersSean McCully2017-03-291-1/+1
| | | | | | | | | Added support for parsing the Postgresql version string for a development version like "PostgreSQL 10devel". Pull request courtesy Sean McCully. Change-Id: I7bc18bc4d290349c23e9796367b7d694d0873096 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/351
* Implement comments for tables, columnsFrazer McLean2017-03-171-5/+30
| | | | | | | | | | | | | | Added support for SQL comments on :class:`.Table` and :class:`.Column` objects, via the new :paramref:`.Table.comment` and :paramref:`.Column.comment` arguments. The comments are included as part of DDL on table creation, either inline or via an appropriate ALTER statement, and are also reflected back within table reflection, as well as via the :class:`.Inspector`. Supported backends currently include MySQL, Postgresql, and Oracle. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #1546 Change-Id: Ib90683850805a2b4ee198e420dc294f32f15d35d
* Repair missing "checkfirst" for test suiteMike Bayer2017-03-071-4/+4
| | | | | | | | the test_metadata tests trigger the before_create dispatch without the checkfirst flag. Postgresql backend should be able to tolerate this. Change-Id: Ife497cc3a4eb2812462116f94aad732864225f3f
* Add new DDL autocommit expressions for PostgresqlMike Bayer2017-02-131-0/+8
| | | | | | | | | | | | | | Added regular expressions for the "IMPORT FOREIGN SCHEMA", "REFRESH MATERIALIZED VIEW" Postgresql statements so that they autocommit when invoked via a connection or engine without an explicit transaction. Pull requests courtesy Frazer McLean and Paweł Stiasny. Fixes: #3840 Co-authored-by: Frazer McLean Co-authored-by: Paweł Stiasny Change-Id: I92b2b61683d29d57fa23a66a3559120cb1241c2f Pull-request: https://github.com/zzzeek/sqlalchemy/pull/323
* Improve server-side Sequence documentationMike Bayer2017-01-191-0/+1
| | | | | | | | | | | | Include the metadata argument for the Sequence and explain the rationale. Correct inconsistencies between Core / ORM examples and update language regarding client side vs. server side Sequence directive. Co-authored-by: Stéphane Raimbault <stephane.raimbault@gmail.com> Change-Id: I65c522acf9bdf25041a5baf2e10be41f0927999a Pull-request: https://github.com/zzzeek/sqlalchemy/pull/341
* Merge "Use full column->type processing for ON CONFLICT SET clause"mike bayer2017-01-131-10/+46
|\
| * Use full column->type processing for ON CONFLICT SET clauseMike Bayer2017-01-131-10/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug in new "ON CONFLICT DO UPDATE" feature where the "set" values for the UPDATE clause would not be subject to type-level processing, as normally takes effect to handle both user-defined type level conversions as well as dialect-required conversions, such as those required for JSON datatypes. Additionally, clarified that the keys in the set_ dictionary should match the "key" of the column, if distinct from the column name. A warning is emitted for remaining column names that don't match column keys; for compatibility reasons, these are emitted as they were previously. Fixes: #3888 Change-Id: I67a04c67aa5f65e6d29f27bf3ef2f8257088d073
* | Merge "Support python3.6"mike bayer2017-01-131-10/+10
|\ \ | |/ |/|
| * Support python3.6Mike Bayer2017-01-131-10/+10
| | | | | | | | | | | | | | | | | | | | | | Corrects some warnings and adds tox config. Adds DeprecationWarning to the error category. Large sweep for string literals w/ backslashes as this is common in docstrings Co-authored-by: Andrii Soldatenko Fixes: #3886 Change-Id: Ia7c838dfbbe70b262622ed0803d581edc736e085 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/337
* | - document how to use autocommit isolation level for CONCURRENTLY,Mike Bayer2017-01-121-0/+19
|/ | | | | | fixes #3887 Change-Id: I6d1a13b7bb4169204105c7a100d17cfed3ded9d1
* Merge "update for 2017 copyright"mike bayer2017-01-091-1/+1
|\
| * update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | | | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* | - add a section for ARRAY of JSON to complement ARRAY of ENUM. references #3467Mike Bayer2017-01-051-0/+23
|/ | | | Change-Id: I9836b842be01ef24138071fa022d80f5f77be14f
* Allow the value 0 for Postgresql TIME/TIMESTAMP precisionIonuț Ciocîrlan2016-11-231-4/+4
| | | | | Change-Id: Ie38c48369222d95849645f027e2c659f503cfd53 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/322
* Put include_table=True for DO UPDATE..WHERE, but not ON CONFLICTMike Bayer2016-11-071-0/+1
| | | | | | | | | | | | | Fixed regression caused by the fix in :ticket:`3807` (version 1.1.0) where we ensured that the tablename was qualified in the WHERE clause of the DO UPDATE portion of PostgreSQL's ON CONFLICT, however you *cannot* put the table name in the WHERE clause in the actual ON CONFLICT itself. This was an incorrect assumption, so that portion of the change in :ticket:`3807` is rolled back. Change-Id: I442d8629496a8e405b54711cfcf487761810ae8a Fixes: #3846 Fixes: #3807
* Don't set pg autoincrement if type affinity is not IntegerMike Bayer2016-10-201-1/+2
| | | | | | | | | | | | | | | Postgresql table reflection will ensure that the :paramref:`.Column.autoincrement` flag is set to False when reflecting a primary key column that is not of an :class:`.Integer` datatype, even if the default is related to an integer-generating sequence. This can happen if a column is created as SERIAL and the datatype is changed. The autoincrement flag can only be True if the datatype is of integer affinity in the 1.1 series. This bug is related to a test failure in downstream sqlalchemy_migrate. Change-Id: I40260e47e1927a1ac940538408983c943bbdba28 Fixes: #3835
* spelling: Postgresql -> PostgreSQLVille Skyttä2016-10-081-45/+45
|