summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-07-04 16:37:26 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-07-04 16:54:01 -0400
commit428dfeee48c1fc4ceb5712b8934e90132ee57e33 (patch)
tree3302a446ef026ffa995a471ec2fb8e88a1533198 /test/dialect/postgresql
parentf5ec60c8811feb92ded85f8a4f8c3071e44acddf (diff)
downloadsqlalchemy-428dfeee48c1fc4ceb5712b8934e90132ee57e33.tar.gz
Repair PG BIGSERIAL w/ TypeDecorator, Variant
Some of the dialect impl memoization for TypeDecorator necessarily keeps the top-level TypeDecorator type around, since a user-defined type will have bind and result set processing behavior. For both TypeDecorator and Variant, PG dialect needs to ensure it's looking at the SQLAlchemy type to check for SmallInteger / BigInteger. Fixes: 3739 Change-Id: I2d45fb997f17c6272d6bb826a77d2dba665adae7 (cherry picked from commit 421fa6b8bf9f0c3c5041579c89ec405ce0f5e0b0)
Diffstat (limited to 'test/dialect/postgresql')
-rw-r--r--test/dialect/postgresql/test_dialect.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py
index c0e1819d6..9f7af8638 100644
--- a/test/dialect/postgresql/test_dialect.py
+++ b/test/dialect/postgresql/test_dialect.py
@@ -8,7 +8,7 @@ from sqlalchemy import testing
import datetime
from sqlalchemy import (
Table, Column, select, MetaData, text, Integer, String, Sequence, Numeric,
- DateTime, BigInteger, func, extract, SmallInteger)
+ DateTime, BigInteger, func, extract, SmallInteger, TypeDecorator)
from sqlalchemy import exc, schema
from sqlalchemy.dialects.postgresql import base as postgresql
import logging
@@ -252,6 +252,15 @@ class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
"postgresql >= 8.2", "requires standard_conforming_strings")
def test_serial_integer(self):
+ class BITD(TypeDecorator):
+ impl = Integer
+
+ def load_dialect_impl(self, dialect):
+ if dialect.name == 'postgresql':
+ return BigInteger()
+ else:
+ return Integer()
+
for version, type_, expected in [
(None, Integer, 'SERIAL'),
(None, BigInteger, 'BIGSERIAL'),
@@ -259,6 +268,16 @@ class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
((9, 2), SmallInteger, 'SMALLSERIAL'),
(None, postgresql.INTEGER, 'SERIAL'),
(None, postgresql.BIGINT, 'BIGSERIAL'),
+ (
+ None, Integer().with_variant(BigInteger(), 'postgresql'),
+ 'BIGSERIAL'),
+ (
+ None, Integer().with_variant(postgresql.BIGINT, 'postgresql'),
+ 'BIGSERIAL'),
+ (
+ (9, 2), Integer().with_variant(SmallInteger, 'postgresql'),
+ 'SMALLSERIAL'),
+ (None, BITD(), 'BIGSERIAL')
]:
m = MetaData()