Commit Graph

92 Commits

Author SHA1 Message Date
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
Malik Diarra d6873904c4 Adding oids and on_commit table options 2014-08-17 01:56:02 +02:00
Malik Diarra ef6042ff46 Adding a tablespace options for postgresql create table 2014-08-17 01:56:02 +02:00
Rodrigo Menezes 8af9c7670e Merge branch 'master' of https://github.com/rclmenezes/sqlalchemy 2014-08-14 17:08:55 -04:00
Rodrigo Menezes 649f06759d Added support for postgres_relkind. 2014-08-14 14:47:23 -04:00
Mike Bayer f39767ad72 - public method name is get_enums()
- return a list of dicts like other methods do
- don't combine 'schema' with 'name', leave them separate
- support '*' argument so that we can retrieve cross-schema
if needed
- remove "conn" argument
- use bound parameters for 'schema' in SQL
- order by schema, name, label
- adapt _load_enums changes to column reflection
- changelog
- module docs for get_enums()
- add drop of enums to --dropfirst
2014-08-13 17:42:33 -04:00
Ilya Pekelny a0e0f4c289 Public inspector method to load enum list
Provide opportunity to get enums list via an inspector instance public
interface.
2014-08-08 10:05:30 +03:00
Mike Bayer 3c6ff6adae -Fixed bug where Postgresql JSON type was not able to persist or
otherwise render a SQL NULL column value, rather than a JSON-encoded
``'null'``.  To support this case, changes are as follows:

* The value :func:`.null` can now be specified, which will always
  result in a NULL value resulting in the statement.

* A new parameter :paramref:`.JSON.none_as_null` is added, which
  when True indicates that the Python ``None`` value should be
  peristed as SQL NULL, rather than JSON-encoded ``'null'``.

Retrival of NULL as None is also repaired for DBAPIs other than
psycopg2, namely pg8000.

fixes #3159
2014-08-07 10:43:55 -04:00
Mike Bayer 83326bf44c - The exception wrapping system for DBAPI errors can now accommodate
non-standard DBAPI exceptions, such as the psycopg2
TransactionRollbackError.  These exceptions will now be raised
using the closest available subclass in ``sqlalchemy.exc``, in the
case of TransactionRollbackError, ``sqlalchemy.exc.OperationalError``.
fixes #3075
2014-07-29 14:06:43 -04:00
Mike Bayer 54592942c4 - add support for tags, including include/exclude support.
simplify tox again now that we can exclude tests more easily
2014-07-27 18:46:20 -04:00
Mike Bayer d92177cede - Fixed bug in :class:.postgresql.array object where comparison
to a plain Python list would fail to use the correct array constructor.
Pull request courtesy Andrew.  fixes #3141
2014-07-25 16:08:21 -04:00
Mike Bayer 31178db914 - flake8 all of test/dialect/postgresql
- add __backend__ to most tests so that pg8000 can start coming in
2014-07-25 16:04:35 -04:00
jonathan vanasco c996b76d5b - add postgresql_regconfig argument to PG dialect for match() operator,
implements PG's to_tsquery('regconfig', 'arg') pattern. fixes #3078
2014-07-08 18:18:04 -04:00
Damian Dimmich ceeee81017 jsonb support for <@, ?| and ?& added.
need to see if equality already works.
2014-07-01 13:24:30 +04:00
Damian Dimmich 7f402761d9 it's OK to pass a dict in - it does the right thing, no need to quote it
in the tests.
2014-06-28 23:24:36 +04:00
Damian Dimmich 4eca136e09 minor cleanup of the jsonb - had extraneous operators that where copied
from hstore that don't apply.

Add tests for ? and @> operators.
2014-06-28 23:11:03 +04:00
Damian Dimmich f509260202 and tests for JSONB - as this is a superset of JSON i've subclassed
the JSON tests as all of these should be applicable as well.
2014-06-28 20:02:24 +04:00
Mike Bayer 42bbb7163a - Added a new type :class:.postgresql.OID to the Postgresql dialect.
While "oid" is generally a private type within PG that is not exposed
in modern versions, there are some PG use cases such as large object
support where these types might be exposed, as well as within some
user-reported schema reflection use cases.
fixes #3002
2014-06-20 17:58:06 -04:00
Mike Bayer f000161f24 Merge branch 'master' of https://github.com/tlocke/sqlalchemy into tlocke-master 2014-05-30 12:08:26 -04:00
Mike Bayer e384347ffb - Added the `hashable=False flag to the PG :class:.HSTORE` type, which
is needed to allow the ORM to skip over trying to "hash" an ORM-mapped
HSTORE column when requesting it in a mixed column/entity list.
Patch courtesy Gunnlaugur Þór Briem.  Fixes #3053
2014-05-25 13:58:08 -04:00
Tony Locke f8f29d0a10 PEP 8 tidy of pg8000 dialect and postgresql/test_dialect.py 2014-05-22 20:36:27 +01:00
Tony Locke 66e0a7771f Autocommit isolation level for postgresql+pg8000
As with postgresql+psycopg2,
execution_options(isolation_level='AUTOCOMMIT') now works for the
postgresql+pg8000 dialect.

Also enabled the autocommit test in test_dialect.py for pg8000.
2014-05-22 20:13:10 +01:00
Tony Locke fc4e113cf1 pg8000 now passes test_extract() test 2014-05-21 19:17:41 +01:00
Tony Locke 30af311628 Two tests now work for pg800 in EnumTest
The two tests, test_create_table() and test_unicode_labels() previously
failed under pg8000, but now they pass, so this commit opens them up.
2014-05-21 19:17:41 +01:00
Mike Bayer 460465a874 - changelog for #2785
- refactor tests a bit
fixes #2785
2014-05-16 13:09:50 -04:00
Alexey Terentev 57b6da9d40 zero_indexes-param-for-postgresql-ARRAY-type 2014-05-13 15:48:29 +04:00
Alex Gaynor 1caa7fafbd Fix many typos throughout the codebase
Found using: https://github.com/intgr/topy
2014-04-26 13:13:13 -07:00
Mike Bayer b2189da650 - Repaired support for Postgresql UUID types in conjunction with
the ARRAY type when using psycopg2.  The psycopg2 dialect now
employs use of the psycopg2.extras.register_uuid() hook
so that UUID values are always passed to/from the DBAPI as
UUID() objects.   The :paramref:`.UUID.as_uuid` flag is still
honored, except with psycopg2 we need to convert returned
UUID objects back into strings when this is disabled.
fixes #2940
2015-02-01 19:03:08 -05:00