Commit Graph

55 Commits

Author SHA1 Message Date
Rodrigo Menezes 649f06759d Added support for postgres_relkind. 2014-08-14 14:47:23 -04: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 1a35188b69 - Fixed regression caused by release 0.8.5 / 0.9.3's compatibility
enhancements where index reflection on Postgresql versions specific
to only the 8.1, 8.2 series again
broke, surrounding the ever problematic int2vector type.  While
int2vector supports array operations as of 8.1, apparently it only
supports CAST to a varchar as of 8.3.
fix #3000
2014-03-25 12:26:42 -04:00
Mike Bayer ab2b3b0862 pytest calls all the descriptors. and we can't call this one unconditionally 2014-03-04 18:17:53 -05:00
Mike Bayer ea05a23218 - Support has been added for pytest to run tests. This runner
is currently being supported in addition to nose, and will likely
be preferred to nose going forward.   The nose plugin system used
by SQLAlchemy has been split out so that it works under pytest as
well.  There are no plans to drop support for nose at the moment
and we hope that the test suite itself can continue to remain as
agnostic of testing platform as possible.  See the file
README.unittests.rst for updated information on running tests
with pytest.

The test plugin system has also been enhanced to support running
tests against mutiple database URLs at once, by specifying the ``--db``
and/or ``--dburi`` flags multiple times.  This does not run the entire test
suite for each database, but instead allows test cases that are specific
to certain backends make use of that backend as the test is run.
When using pytest as the test runner, the system will also run
specific test suites multiple times, once for each database, particularly
those tests within the "dialect suite".   The plan is that the enhanced
system will also be used by Alembic, and allow Alembic to run
migration operation tests against multiple backends in one run, including
third-party backends not included within Alembic itself.
Third party dialects and extensions are also encouraged to standardize
on SQLAlchemy's test suite as a basis; see the file README.dialects.rst
for background on building out from SQLAlchemy's test platform.
2014-03-03 15:55:17 -05:00
Mike Bayer ecdfc31774 - Support has been improved for Postgresql reflection behavior on very old
(pre 8.1) versions of Postgresql, and potentially other PG engines
such as Redshift (assuming Redshift reports the version as < 8.1).
The query for "indexes" as well as "primary keys" relies upon inspecting
a so-called "int2vector" datatype, which refuses to coerce to an array
prior to 8.1 causing failures regarding the "ANY()" operator used
in the query.  Extensive googling has located the very hacky, but
recommended-by-PG-core-developer query to use when PG version < 8.1
is in use, so index and primary key constraint reflection now work
on these versions.
2014-02-18 18:35:23 -05:00
Mike Bayer 0326f3cf01 - Added :paramref:.MetaData.reflect.**dialect_kwargs
to support dialect-level reflection options for all :class:`.Table`
objects reflected.

- Added a new dialect-level argument ``postgresql_ignore_search_path``;
this argument is accepted by both the :class:`.Table` constructor
as well as by the :meth:`.MetaData.reflect` method.  When in use
against Postgresql, a foreign-key referenced table which specifies
a remote schema name will retain that schema name even if the name
is present in the ``search_path``; the default behavior since 0.7.3
has been that schemas present in ``search_path`` would not be copied
to reflected :class:`.ForeignKey` objects.  The documentation has been
updated to describe in detail the behavior of the ``pg_get_constraintdef()``
function and how the ``postgresql_ignore_search_path`` feature essentially
determines if we will honor the schema qualification reported by
this function or not. [ticket:2922]
2014-02-02 16:33:54 -05:00
Mike Bayer 2104d0ba2d - rework the JSON expression system so that "astext" is called *after*
the indexing.  this is for more natural operation.
- also add cast() to the JSON expression to complement astext. This integrates
the CAST call which will be needed frequently.  Part of [ticket:2687].
- it's a little unclear how more advanced unicode attribute-access is going to go,
some quick attempts at testing yielded strange error messages from psycopg2.
- do other cross linking as mentioned in [ticket:2687].
2013-12-27 18:25:57 -05:00
Mike Bayer fec03c88d6 - make the json serializer and deserializer per-dialect, so that we are
compatible with psycopg2's per-connection/cursor approach.  add round trip tests for
both native and non-native.
2013-12-17 17:46:09 -05:00
Mike Bayer d98fcca0b3 this test appears to be failing with pg 9.3, not sure how to restore it 2013-12-17 15:37:50 -05:00
Mike Bayer e1802ff542 - using AssertsCompiledSQL so need __dialect__ 2013-12-17 15:33:27 -05:00
Mike Bayer 73013914e7 - rework JSON expressions to be based off __getitem__ exclusively
- add support for "standalone" JSON objects; this involves getting CAST
to upgrade the given type of a bound parameter.  should add a core-only test
for this.
- add tests for "standalone" json round trips both with and without unicode
- add mechanism by which we remove psycopg2's "json" handler in order to get
the effect of using our non-native result handlers
2013-12-17 15:13:39 -05:00
Mike Bayer 2c3afb4dcb Merge branch 'issue_2581' of github.com:nathan-rice/sqlalchemy into pg_json 2013-12-17 14:03:20 -05:00
nathan 015c73c83a sqlalchemy/dialects/postgresql/pgjson:
- Added support for additional operators
 - Made return as json default (rather than text)
