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

Support "collation" option on String/Text types #81

Open
kadler opened this issue Apr 13, 2020 · 1 comment
Open

Support "collation" option on String/Text types #81

kadler opened this issue Apr 13, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@kadler
Copy link
Member

kadler commented Apr 13, 2020

String and Text both support a "collation" option to set the encoding of the parameter:

collation

Optional, a column-level collation for use in DDL and CAST expressions. Renders using the COLLATE keyword supported by SQLite, MySQL, and PostgreSQL. E.g.:

from sqlalchemy import cast, select, String
>>> print(select([cast('some string', String(collation='utf8'))]))
SELECT CAST(:param_1 AS VARCHAR COLLATE utf8) AS anon_1

We could allow users to specify a CCSID here, eg.

from sqlalchemy import cast, select, String
>>> print(select([cast('some string', String(10, collation=37))]))
SELECT CAST(:param_1 AS VARCHAR(10) CCSID 37) AS anon_1

I think we target this for a future version.

@kadler kadler added the enhancement New feature or request label Apr 13, 2020
@kadler
Copy link
Member Author

kadler commented Sep 9, 2021

Various built-in SQLAlchemy dialects add custom attributes. MySQL has quite a few that we could model a "ccsid" attribute on. See the code for setting these attributes here: https://github.com/sqlalchemy/sqlalchemy/blob/master/lib/sqlalchemy/dialects/mysql/types.py#L66-L93 then using the attributes: https://github.com/sqlalchemy/sqlalchemy/blob/master/lib/sqlalchemy/dialects/mysql/base.py#L2265-L2297

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant