Commit Graph

119 Commits

Author SHA1 Message Date
Mike Bayer 9ed36c2eed - Fixed the `.python_type attribute of :class:.postgresql.INTERVAL`
to return ``datetime.timedelta`` in the same way as that of
:obj:`.types.Interval.python_type`, rather than raising
``NotImplementedError``.
fixes #3571

(cherry picked from commit 29d6f6e19b)
2015-11-19 15:11:37 -05:00
Mike Bayer 14498364f8 - Added support for reflecting the source of materialized views
to the Postgresql version of the :meth:`.Inspector.get_view_definition`
method.
fixes #3587
2015-11-18 09:06:33 -05:00
Mike Bayer affcfd1e52 - modernize some very old global-engine tests w/ bad teardowns 2015-10-11 12:26:45 -04:00
Mike Bayer e6779d8437 - repair flake8 issues 2015-10-11 12:08:53 -04:00
Mike Bayer 2a8a06e33a - repair laziness about setting time zone here, which is leaking
out depending on connection pool state
2015-10-11 12:00:39 -04:00
Mike Bayer 414af7b612 - The system by which a :class:.Column considers itself to be an
"auto increment" column has been changed, such that autoincrement
is no longer implicitly enabled for a :class:`.Table` that has a
composite primary key.  In order to accommodate being able to enable
autoincrement for a composite PK member column while at the same time
maintaining SQLAlchemy's long standing behavior of enabling
implicit autoincrement for a single integer primary key, a third
state has been added to the :paramref:`.Column.autoincrement` parameter
``"auto"``, which is now the default. fixes #3216
- The MySQL dialect no longer generates an extra "KEY" directive when
generating CREATE TABLE DDL for a table using InnoDB with a
composite primary key with AUTO_INCREMENT on a column that isn't the
first column;  to overcome InnoDB's limitation here, the PRIMARY KEY
constraint is now generated with the AUTO_INCREMENT column placed
first in the list of columns.
2015-10-07 10:02:45 -04:00
Mike Bayer 371f1a82c5 - The use of a :class:.postgresql.ARRAY object that refers
to a :class:`.types.Enum` or :class:`.postgresql.ENUM` subtype
will now emit the expected "CREATE TYPE" and "DROP TYPE" DDL when
the type is used within a "CREATE TABLE" or "DROP TABLE".
fixes #2729
2015-09-19 11:58:50 -04:00
Mike Bayer ed535649d4 - The :class:.TypeDecorator type extender will now work in conjunction
with a :class:`.SchemaType` implementation, typically :class:`.Enum`
or :class:`.Boolean` with regards to ensuring that the per-table
events are propagated from the implementation type to the outer type.
These events are used
to ensure that the constraints or Postgresql types (e.g. ENUM)
are correctly created (and possibly dropped) along with the parent
table.
fixes #2919
2015-08-27 18:04:25 -04:00
Mike Bayer 410be197ef - add a postgresql-specific form of array_agg() that injects the
ARRAY type, references #3132
2015-08-27 11:22:05 -04:00
Mike Bayer 5295a683f9 - add PG-specific aggregate_order_by(), references #3132 2015-08-27 10:32:21 -04:00
Mike Bayer 7c4512cbeb - Added support for "set-aggregate" functions of the form
``<function> WITHIN GROUP (ORDER BY <criteria>)``, using the
method :class:`.FunctionElement.within_group`.  A series of common
set-aggregate functions with return types derived from the set have
been added. This includes functions like :class:`.percentile_cont`,
:class:`.dense_rank` and others.
fixes #1370
- make sure we use func.name for all _literal_as_binds in functions.py
so we get consistent naming behavior for parameters.
2015-08-26 17:19:27 -04:00
Mike Bayer cfae9c2eaf - Added support for the SQL-standard function :class:.array_agg,
which automatically returns an :class:`.Array` of the correct type
and supports index / slice operations.   As arrays are only
supported on Postgresql at the moment, only actually works on
Postgresql. fixes #3132
2015-08-26 15:15:55 -04:00
Mike Bayer 7024745a14 - build out a new base type for Array, as well as new any/all operators
- any/all work for Array as well as subqueries, accepted by MySQL
- Postgresql ARRAY now subclasses Array
- fixes #3516
2015-08-25 18:24:46 -04:00
Mike Bayer b653fedca5 - fix the postgresql_jsonb requirement to include the 9.4 requirement
- new test for json col['x']['y']['z'] seems to fail pre PG 9.4,
fails on comparisons for non-compatible data instead of not matching
- no need to call SpecPredicate(db) directly in exclusion functions,
by using Predicate.as_predicate() the spec strings can have version
comparisons
2015-08-18 13:30:21 -04:00
Mike Bayer d14a4b480c - merge of ticket_3514 None-handling branch
- Fixes to the ORM and to the postgresql JSON type regarding the
``None`` constant in conjunction with the Postgresql :class:`.JSON` type.  When
the :paramref:`.JSON.none_as_null` flag is left at its default
value of ``False``, the ORM will now correctly insert the Json
"'null'" string into the column whenever the value on the ORM
object is set to the value ``None`` or when the value ``None``
is used with :meth:`.Session.bulk_insert_mappings`,
**including** if the column has a default or server default on it.  This
makes use of a new type-level flag "evaluates_none" which is implemented
by the JSON type based on the none_as_null flag. fixes #3514
- Added a new constant :attr:`.postgresql.JSON.NULL`, indicating
that the JSON NULL value should be used for a value
regardless of other settings. part of fixes #3514
2015-08-17 17:12:16 -04:00
Mike Bayer ceeb033054 - merge of ticket_3499 indexed access branch
- The "hashable" flag on special datatypes such as :class:`.postgresql.ARRAY`,
:class:`.postgresql.JSON` and :class:`.postgresql.HSTORE` is now
set to False, which allows these types to be fetchable in ORM
queries that include entities within the row.  fixes #3499
- The Postgresql :class:`.postgresql.ARRAY` type now supports multidimensional
indexed access, e.g. expressions such as ``somecol[5][6]`` without
any need for explicit casts or type coercions, provided
that the :paramref:`.postgresql.ARRAY.dimensions` parameter is set to the
desired number of dimensions. fixes #3487
- The return type for the :class:`.postgresql.JSON` and :class:`.postgresql.JSONB`
when using indexed access has been fixed to work like Postgresql itself,
and returns an expression that itself is of type :class:`.postgresql.JSON`
or :class:`.postgresql.JSONB`.  Previously, the accessor would return
:class:`.NullType` which disallowed subsequent JSON-like operators to be
used. part of fixes #3503
- The :class:`.postgresql.JSON`, :class:`.postgresql.JSONB` and
:class:`.postgresql.HSTORE` datatypes now allow full control over the
return type from an indexed textual access operation, either ``column[someindex].astext``
for a JSON type or ``column[someindex]`` for an HSTORE type,
via the :paramref:`.postgresql.JSON.astext_type` and
:paramref:`.postgresql.HSTORE.text_type` parameters. also part of fixes #3503
- The :attr:`.postgresql.JSON.Comparator.astext` modifier no longer
calls upon :meth:`.ColumnElement.cast` implicitly, as PG's JSON/JSONB
types allow cross-casting between each other as well.  Code that
makes use of :meth:`.ColumnElement.cast` on JSON indexed access,
e.g. ``col[someindex].cast(Integer)``, will need to be changed
to call :attr:`.postgresql.JSON.Comparator.astext` explicitly.  This is
part of the refactor in references #3503 for consistency in operator
use.
2015-08-17 17:07:10 -04:00
Mike Bayer 9e092e3394 - An adjustment to the new Postgresql feature of reflecting storage
options and USING of 🎫`3455` released in 1.0.6,
to disable the feature for Postgresql versions < 8.2 where the
``reloptions`` column is not provided; this allows Amazon Redshift
to again work as it is based on an 8.0.x version of Postgresql.
Fix courtesy Pete Hollobon.
references #3455
2015-07-24 12:24:18 -04:00
Pete Hollobon e3c8eabb28 Fix typo 2015-06-22 14:54:21 +01:00
Mike Bayer e625d2ea88 - for #3455
- changelog
- versionadded + reflink for new pg storage parameters doc
- pep8ing
- add additional tests to definitely check that the Index object
is created all the way with the opts we want
fixes #3455
2015-06-19 14:10:47 -04:00
Mike Bayer 99ceed3e55 Merge remote-tracking branch 'origin/pr/179' into pr179 2015-06-19 13:45:01 -04:00
Mike Bayer 4a25c10e27 - Repaired the :class:.ExcludeConstraint construct to support common
features that other objects like :class:`.Index` now do, that
the column expression may be specified as an arbitrary SQL
expression such as :obj:`.cast` or :obj:`.text`.
fixes #3454
2015-06-16 14:33:53 -04:00
Mike Bayer 4e6ec9eef4 - Repaired some typing and test issues related to the pypy
psycopg2cffi dialect, in particular that the current 2.7.0 version
does not have native support for the JSONB type.  The version detection
for psycopg2 features has been tuned into a specific sub-version
for psycopg2cffi.  Additionally, test coverage has been enabled
for the full series of psycopg2 features under psycopg2cffi.
fixes #3439
2015-06-05 17:34:02 -04:00
Pete Hollobon af19435b9c Add reflection of PostgreSQL index access methods (USING clause) 2015-06-04 16:45:41 +01:00
Pete Hollobon b03ee45f32 Add reflection of PostgreSQL index storage options 2015-06-04 15:12:09 +01:00
Pete Hollobon dff81500b1 Add support for PostgreSQL index storage parameters
Add support for specifying PostgreSQL index storage paramters (e.g.
fillfactor).
2015-06-03 17:32:12 +01:00
Mike Bayer a50dcb31b9 - Fixed bug where known boolean values used by
:func:`.engine_from_config` were not being parsed correctly;
these included ``pool_threadlocal`` and the psycopg2 argument
``use_native_unicode``. fixes #3435
- add legacy_schema_aliasing config parsing for mssql
- move use_native_unicode config arg to the psycopg2 dialect
2015-05-26 10:56:23 -04:00
Mike Bayer ecd7b31d5e - Fixed a long-standing bug where the :class:.Enum type as used
with the psycopg2 dialect in conjunction with non-ascii values
and ``native_enum=False`` would fail to decode return results properly.
This stemmed from when the PG :class:`.postgresql.ENUM` type used
to be a standalone type without a "non native" option.
fixes #3354
- corrected the assertsql comparison rule to expect a non-ascii
SQL string
2015-04-04 12:02:51 -04:00
Mike Bayer 4b16493548 - Fixed bug where updated PG index reflection as a result of
🎫`3184` would cause index operations to fail on Postgresql
versions 8.4 and earlier.  The enhancements are now
disabled when using an older version of Postgresql.
fixes #3343
2015-04-01 16:50:32 -04:00
Mike Bayer 71b8df2e53 - The Postgresql :class:.postgresql.ENUM type will emit a
DROP TYPE instruction when a plain ``table.drop()`` is called,
assuming the object is not associated directly with a
:class:`.MetaData` object.   In order to accomodate the use case of
an enumerated type shared between multiple tables, the type should
be associated directly with the :class:`.MetaData` object; in this
case the type will only be created at the metadata level, or if
created directly.  The rules for create/drop of
Postgresql enumerated types have been highly reworked in general.
fixes #3319
2015-03-11 11:41:52 -04:00
Mike Bayer 7ac81f6d0a Merge branch 'postgres-concurrently' of https://bitbucket.org/iurisilvio/sqlalchemy into pr45 2015-03-10 15:00:21 -04:00
Mike Bayer cfb2eee0f3 - add a skip for JSONB on pg8000 if we are on 1.10.1 or earlier 2015-03-02 19:16:37 -05:00
Mike Bayer d140983148 Merge remote-tracking branch 'origin/pr/132' into pr132 2015-03-02 19:00:19 -05:00
Iuri de Silvio 955576fcf6 Dialect option postgresql_concurrently to Index construct. 2015-02-25 21:05:31 -03:00
Tony Locke 8038cfa077 pg8000 client_encoding in create_engine()
The pg8000 dialect now supports the setting of the PostgreSQL parameter
client_encoding from create_engine().
2014-12-16 20:55:55 +00:00
Mike Bayer f5ff86983f - The :meth:.Operators.match operator is now handled such that the
return type is not strictly assumed to be boolean; it now
returns a :class:`.Boolean` subclass called :class:`.MatchType`.
The type will still produce boolean behavior when used in Python
expressions, however the dialect can override its behavior at
result time.  In the case of MySQL, while the MATCH operator
is typically used in a boolean context within an expression,
if one actually queries for the value of a match expression, a
floating point value is returned; this value is not compatible
with SQLAlchemy's C-based boolean processor, so MySQL's result-set
behavior now follows that of the :class:`.Float` type.
A new operator object ``notmatch_op`` is also added to better allow
dialects to define the negation of a match operation.
fixes #3263
2014-12-04 18:29:56 -05:00
Mike Bayer 87bfcf91e9 - The :meth:.PGDialect.has_table method will now query against
``pg_catalog.pg_table_is_visible(c.oid)``, rather than testing
for an exact schema match, when the schema name is None; this
so that the method will also illustrate that temporary tables
are present.  Note that this is a behavioral change, as Postgresql
allows a non-temporary table to silently overwrite an existing
temporary table of the same name, so this changes the behavior
of ``checkfirst`` in that unusual scenario.
fixes #3264
2014-12-04 12:01:19 -05:00
Mike Bayer b510b99094 - use provide_metadata for new unique constraint / index tests
- add a test for PG reflection of unique index without any unique
constraint
- for PG, don't include 'duplicates_constraint' in the entry
if the index does not actually mirror a constraint
- use a distinct method for unique constraint reflection within table
- catch unique constraint not implemented condition; this may
be within some dialects and also is expected to be supported by
Alembic tests
- migration + changelogs for #3184
- add individual doc notes as well to MySQL, Postgreql
fixes #3184
2014-10-04 19:06:35 -04:00
Johannes Erdfelt 7fa21b2298 Reflect unique constraints when reflecting a Table object
Calls to reflect a table did not create any UniqueConstraint objects.
The reflection core made no calls to get_unique_constraints and as
a result, the sqlite dialect would never reflect any unique constraints.

MySQL transparently converts unique constraints into unique indexes, but
SQLAlchemy would reflect those as an Index object and as a
UniqueConstraint. The reflection core will now deduplicate the unique
constraints.

PostgreSQL would reflect unique constraints as an Index object and as
a UniqueConstraint object. The reflection core will now deduplicate
the unique indexes.
2014-09-17 13:19:50 -07:00
Mike Bayer be57def4b9 - repair get_foreign_table_names() for PGInsp/dialect level
- repair get_view_names()
- changelog + migration note
2014-09-17 13:11:22 -04:00
Mike Bayer 414bc1c64d - the actual round trip requires password authent set up for the user;
we don't actually need a round trip test here as we're only testing reflection.
2014-09-17 12:41:08 -04:00
Mike Bayer 8546153d5d - break out and fix tests for materialized view and foreign tables. foreign tables not working 2014-09-16 17:24:34 -04:00
Mike Bayer ecda5429af Merge remote-tracking branch 'origin/pr/128' into pr128 2014-09-16 16:55:05 -04:00
Rodrigo Menezes fd2faa9bc2 Added documentation. Changed my mind - added get_foreign_table_names() only to PGInspect and not in the Dialect. Added tests for PGInspect and removed a bunch of the old test scaffolding. 2014-09-05 13:54:48 -04:00
Rodrigo Menezes fbd2d70a5c Fixing some pep8s and adding get_foreign_tables. 2014-09-03 16:38:43 -04:00
Mike Bayer 7c6a45c480 - The :func:~.expression.column and :func:~.expression.table
constructs are now importable from the "from sqlalchemy" namespace,
just like every other Core construct.
- The implicit conversion of strings to :func:`.text` constructs
when passed to most builder methods of :func:`.select` as
well as :class:`.Query` now emits a warning with just the
plain string sent.   The textual conversion still proceeds normally,
however.  The only method that accepts a string without a warning
are the "label reference" methods like order_by(), group_by();
these functions will now at compile time attempt to resolve a single
string argument to a column or label expression present in the
selectable; if none is located, the expression still renders, but
you get the warning again. The rationale here is that the implicit
conversion from string to text is more unexpected than not these days,
and it is better that the user send more direction to the Core / ORM
when passing a raw string as to what direction should be taken.
Core/ORM tutorials have been updated to go more in depth as to how text
is handled.
fixes #2992
2014-09-01 20:19:54 -04:00
Rodrigo Menezes b3f7cd8bf4 Merge branch 'master' of https://github.com/zzzeek/sqlalchemy into feature/postgres-relkind 2014-08-26 12:57:00 -04:00
Rodrigo Menezes 2f7dce1d6f Removed all mentions to postgresql_relkind 2014-08-26 12:53:34 -04:00
Mike Bayer b490534657 - pep8 formatting for pg table opts feature, tests
- add support for PG INHERITS
- fix mis-named tests
- changelog
fixes #2051
2014-08-23 15:21:16 -04:00
Malik Diarra 9eacc8d42a Correcting options name from withoids to with_oids 2014-08-17 02:48:21 +02:00
Malik Diarra 8e03430acd quoting tablespace name in create table command in postgresql dialect 2014-08-17 01:56:02 +02:00