--- /dev/null
+.. change::
+ :tags: bug, mysql
+ :tickets: 4743
+
+ Fixed bug where the special logic to render "NULL" for the
+ :class:`.TIMESTAMP` datatype when ``nullable=True`` would not work if the
+ column's datatype were a :class:`.TypeDecorator` or a :class:`.Variant`.
+ The logic now ensures that it unwraps down to the original
+ :class:`.TIMESTAMP` so that this special case NULL keyword is correctly
+ rendered when requested.
# coding: utf-8
-
from collections import OrderedDict
import datetime
import decimal
from sqlalchemy import Table
from sqlalchemy import testing
from sqlalchemy import TIMESTAMP
+from sqlalchemy import TypeDecorator
from sqlalchemy import types as sqltypes
from sqlalchemy import UnicodeText
from sqlalchemy import util
Table("t", MetaData(), c)
self.assert_compile(schema.CreateColumn(c), "t %s" % expected)
+ def test_timestamp_nullable_plain(self):
+ self._test_timestamp_nullable(TIMESTAMP)
+
+ def test_timestamp_nullable_typedecorator(self):
+ class MyTime(TypeDecorator):
+ impl = TIMESTAMP
+
+ self._test_timestamp_nullable(MyTime())
+
+ def test_timestamp_nullable_variant(self):
+ t = String().with_variant(TIMESTAMP, "mysql")
+ self._test_timestamp_nullable(t)
+
@testing.requires.mysql_zero_date
@testing.provide_metadata
- def test_timestamp_nullable(self):
+ def _test_timestamp_nullable(self, type_):
ts_table = Table(
"mysql_timestamp",
self.metadata,
- Column("t1", TIMESTAMP),
- Column("t2", TIMESTAMP, nullable=False),
+ Column("t1", type_),
+ Column("t2", type_, nullable=False),
mysql_engine="InnoDB",
)
self.metadata.create_all()