Skip to content

Commit

Permalink
Fix NullPointerException for case sensitive collations (#3699)
Browse files Browse the repository at this point in the history
Fix NullPointerException for case sensetive collations

* Added collation attribute to MSSQL Test sytem class to allow us perform testing with a specific collation.

---------

Co-authored-by: Daniel Mallorga <dmallorga@liquibase.com>
Co-authored-by: filipe <flautert@liquibase.org>
  • Loading branch information
3 people committed Jan 27, 2023
1 parent f04d5d5 commit 958ae65
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,8 @@ protected List<CachedRow> mssqlQuery(boolean bulk) throws DatabaseException, SQL
"object_schema_name(c.object_id" + dbIdParam + ") AS TABLE_SCHEM, " +
"object_name(c.object_id" + dbIdParam + ") AS TABLE_NAME, " +
"c.name AS COLUMN_NAME, " +
"is_filestream, " +
"is_rowguidcol, " +
"is_filestream AS IS_FILESTREAM, " +
"is_rowguidcol AS IS_ROWGUIDCOL, " +
"CASE WHEN c.is_identity = 'true' THEN 'YES' ELSE 'NO' END as IS_AUTOINCREMENT, " +
"{REMARKS_COLUMN_PLACEHOLDER}" +
"t.name AS TYPE_NAME, " +
Expand Down Expand Up @@ -608,7 +608,7 @@ protected List<CachedRow> mssqlQuery(boolean bulk) throws DatabaseException, SQL
"WHEN 'varchar(max)' THEN " + java.sql.Types.VARCHAR + " " +
"WHEN 'xml' THEN " + java.sql.Types.LONGVARCHAR + " " +
"WHEN 'LONGNVARCHAR' THEN " + java.sql.Types.SQLXML + " " +
"ELSE " + Types.OTHER + " END AS data_type, " +
"ELSE " + Types.OTHER + " END AS DATA_TYPE, " +
"CASE WHEN c.is_nullable = 'true' THEN 1 ELSE 0 END AS NULLABLE, " +
"10 as NUM_PREC_RADIX, " +
"c.column_id as ORDINAL_POSITION, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.testcontainers.utility.DockerImageName;

public class MSSQLTestSystem extends DatabaseTestSystem {
private String collation;

public MSSQLTestSystem() {
super("mssql");
Expand Down Expand Up @@ -46,7 +47,7 @@ protected String[] getSetupSql() {
return new String[]{
"CREATE LOGIN [" + getUsername() + "] with password=N'" + getPassword() + "', CHECK_EXPIRATION=OFF",

"CREATE DATABASE " + getCatalog(),
"CREATE DATABASE " + getCatalog() + (collation == null ? "" : " COLLATE " + collation ),
"EXEC lbcat..sp_addsrvrolemember @loginame = N'" + getUsername() + "', @rolename = N'sysadmin'",

"CREATE DATABASE " + getAltCatalog(),
Expand All @@ -64,4 +65,12 @@ protected String[] getSetupSql() {
"CREATE SCHEMA [" + getAltSchema() + "] AUTHORIZATION [dbo]"
};
}

public String getCollation() {
return collation;
}

public void setCollation(String collation) {
this.collation = collation;
}
}

0 comments on commit 958ae65

Please sign in to comment.