Skip to content

SQLAlchemy 2.0 ComponentReflectionTest test_check_constraint_standalone fails #165

Description

@kadler
pyodbc.Error: ('HY000', '[HY000] [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL5051 - Qualifier SQLALCHEMY not same as name TEST_SCHEMA. (-5051) (SQLExecDirectW)')

This is caused by the constraint name not being schema-qualified and the table schema doesn't match the default schema:

CREATE TABLE test_schema.sa_cc (
        a INTEGER, 
        CONSTRAINT "MyCkConst" CHECK (a = 1 OR (a > 2 AND a < 5))
)

We will have to modify DB2IdentifierPreparer to override the format_constraint function which adds the schema.

See https://github.com/sqlalchemy/sqlalchemy/blob/0c6e2f39df1e6748a916fc5f5a1a3b3296aed4af/lib/sqlalchemy/sql/compiler.py#L8219-L8222 for how to get the schema and default format_constraint is https://github.com/sqlalchemy/sqlalchemy/blob/0c6e2f39df1e6748a916fc5f5a1a3b3296aed4af/lib/sqlalchemy/sql/compiler.py#L8133

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions