# note that SQLAlchemy as of 1.2 does not yet support
# DROP CONSTRAINT for MySQL/MariaDB, so we implement fully
# here.
- if compiler.dialect.is_mariadb: # type: ignore[attr-defined]
+ if compiler.dialect.is_mariadb:
return "ALTER TABLE %s DROP CONSTRAINT %s" % (
compiler.preparer.format_table(constraint.table),
compiler.preparer.format_constraint(constraint),
sqla_14_18 = _vers >= (1, 4, 18)
sqla_14_26 = _vers >= (1, 4, 26)
sqla_2 = _vers >= (2,)
+sqla_2_1 = _vers >= (2, 1)
sqlalchemy_version = __version__
if TYPE_CHECKING:
if not isinstance(expr, ColumnClause) or expr.is_literal:
return True
return False
+
+
+def _inherit_schema_deprecated() -> bool:
+ # at some point in 2.1 inherit_schema was replaced with a property
+ # so that's preset at the class level, while before it wasn't.
+ return sqla_2_1 and hasattr(sqltypes.Enum, "inherit_schema")
)
def _check_enum_inherit_schema(self, enum):
- if enum.inherit_schema:
+ if (
+ not sqla_compat._inherit_schema_deprecated()
+ and enum.inherit_schema
+ ):
return enum, ", inherit_schema=True"
else:
return enum, ""