summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_dialect.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-10-15 19:06:21 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-10-15 19:06:21 -0400
commita5dc173ea6735c2b0877c771d2cb0693ac8dca82 (patch)
tree9165880f4384dd6bee35dbbe0e4c4234e8ef5cad /test/dialect/postgresql/test_dialect.py
parent92534dc8f30d173deaa1221a6872fd9b7ceae325 (diff)
downloadsqlalchemy-a5dc173ea6735c2b0877c771d2cb0693ac8dca82.tar.gz
- 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]
Diffstat (limited to 'test/dialect/postgresql/test_dialect.py')
-rw-r--r--test/dialect/postgresql/test_dialect.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py
index 3d48230f3..aa11662a0 100644
--- a/test/dialect/postgresql/test_dialect.py
+++ b/test/dialect/postgresql/test_dialect.py
@@ -203,17 +203,30 @@ class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
assert_raises(exc.InvalidRequestError, testing.db.execute, stmt)
def test_serial_integer(self):
- for type_, expected in [
- (Integer, 'SERIAL'),
- (BigInteger, 'BIGSERIAL'),
- (SmallInteger, 'SMALLINT'),
- (postgresql.INTEGER, 'SERIAL'),
- (postgresql.BIGINT, 'BIGSERIAL'),
+
+ for version, type_, expected in [
+ (None, Integer, 'SERIAL'),
+ (None, BigInteger, 'BIGSERIAL'),
+ ((9, 1), SmallInteger, 'SMALLINT'),
+ ((9, 2), SmallInteger, 'SMALLSERIAL'),
+ (None, postgresql.INTEGER, 'SERIAL'),
+ (None, postgresql.BIGINT, 'BIGSERIAL'),
]:
m = MetaData()
t = Table('t', m, Column('c', type_, primary_key=True))
- ddl_compiler = testing.db.dialect.ddl_compiler(testing.db.dialect, schema.CreateTable(t))
+
+ if version:
+ dialect = postgresql.dialect()
+ dialect._get_server_version_info = Mock(return_value=version)
+ dialect.initialize(testing.db.connect())
+ else:
+ dialect = testing.db.dialect
+
+ ddl_compiler = dialect.ddl_compiler(
+ dialect,
+ schema.CreateTable(t)
+ )
eq_(
ddl_compiler.get_column_specification(t.c.c),
"c %s NOT NULL" % expected