justx2
August 4, 2009, 1:07pm
1
After I switched from Liquibase 1.9.3 to Liquibase 1.9.4, I get an error when using renameColumn.
What happens is that instead of the expected rename to “someColumnName”, the column are now named “[someColumnName]” - the square brackets are actually a part of the column name known by the database.
My dbms is MSSQL 2K5.
What do you have in your changelog file? I think there was fix in 1.9.4 to add escaping to column names, were you already escaping them?
Nathan
justx2
August 4, 2009, 1:07pm
3
No, I didn’t escape the name.
The line in the changeset looks like this:
justx2
August 4, 2009, 1:07pm
4
I think I found what is wrong.
renameTable generates this SQL:
exec sp_rename 'Type]', [PersistentEntityMetaData]renameColumn generates this SQL:
exec sp_rename '[PersistentEntityMetaData].
TypeID]', '[PersistentEntityMetaDataID]'but it should have generated this SQL:
exec sp_rename '[PersistentEntityMetaData].
TypeID]', [PersistentEntityMetaDataID]
I think correct sql snippet should be
exec sp_rename '[PersistentEntityMetaData].TypeID]', 'PersistentEntityMetaDataID'
escaping for this case should be avoided, keeping single quotes.
see http://msdn.microsoft.com/en-us/library/ms188351.aspx
Thanks, I created an issue for it: http://liquibase.jira.com/browse/CORE-442
Nathan