summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Add "eager_parenthesis" late-compilation rule, use w/ PG JSON/HSTOREMike Bayer2016-10-011-0/+2
| | | | | | | | | | | | Added compiler-level flags used by Postgresql to place additional parenthesis than would normally be generated by precedence rules around operations involving JSON, HSTORE indexing operators as well as within their operands since it has been observed that Postgresql's precedence rules for at least the HSTORE indexing operator is not consistent between 9.4 and 9.5. Fixes: #3806 Change-Id: I5899677b330595264543b055abd54f3c76bfabf2
* Enable include_table for ON CONFLICT whereclausesMike Bayer2016-09-281-2/+1
| | | | | | | | | Fixed issue in new PG "on conflict" construct where columns including those of the "excluded" namespace would not be table-qualified in the WHERE clauses in the statement. Change-Id: Idfefc93e7e7b0d84805e23d5436d822d606f6a0a Fixes: #3807
* Fix table reference in PostgreSQL documentationpr/303Michael Williamson2016-08-281-1/+1
|
* Repair PG BIGSERIAL w/ TypeDecorator, VariantMike Bayer2016-07-041-0/+3
| | | | | | | | | | | | | Some of the dialect impl memoization for TypeDecorator necessarily keeps the top-level TypeDecorator type around, since a user-defined type will have bind and result set processing behavior. For both TypeDecorator and Variant, PG dialect needs to ensure it's looking at the SQLAlchemy type to check for SmallInteger / BigInteger. Fixes: 3739 Change-Id: I2d45fb997f17c6272d6bb826a77d2dba665adae7 (cherry picked from commit 421fa6b8bf9f0c3c5041579c89ec405ce0f5e0b0)
* Add ON CONFLICT support for PostgresqlRobin Thomas2016-06-141-9/+263
| | | | | | | Fixes: #3529 Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: Ie3bf6ad70d9be9f0e44938830e922db03573991a Pull-request: https://github.com/zzzeek/sqlalchemy/pull/258
* Support `postgresql_concurrently` on index dropping.Iuri de Silvio2016-06-081-5/+36
| | | | | | | | | | | | Also adds version detection so that DROP INDEX CONCURRENTLY only renders if the Postgresql version is 9.2 or higher; for CREATE INDEX CONCURRENTLY, version detection is added to allow the phrase to omit if the Postgresql version is less than 8.2. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I597287e0ebbbe256c957a3579b58ace6848ab4f4 Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/84
* Merge "Support normal /materialized views in PG separately"mike bayer2016-06-081-2/+36
|\
| * Support normal /materialized views in PG separatelySebastian Bank2016-06-061-2/+36
| | | | | | | | | | | | Fixes: #3588 Change-Id: Ifbfcab67375f289ddb5c4522f4b803cb8b7c34de Pull-request: https://github.com/zzzeek/sqlalchemy/pull/250
* | Add 'FOR NO KEY UPDATE' / 'FOR KEY SHARE' support for PostgresqlSergey Skopin2016-06-081-1/+6
|/ | | | | | | | Adds ``key_share=True`` for with_for_update(). Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I74e0c3fcbc023e1dc98a1fa0c7db67b4c3693a31 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/279
* Merge "Refine PG inspection methods"mike bayer2016-06-061-94/+34
|\
| * Refine PG inspection methodsSebastian Bank2016-06-061-94/+34
| | | | | | | | | | | | | | | | | | | | This refines get_schema_names(), get_table_names(), get_view_defintion(), _get_foreign_table_names(), and get_view_names() to use better queries and remove unnecessary explicit encoding logic. Pull-request: https://github.com/zzzeek/sqlalchemy/pull/250 Change-Id: I7e87b29c34b97b37f21bbc83392b2274af4db0ab
* | Replace some uses of re.sub with str.lstrip/replaceVille Skyttä2016-06-061-1/+1
|/ | | | | Change-Id: I98cd60b6830ee94e39ba9307523a9e8fb93bf4e8 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/280
* Add SKIP LOCKED support for Postgresql, OracleJack Zhou2016-06-021-0/+2
| | | | | | | | This adds `SELECT ... FOR UPDATE SKIP LOCKED`/ `SELECT ... FOR SHARE SKIP LOCKED` rendering. Change-Id: Id1dc4f1cafc1de23f397a6f73d54ab2c58d5910d Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/86
* Add postgresql_tablespace option on Indexbeenje2016-06-011-1/+19
| | | | | | | | | This complements the same-named parameter available on Table. Fixes: #3720 Change-Id: I56e081e2a551f37c3f392ca4b301c9ef82b94e59 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/233
* Implemented CHECK constraint reflection for SQLite and PostgreSQLAlex Grönholm2016-06-011-0/+25
| | | | | | Co-Authored-By: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: Ie6cf2d2958d1c567324db9e08fef2d3186e97350 Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/80
* - Add support for PostgreSQL with PyGreSQLChristoph Zwerschke2016-04-151-1/+3
| | | | | Change-Id: I040b75ff3b4110e7e8b26442a4eb226ba8c26715 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/234
* - Added :meth:`.Select.lateral` and related constructs to allowMike Bayer2016-03-291-0/+1
| | | | | for the SQL standard LATERAL keyword, currently only supported by Postgresql. fixes #2857
* - changelog and docs for #3332, fixes #3332Mike Bayer2016-03-151-6/+4
| | | | | | - make docs for isolation level more consistent between postgresql and mysql - move mysql autocommit tests
* - happy new yearMike Bayer2016-01-291-1/+1
|
* Fix ArrayOfEnum's handling of empty arrays.pr/229Chase2016-01-191-1/+1
| | | Prior to this change a value of `'{}'` would split into the list `['']`.
* - reorganize schema_translate_map to be succinct and gain the performanceMike Bayer2016-01-111-2/+2
| | | | back by using an attrgetter for the default case