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

Single quotes for the COLLATE statement #186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Stamper
Copy link

@Stamper Stamper commented Aug 28, 2020

As we can see in the snowflake docs the COLLATE statement requires single quotes for the collation specification.
In case of running CREATE TABLE script with double quotes in the Snowflake Console it returns the result like SQL compilation error: syntax error line 3 at position 24 unexpected '"SQL_Latin1_General_CP1_CI_AS"'.

After this PR sqlalchemy.schema.CreateTable(some_table).compile with dialect=snowflake.sqlalchemy.snowdialect.dialect() will return i.e. name NCHAR(10) COLLATE 'SQL_Latin1_General_CP1_CI_AS' instead of name NCHAR(10) COLLATE "SQL_Latin1_General_CP1_CI_AS"

This PR just overriding _render_string_type method from SQLAlchemy GenericTypeCompiler class for Snowflake SQLAlchemy dialect.

Tested with Python 3.8.2

@Stamper
Copy link
Author

Stamper commented Sep 1, 2020

@sfc-gh-stakeda did I file it wrong?

@sfc-gh-stakeda
Copy link
Contributor

@sfc-gh-mkeller FYI.

@Stamper
Copy link
Author

Stamper commented Oct 3, 2020

@sfc-gh-mkeller did I file it wrong?

@sfc-gh-mkeller
Copy link
Collaborator

No @Stamper , I just didn't have time to look at this yet.
However, it is missing tests for this feature. I'm going to need to add those to your PR.

@YYYasin19
Copy link

@Stamper is it okay if I take this over and write some tests?
Thanks for your solution, should solve the problem. ✅

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

Successfully merging this pull request may close these issues.

4 participants