summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql
Commit message (Collapse)AuthorAgeFilesLines
* - dialects passes flake8Mike Bayer2019-01-051-1/+1
| | | | Change-Id: I9fa269423619c1adfbaa6d63e0997153ea115d73
* flake8 refactor - dialectsMike Bayer2019-01-059-72/+91
| | | | | | | | | | | | A full rewrite of all imports and pep8 formatting using zimports, black, commits are broken into sections. Directories included in this commit: lib/sqlalchemy/dialects/ lib/sqlalchemy/databases/ lib/sqlalchemy/connectors/ Change-Id: I7070d589303a760e6ed5eefde39efc11da818281 (cherry picked from commit aa46e6a9e2e3cd04f835c53ed4600e6f8e9ee13f)
* partial cherry-pick of master flake8. clean cherrypick for lib and test,Mike Bayer2019-01-053-12/+8
| | | | | | | manually merged exaples. Change-Id: I9532d3b13d13f2769e6ca48eea23dd7d4041f68f (cherry picked from commit e3bdd80c6661c0e95fb67998c57540be667ce761)
* - do a broken zimports run on libMike Bayer2019-01-0512-138/+136
|
* step 1, straight black -l 79 runMike Bayer2019-01-0514-941/+1486
| | | | includes adjustment to setup.py to recognize __version__ correctly
* 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 (cherry picked from commit 0b0a4c8ba2465fce5fa1954a0d31b44840f1b4b8)
* 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 (cherry picked from commit 46f9c3c7d4d2c31f3f1627dcf777bd3215e13e3d)
* Minor cosmetic tweaks to reST markupLele Gaifax2018-11-031-9/+10
| | | | (cherry picked from commit e0dd82f26703f56e5fda7fb6deb579d1f96ecab9)
* Import from collections.abcxtreak2018-09-271-3/+2
| | | | | | | | | | | | | | | Fixed additional warnings generated by Python 3.7 due to changes in the organization of the Python ``collections`` and ``collections.abc`` packages. Previous ``collections`` warnings were fixed in version 1.2.11. Pull request courtesy xtreak. See I2d1c0ef97c8ecac7af152cc56263422a40faa6bb for the original collections.abc fixes. Fixes: #4339 Change-Id: Ia92d2461f20309fb33ea6c6f592f7d4e7e32ae7a Pull-request: https://github.com/zzzeek/sqlalchemy/pull/475 (cherry picked from commit 2d2fa49130249f757f6f1100dad879e1071ad385)
* Accept multiple expressions for aggregate_order_by order_byMike Bayer2018-09-251-2/+13
| | | | | | | | | Added support for the :class:`.aggregate_order_by` function to receive multiple ORDER BY elements, previously only a single element was accepted. Fixes: #4337 Change-Id: I411ac31697a0d65b568ad65ce5b5181717afbd65 (cherry picked from commit b7ba3f0d9395236cbf05f830d82f6494163d1dfb)
* minor spelling correctionGlyph2018-09-071-1/+1
| | | | (cherry picked from commit 35a458c7822a8071a61da84fce021fb42cd9b086)
* 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 (cherry picked from commit 469931514a1517dde82ba56f780c3007c66d5943)
* Pass desired array type from pg.array_agg to functions.array_aggMike Bayer2018-08-221-2/+3
| | | | | | | | | | | | Fixed the :func:`.postgresql.array_agg` function, which is a slightly altered version of the usual :func:`.functions.array_agg` function, to also accept an incoming "type" argument without forcing an ARRAY around it, essentially the same thing that was fixed for the generic function in 1.1 in :ticket:`4107`. Fixes: #4324 Change-Id: I399a29f59c945a217cdd22c65ff0325edea8ea65 (cherry picked from commit 52a3f5b7635583ae6feb084b1db654b9c65caec2)
* 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 (cherry picked from commit 32ce703a98eba8a7685e609b4a7ca86b79dd0904)
* - 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 (cherry picked from commit 513a6e5bcea5dccabaf86166906233542a4669e7)
* 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 (cherry picked from commit b4eb29253cb29a069973503f36d1103d4a18311c)
* Use base __ne__ implementation for range types w/ NoneMike Bayer2018-04-031-1/+5
| | | | | | | | | | | | | Fixed bug where the special "not equals" operator for the Postgresql "range" datatypes such as DATERANGE would fail to render "IS NOT NULL" when compared to the Python ``None`` value. Also break up range tests into backend round trip and straight compilation suites. Change-Id: Ibaee132b1ea7dac8b799495a27f98f82a7d9c028 Fixes: #4229 (cherry picked from commit e1ac5dc63cc13cfbabe0ec7fbb3521bfb1b7b750)
* Add postgresl.REGCLASS type for casting table names to OIDs and vice versaSebastian Bank2018-04-032-3/+17
| | | | | | | Fixes: #4160 Change-Id: Id0bdbad1be3a0950dc8f35895ee13d9264244722 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/435 (cherry picked from commit 9f986ce10c6755af3f347a56f9ea03e0e2c5943e)
* 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 (cherry picked from commit 0174d698a8ed155b51cc44c503b10bc67b16dfc9)
* 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 ssl "operation timed out" message for psycopg2André Cruz2018-02-151-0/+1
| | | | | | | | | Added "SSL SYSCALL error: Operation timed out" to the list of messages that trigger a "disconnect" scenario for the psycopg2 driver. Pull request courtesy André Cruz. Change-Id: Ie1a8fc97e74b6906ccacf53dad70fed973c42b7f Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/3
* 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
* Convert dialect modules to relative imports and testMike Bayer2018-02-051-7/+8
| | | | | | | | For some reason the dialects were not consistently converted to relative imports. Also added a test to ensure that __all__ is functioning within each dialect. Change-Id: I8450ed724473be7e17678e9aba7ba0f661fdf134
* happy new yearMike Bayer2018-01-1214-14/+14
| | | | 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-162-2/+16
| | | | | Change-Id: I2b40faf583a84bc5b416e1ad3aa812896ea67a8c Pull-request: https://github.com/zzzeek/sqlalchemy/pull/395
* Fix as many RST parse warnings as possible.Mike Bayer2017-11-032-40/+41
| | | | | | | Still a few I can't get. Also 0.9 is EOL so hide the unreleased notes. Change-Id: If0e44d4a0b3e78e211f32d5c33b51b1a007c9c69
* Add fast execution helper support.Mike Bayer2017-10-101-1/+45
| | | | | | | | | | | | Added a new flag ``use_batch_mode`` to the psycopg2 dialect. This flag enables the use of psycopg2's ``psycopg2.extras.execute_batch`` extension when the :class:`.Engine` calls upon ``cursor.executemany()``. This extension provides a critical performance increase by over an order of magnitude when running INSERT statements in batch. The flag is False by default as it is considered to be experimental for now. Change-Id: Ib88d28bc792958d47109f644ff1d08c897db4ff7 Fixes: #4109
* - 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-252-5/+22
| | | | | | | | | | | | | | 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
* Use text_type, not unicodeMike Bayer2017-08-311-1/+1
| | | | | | | Revise the fix from 03560c4b83308719067ec635662c35f9a437fb7f to use compat.text_type for py3k compatibility Change-Id: Ia6807bd4de3bba4b33b5327a1be7e728b45eb093
* Enable uuid for pg8000Mike Bayer2017-08-081-2/+26
| | | | | | | | | Enabled UUID support for the pg8000 driver, which supports native Python uuid round trips for this datatype. Arrays of UUID are still not supported, however. Change-Id: I44ca323c5d9f2cd87327210233bc36a3556eb050 Fixes: #4016
* Add quoted_name to pg8000 py_typesMike Bayer2017-08-081-0/+6
| | | | | | | | | | | Fixed bug where the pg8000 driver would fail if using :meth:`.MetaData.reflect` with a schema name, since the schema name would be sent as a "quoted_name" object that's a string subclass, which pg8000 doesn't recognize. The quoted_name type is added to pg8000's py_types collection on connect. Change-Id: Id0f838320cb66563685e094e4eae2d5116100d27 Fixes: #4041
* 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
* Set up base ARRAY to be compatible with postgresql.ARRAY.Mike Bayer2017-04-111-14/+3
| | | | | | | | | | For some reason, when ARRAY was added to the base it was never linked to postgresql.ARRAY. Link the two types and also make base ARRAY the schema event target so that it supports the same features as postgresql.ARRAY. Change-Id: I82fa6c9d2b8c5028dba3a009715f7bc296b2bc0b Fixes: #3964
* 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
* Double percent signs based on paramstyle, not dialectMike Bayer2017-04-051-9/+2
| | | | | | | | | | | | This patch moves the "doubling" of percent signs into the base compiler and makes it completely a product of whether or not the paramstyle is format/pyformat or not. Without this paramstyle, percent signs are not doubled across text(), literal_column(), and column(). Change-Id: Ie2f278ab1dbb94b5078f85c0096d74dbfa049197 Fixes: #3740
* 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
* Copy whereclause / using in ExcludeConstraintMike Bayer2017-01-301-1/+3
| | | | | | | | | Fixed bug in Postgresql :class:`.ExcludeConstraint` where the "whereclause" and "using" parameters would not be copied during an operation like :meth:`.Table.tometadata`. Change-Id: I2f704981d4d4862f9c82a50272006fab8becebb6 Fixes: #3900
* - document that "column" and "where" are arbitrary SQL expressionsMike Bayer2017-01-261-3/+51
| | | | | | | for ExcludeConstraint, if string is used then quoting must be applied manually. fixes #3899 Change-Id: I5885c90179e4056b84fc4776464bba7c8c70a80a
* 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