Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle length attribute properly for string types #125

Open
kadler opened this issue Sep 9, 2021 · 1 comment
Open

Handle length attribute properly for string types #125

kadler opened this issue Sep 9, 2021 · 1 comment
Labels
good first issue Good for newcomers
Milestone

Comments

@kadler
Copy link
Member

kadler commented Sep 9, 2021

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

@Atharva321
Copy link

Hii, I am interested to work on this issue.

@kadler kadler added this to the 1.0 milestone Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants