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

Fix CORE-2178 Use correct database collation #338

Merged
merged 1 commit into from
Jan 5, 2015
Merged

Fix CORE-2178 Use correct database collation #338

merged 1 commit into from
Jan 5, 2015

Conversation

rhuffman
Copy link
Contributor

Fixes CORE-2178: https://liquibase.jira.com/browse/CORE-2178

MSSQLDatabase.isCaseSensitive() uses the system collation rather than the database collation to determine whether or not the database is case-sensitive. That is fixed by checking DATABASEPROPERTYEX(, 'collation').

Also, MSSQLDatabase.getdbcSchemaName() always converts to lower case. That causes a false negative on a case-sensitive database when checking to see if the lock table exists.

I am not nearly familiar enough to understand the full impact of this change, but it does seem to fix the problem we are having on SQL Server 2012.

String collation = ExecutorService.getInstance().getExecutor(this).queryForObject(new RawSqlStatement("SELECT CONVERT(varchar(100), SERVERPROPERTY('COLLATION'))"), String.class);
caseSensitive = ! collation.contains("_CI_");
String catalog = getConnection().getCatalog();
String sql = String.format("SELECT CONVERT(varchar(100), DATABASEPROPERTYEX('%s', 'COLLATION'))", catalog);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is an SQL injection problem here, but I'm not familiar enough with SQL Server to know for sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the goal of Liquibase is to run arbitrary SQL I tend to not worry too much about sql injection problems so I think it is fine.

nvoxland added a commit that referenced this pull request Jan 5, 2015
…rver

Fix CORE-2178 Use correct database collation
@nvoxland nvoxland merged commit d362b0a into liquibase:master Jan 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants