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

Issue with quoting in column rename on MSSQL #109

Closed
sqlalchemy-bot opened this issue Mar 8, 2013 · 5 comments
Closed

Issue with quoting in column rename on MSSQL #109

sqlalchemy-bot opened this issue Mar 8, 2013 · 5 comments
Labels
bug Something isn't working

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by Anonymous

I have a revision file where I call the following operation to fix a casing typo in a column name:

op.alter_column('WLB_SSL_Subledger', 'wlbPremiumDrCR',
                new_column_name='wlbPremiumDrCr',)

The generated SQL is basically

EXEC sp_rename '[WLB_SSL_Subledger].[wlbPremiumDrCR]', '[wlbPremiumDrCr]', 'COLUMN';

But then the renamed column is named [wlbPremiumDrCr] (including the brackets!), i.e., the rename statement should be

EXEC sp_rename '[WLB_SSL_Subledger].[wlbPremiumDrCR]', 'wlbPremiumDrCr', 'COLUMN';

(without brackets).

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

this is annoying, but some experimentation has shown that the "new col name" doesn't need to be quoted, which is why '[name]' is interepreted as two levels of quoting. This works and would be much easier:

EXEC sp_rename '[WLB_SSL_Subledger].[wlbPremiumDrCR]', [wlbPremiumDrCr], 'COLUMN';

if the name isn't a quotable, then there's no quotes (also seems to work):

EXEC sp_rename '[WLB_SSL_Subledger].[wlbPremiumDrCR]', some_regular_name, 'COLUMN';

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

please confirm that works on your end.

@sqlalchemy-bot
Copy link
Author

david_fritzsche wrote:

The two examples without single-quotes work perfectly for me. Thanks.

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

0fc1e5f

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added the bug Something isn't working label Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant