from . import ops
from .base import Operations
-from ..util.sqla_compat import _copy
+from ..util.sqla_compat import _copy, sqla_2
if TYPE_CHECKING:
from sqlalchemy.sql.schema import Table
) -> None:
kw = {}
if operation.if_exists is not None:
+ if not sqla_2:
+ raise NotImplementedError("SQLAlchemy 2.0 required")
kw["if_exists"] = operation.if_exists
operations.impl.drop_constraint(
operations.schema_obj.generic_constraint(
def test_drop_constraint_if_exists(self):
context = op_fixture()
- op.drop_constraint("foo_bar_bat", "t1", if_exists=True)
- context.assert_("ALTER TABLE t1 DROP CONSTRAINT IF EXISTS foo_bar_bat")
+ if sqla_compat.sqla_2:
+ op.drop_constraint("foo_bar_bat", "t1", if_exists=True)
+ context.assert_("ALTER TABLE t1 DROP CONSTRAINT IF EXISTS foo_bar_bat")
+ else:
+ with expect_raises_message(
+ NotImplementedError, "SQLAlchemy 2.0 required"
+ ):
+ op.drop_constraint("foo_bar_bat", "t1", if_exists=True)
def test_create_index(self):
context = op_fixture()