2013-12-11 10:21:08 -05:00
nathan f285b3536f sqlalchemy/dialects/postgresql/pgjson:
- Fixed reference to HSTORE
 - Corrected spelling of SQLAlchemy

 sqlalchemy/dialects/postgresql/psycopg2:
 - Added psycopg2 specific wrapper type for JSON which uses inherent json deserialization facilities
 - Added code to detect and utilize the JSON wrapper if psycopg2 >= 2.5

test/dialect/postgresql/test_types:
- removed reference to use_native_hstore
2013-12-10 10:01:51 -05:00
Mike Bayer 164bff0749 - round trip test
- changelog
- some doc rearrangement
2013-12-09 21:27:14 -05:00
Noufal Ibrahim d3b65cd9bc Adds test to verify tsvector creation.
Signed-off-by: Noufal Ibrahim <noufal@nibrahim.net.in>
2013-12-10 01:07:53 +05:30
nathan 64288c7d6f sqlalchemy/dialects/postgresql/__init__.py:
- Added import references to JSON class

 sqlalchemy/dialects/postgresql/base.py:
 - Added visitor method for JSON class

 sqlalchemy/dialects/postgresql/pgjson (new):
 - JSON class, supports automatic serialization and deserialization of json data, as well as basic json operators.
2013-12-09 11:46:36 -05:00
Mike Bayer d52db834a5 - move additional enum compilation tests to postgresql/test_compiler.py 2013-11-30 16:12:20 -05:00
Mike Bayer 66773a8801 - Fixed bug where values within an ENUM weren't escaped for single
quote signs.   Note that this is backwards-incompatible for existing
workarounds that manually escape the single quotes. [ticket:2878]
2013-11-30 13:53:26 -05:00
Mike Bayer 31cecebd48 - add support for specifying tables or entities for "of"
- implement Query with_for_update()
- rework docs and tests
2013-11-28 23:23:27 -05:00
Mike Bayer 4aaf3753d7 - fix up rendering of "of"
- move out tests, dialect specific out of compiler, compiler tests use new API,
legacy API tests in test_selecatble
- add support for adaptation of ForUpdateArg, alias support in compilers
2013-11-28 22:25:09 -05:00
Mike Bayer 46ac022e57 - move this test to PG test_reflection
- don't use locals()
2013-10-25 17:19:03 -04:00
Mike Bayer e5a42a748b Merge branch 'master' of github.com:ijl/sqlalchemy into merge_2183 2013-10-25 17:01:38 -04:00
Mike Bayer fff9079909 - Removed a 128-character truncation from the reflection of the
server default for a column; this code was original from
PG system views which truncated the string for readability.
[ticket:2844]
2013-10-18 19:00:05 -04:00
Mike Bayer a5dc173ea6 - Added support for rendering `SMALLSERIAL when a :class:.SmallInteger`
type is used on a primary key autoincrement column, based on server
version detection of Postgresql version 9.2 or greater.
[ticket:2840]
2013-10-15 19:06:21 -04:00
Mike Bayer a2cce1bf43 Parenthesis will be applied to a compound SQL expression as
rendered in the column list of a CREATE INDEX statement.
[ticket:2742]
2013-10-12 20:21:18 -04:00
Mike Bayer 9bc9d5c106 - Fixed bug in default compiler plus those of postgresql, mysql, and
mssql to ensure that any literal SQL expression values are
rendered directly as literals, instead of as bound parameters,
within a CREATE INDEX statement. [ticket:2742]
- don't need expression_as_ddl(); literal_binds and include_table
take care of this functionality.
2013-10-12 20:04:55 -04:00
ijl 9d952e0a11 PostgreSQL foreign key inspection includes options 2013-10-11 15:01:14 -04:00
Mike Bayer 94d421ca2f - put exact version string in the test
- use match with a .* preceding instead of search
2013-09-29 17:24:29 -04:00
Mike Bayer 62463b95e0 add test for upcoming pullreq 2013-09-29 17:19:25 -04:00