summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-02-18 18:35:23 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-02-18 18:35:23 -0500
commitecdfc31774e226b9f57701ae197d1bcbaf6afa24 (patch)
treebe2b51199ebef39ee4a26e47c6b8b77e0388843e /test/dialect/postgresql
parentfdedb69d9c6d995fc85105c22f0f537ea25a0c44 (diff)
downloadsqlalchemy-ecdfc31774e226b9f57701ae197d1bcbaf6afa24.tar.gz
- 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.
Diffstat (limited to 'test/dialect/postgresql')
-rw-r--r--test/dialect/postgresql/test_dialect.py1
-rw-r--r--test/dialect/postgresql/test_query.py6
-rw-r--r--test/dialect/postgresql/test_reflection.py8
-rw-r--r--test/dialect/postgresql/test_types.py4
4 files changed, 12 insertions, 7 deletions
diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py
index fd6df2c98..7f22c6a6b 100644
--- a/test/dialect/postgresql/test_dialect.py
+++ b/test/dialect/postgresql/test_dialect.py
@@ -205,6 +205,7 @@ class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
: Numeric})
assert_raises(exc.InvalidRequestError, testing.db.execute, stmt)
+ @testing.only_if("postgresql >= 8.2", "requires standard_conforming_strings")
def test_serial_integer(self):
for version, type_, expected in [
diff --git a/test/dialect/postgresql/test_query.py b/test/dialect/postgresql/test_query.py
index ee5800db0..82b49d974 100644
--- a/test/dialect/postgresql/test_query.py
+++ b/test/dialect/postgresql/test_query.py
@@ -70,6 +70,7 @@ class InsertTest(fixtures.TestBase, AssertsExecutionResults):
metadata.create_all()
self._assert_data_with_sequence(table, 'my_seq')
+ @testing.requires.returning
def test_sequence_returning_insert(self):
table = Table('testtable', metadata, Column('id', Integer,
Sequence('my_seq'), primary_key=True),
@@ -84,6 +85,7 @@ class InsertTest(fixtures.TestBase, AssertsExecutionResults):
metadata.create_all()
self._assert_data_autoincrement(table)
+ @testing.requires.returning
def test_opt_sequence_returning_insert(self):
table = Table('testtable', metadata, Column('id', Integer,
Sequence('my_seq', optional=True),
@@ -97,6 +99,7 @@ class InsertTest(fixtures.TestBase, AssertsExecutionResults):
metadata.create_all()
self._assert_data_autoincrement(table)
+ @testing.requires.returning
def test_autoincrement_returning_insert(self):
table = Table('testtable', metadata, Column('id', Integer,
primary_key=True), Column('data', String(30)))
@@ -592,8 +595,7 @@ class ServerSideCursorsTest(fixtures.TestBase, AssertsExecutionResults):
class MatchTest(fixtures.TestBase, AssertsCompiledSQL):
- __only_on__ = 'postgresql'
- __excluded_on__ = ('postgresql', '<', (8, 3, 0)),
+ __only_on__ = 'postgresql >= 8.3'
@classmethod
def setup_class(cls):
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py
index 705a64c8e..aefb6a0ba 100644
--- a/test/dialect/postgresql/test_reflection.py
+++ b/test/dialect/postgresql/test_reflection.py
@@ -20,7 +20,7 @@ class DomainReflectionTest(fixtures.TestBase, AssertsExecutionResults):
"""Test PostgreSQL domains"""
- __only_on__ = 'postgresql'
+ __only_on__ = 'postgresql > 8.2'
@classmethod
def setup_class(cls):
@@ -128,8 +128,8 @@ class DomainReflectionTest(fixtures.TestBase, AssertsExecutionResults):
class ReflectionTest(fixtures.TestBase):
__only_on__ = 'postgresql'
- @testing.fails_if(('postgresql', '<', (8, 4)),
- "newer query is bypassed due to unsupported SQL functions")
+ @testing.fails_if("postgresql < 8.4",
+ "Better int2vector functions not available")
@testing.provide_metadata
def test_reflected_primary_key_order(self):
meta1 = self.metadata
@@ -170,6 +170,8 @@ class ReflectionTest(fixtures.TestBase):
eq_(
t.c.x.server_default.arg.text, "'%s'::character varying" % ("abcd" * 40)
)
+
+ @testing.fails_if("postgresql < 8.1", "schema name leaks in, not sure")
@testing.provide_metadata
def test_renamed_sequence_reflection(self):
metadata = self.metadata
diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py
index ba4b63e1a..4540b7537 100644
--- a/test/dialect/postgresql/test_types.py
+++ b/test/dialect/postgresql/test_types.py
@@ -102,7 +102,7 @@ class FloatCoercionTest(fixtures.TablesTest, AssertsExecutionResults):
class EnumTest(fixtures.TestBase, AssertsExecutionResults):
- __only_on__ = 'postgresql'
+ __only_on__ = 'postgresql > 8.3'
@testing.fails_on('postgresql+zxjdbc',
@@ -908,7 +908,7 @@ class SpecialTypesTest(fixtures.TestBase, ComparesTables, AssertsCompiledSQL):
class UUIDTest(fixtures.TestBase):
"""Test the bind/return values of the UUID type."""
- __only_on__ = 'postgresql'
+ __only_on__ = 'postgresql >= 8.3'
@testing.fails_on('postgresql+zxjdbc',
'column "data" is of type uuid but expression is of type character varying')