Closed
Description
Describe the bug
create_check_constraint
's condition
argument is declared as condition: Union[str, BinaryExpression]
, which doesn't accept neither or_(…)
/and_(…)
error: Argument 3 to "create_check_constraint" has incompatible type "ColumnElement[bool]"; expected "str | BinaryExpression[Any] | TextClause" [arg-type]
nor col_expr1 | col_expr2
/col_expr1 & col_expr2
:
error: Argument 3 to "create_check_constraint" has incompatible type "BooleanClauseList"; expected "str | BinaryExpression[Any] | TextClause" [arg-type]
Expected behavior
Both described cases work runtime, so type annotation is expected to allow them.
To Reproduce
from alembic import op
import sqlalchemy as sa
def upgrade() -> None:
op.create_check_constraint(
"check_constraint",
"table_name",
sa.or_(sa.column("a") != 0, sa.column("b") != 0),
)
Error
error: Argument 3 to "create_check_constraint" has incompatible type "ColumnElement[bool]"; expected "str | BinaryExpression[Any] | TextClause" [arg-type]
Versions.
- OS:
- Python:
- Alembic: 1.11.1
- SQLAlchemy: 2.0.17
- Database:
- DBAPI:
Additional context
Have a nice day!