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

Some mssql commands are not correctly quoted #1187

Closed
CaselIT opened this issue Feb 23, 2023 · 4 comments
Closed

Some mssql commands are not correctly quoted #1187

CaselIT opened this issue Feb 23, 2023 · 4 comments
Labels
bug Something isn't working Microsoft SQL Server microsoft SQL Server, e.g. mssql

Comments

@CaselIT
Copy link
Member

CaselIT commented Feb 23, 2023

Dropping a constraint with spaces using mssql_drop_foreign_key=True will results in an error

@CaselIT CaselIT added bug Something isn't working Microsoft SQL Server microsoft SQL Server, e.g. mssql labels Feb 23, 2023
@sqla-tester
Copy link
Collaborator

CaselIT has proposed a fix for this issue in the main branch:

Escape sql server constriant names https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/4463

@zzzeek
Copy link
Member

zzzeek commented Feb 24, 2023

can you explain the issue here? "dropping a ...." what? Can I see what SQL is being emitted that fails?

not sure if im following the SQL correctly but it's selecting a column called name from sys.default_constraints or sys.check_contraints, that is

 SELECT [name] FROM sys.default_constraints

[name] is a quoted identifier, you wouldn't put QUOTENAME there, and it does not have spaces in it.

@zzzeek
Copy link
Member

zzzeek commented Feb 24, 2023

oh I see, QUOTENAME is running on the returned data, fine.

@CaselIT
Copy link
Member Author

CaselIT commented Feb 24, 2023

Sorry, the issue is when dropping constraints with names that need escaping. I've filled the missing words on the issue description.

Also this is a failry limited use case, since it affects only the mssql_drop_* kw args

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Microsoft SQL Server microsoft SQL Server, e.g. mssql
Projects
None yet
Development

No branches or pull requests

3 participants