Fixed issues in :class:`_mysql.SET` datatype as well as :class:`.Enum`
where the ``__repr__()`` method would not render all optional parameters in
the string output, impacting the use of these types in Alembic
autogenerate. Pull request for MySQL courtesy Yuki Nishimine.
Fixes: #7720
Fixes: #7789
Closes: #7772
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7772
Pull-request-sha:
d58845479f497f6b2e12d7df2e9eb2d6ac22109b
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: Idcec23eab4258511d9f32f4e3d78e511ea6021f1
--- /dev/null
+.. change::
+ :tags: bug, sql, mysql
+ :tickets: 7720, 7789
+
+ Fixed issues in :class:`_mysql.SET` datatype as well as :class:`.Enum`
+ where the ``__repr__()`` method would not render all optional parameters in
+ the string output, impacting the use of these types in Alembic
+ autogenerate. Pull request for MySQL courtesy Yuki Nishimine.
+
def adapt(self, impltype, **kw):
kw["retrieve_as_bitwise"] = self.retrieve_as_bitwise
return util.constructor_copy(self, impltype, *self.values, **kw)
+
+ def __repr__(self):
+ return util.generic_repr(
+ self,
+ to_inspect=[SET, _StringType],
+ additional_kw=[
+ ("retrieve_as_bitwise", False),
+ ],
+ )
def __repr__(self):
return util.generic_repr(
self,
- additional_kw=[("native_enum", True)],
+ additional_kw=[
+ ("native_enum", True),
+ ("create_constraint", False),
+ ],
to_inspect=[Enum, SchemaType],
)
[("", ""), ("", ""), ("two", "two"), (None, None)],
)
+ @testing.combinations(
+ (
+ [""],
+ {"retrieve_as_bitwise": True},
+ "SET('', retrieve_as_bitwise=True)",
+ ),
+ (["a"], {}, "SET('a')"),
+ (["a", "b", "c"], {}, "SET('a', 'b', 'c')"),
+ (
+ ["a", "b", "c"],
+ {"collation": "utf8_bin"},
+ "SET('a', 'b', 'c', collation='utf8_bin')",
+ ),
+ argnames="value,kw,expected",
+ )
+ def test_set_repr(self, value, kw, expected):
+ eq_(repr(mysql.SET(*value, **kw)), expected)
+
def colspec(c):
return testing.db.dialect.ddl_compiler(
"inherit_schema=True, native_enum=False)",
)
+ def test_repr_two(self):
+ e = Enum("x", "y", name="somename", create_constraint=True)
+ eq_(
+ repr(e),
+ "Enum('x', 'y', name='somename', create_constraint=True)",
+ )
+
def test_length_native(self):
e = Enum("x", "y", "long", length=42)