Skip to content

Some mssql commands are not correctly quoted #1187

Closed
@CaselIT

Description

@CaselIT
Member

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

Activity

sqla-tester

sqla-tester commented on Feb 23, 2023

@sqla-tester
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

zzzeek commented on Feb 24, 2023

@zzzeek
Member

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

zzzeek commented on Feb 24, 2023

@zzzeek
Member

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

CaselIT

CaselIT commented on Feb 24, 2023

@CaselIT
MemberAuthor

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

added a commit that references this issue on Sep 27, 2024
7ebd32d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Microsoft SQL Servermicrosoft SQL Server, e.g. mssqlbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @zzzeek@sqla-tester@CaselIT

        Issue actions

          Some mssql commands are not correctly quoted · Issue #1187 · sqlalchemy/alembic