Skip to content

Handle length attribute properly for string types #125

Description

@kadler

https://docs.sqlalchemy.org/en/14/core/type_basics.html#sqlalchemy.types.String.params.length

String types have an optional length field, but for DDL in Db2, CHAR/VARCHAR/etc require a length be specified. The docs say that in that case an exception should be raised, but we currently do not do this and instead just assume the user passed a valid length and insert it in to the statement, which causes an SQL parser error: SQL0104 - Token ( was not valid.

We need to add code similar to https://github.com/sqlalchemy/sqlalchemy/blob/rel_1_3/lib/sqlalchemy/dialects/mysql/base.py#L2214-L2220 for all visit_VARCHAR, visit_CHAR, visit_VARGRAPHIC, and visit_GRAPHIC. CLOB types do not require a length specified, however so we could actually adjust the code for them to let the database pick the default in that case.

Affected code is at https://github.com/IBM/sqlalchemy-ibmi/blob/master/sqlalchemy_ibmi/base.py#L292-L322

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions