metadata_type = metadata_column.type
metadata_impl = metadata_type.dialect_impl(self.dialect)
+ if isinstance(metadata_impl, sqltypes.Variant):
+ metadata_impl = metadata_impl.impl.dialect_impl(self.dialect)
# work around SQLAlchemy bug "stale value for type affinity"
# fixed in 0.7.4
"SQLAlchemy 0.9.4 or greater required"
)
+ @property
+ def sqlalchemy_1014(self):
+ return exclusions.skip_if(
+ lambda config: not util.sqla_1014,
+ "SQLAlchemy 1.0.14 or greater required"
+ )
+
@property
def sqlalchemy_110(self):
return exclusions.skip_if(
pyc_file_from_path, load_python_file, edit)
from .sqla_compat import ( # noqa
sqla_07, sqla_079, sqla_08, sqla_083, sqla_084, sqla_09, sqla_092,
- sqla_094, sqla_099, sqla_100, sqla_105, sqla_110, sqla_1010)
+ sqla_094, sqla_099, sqla_100, sqla_105, sqla_110, sqla_1010, sqla_1014)
from .exc import CommandError
sqla_105 = _vers >= (1, 0, 5)
sqla_1010 = _vers >= (1, 0, 10)
sqla_110 = _vers >= (1, 1, 0)
+sqla_1014 = _vers >= (1, 0, 14)
if sqla_08:
from sqlalchemy.sql.expression import TextClause
:version: 0.9.3
:released:
+ .. change:: 433
+ :tags: bug, autogenerate
+ :tickets: 433
+
+ Fixed bug where autogen comparison of a :class:`.Variant` datatype
+ would not compare to the dialect level type for the "default"
+ implementation of the :class:`.Variant`, returning the type as changed
+ between database and table metadata.
+
.. change:: 431
:tags: bug, tests
:tickets: 431
is_(impl.compare_type(Column('x', t2), Column('x', t3)), True)
+class AutogenerateVariantCompareTest(AutogenTest, TestBase):
+ __backend__ = True
+
+ # 1.0.13 and lower fail on Postgresql due to variant / bigserial issue
+ # #3739
+
+ __requires__ = ('sqlalchemy_1014', )
+
+ @classmethod
+ def _get_db_schema(cls):
+ m = MetaData()
+
+ Table('sometable', m,
+ Column(
+ 'id',
+ BigInteger().with_variant(Integer, "sqlite"),
+ primary_key=True),
+ Column('value', String(50)))
+ return m
+
+ @classmethod
+ def _get_model_schema(cls):
+ m = MetaData()
+
+ Table('sometable', m,
+ Column(
+ 'id',
+ BigInteger().with_variant(Integer, "sqlite"),
+ primary_key=True),
+ Column('value', String(50)))
+ return m
+
+ def test_variant_no_issue(self):
+ uo = ops.UpgradeOps(ops=[])
+ autogenerate._produce_net_changes(self.autogen_context, uo)
+
+ diffs = uo.as_diffs()
+ eq_(diffs, [])
+
+
class AutogenerateCustomCompareTypeTest(AutogenTest, TestBase):
__only_on__ = 'sqlite'