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

Comments

@sqlalchemy-bot
Copy link

@sqlalchemy-bot sqlalchemy-bot commented Mar 8, 2013

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

@sqlalchemy-bot sqlalchemy-bot commented Mar 8, 2013

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

@sqlalchemy-bot sqlalchemy-bot commented Mar 8, 2013

Michael Bayer (@zzzeek) wrote:

please confirm that works on your end.

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Mar 12, 2013

david_fritzsche wrote:

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

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Apr 4, 2013

Michael Bayer (@zzzeek) wrote:

0fc1e5f

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Apr 4, 2013

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant