Enable database integration tests against Postgres database (#169)

* For Postgres, if a schema name is provided then it's wrapped in double quotes before passing to Hibernate to preserve case-sensitivity, Liquibase does it out-of-box.
* Sql setup scripts for PostgreSQL and datasource configuration.
This commit is contained in:
szymonsztuka
2018-01-08 14:05:42 +00:00
committed by GitHub
parent e92ce3ad37
commit f2186e7e30
8 changed files with 63 additions and 3 deletions

View File

@ -51,7 +51,13 @@ class HibernateConfiguration(
.setProperty("hibernate.connection.isolation", databaseConfig.transactionIsolationLevel.jdbcValue.toString())
databaseConfig.schema?.apply {
config.setProperty("hibernate.default_schema", databaseConfig.schema)
//preserving case-sensitive schema name for PostgreSQL by wrapping in double quotes, schema without double quotes would be treated as case-insensitive (lower cases)
val schemaName = if (jdbcUrl.contains(":postgresql:", ignoreCase = true) && !databaseConfig.schema.startsWith("\"")) {
"\"" + databaseConfig.schema + "\""
} else {
databaseConfig.schema
}
config.setProperty("hibernate.default_schema", schemaName)
}
schemas.forEach { schema ->
@ -97,7 +103,7 @@ class HibernateConfiguration(
applyBasicType(CordaWrapperBinaryType, CordaWrapperBinaryType.name)
// When connecting to SqlServer (and only then) do we need to tell hibernate to use
// nationalised (i.e. Unicode) strings by default
val forceUnicodeForSqlServer = jdbcUrl.contains(":sqlserver:", ignoreCase = true);
val forceUnicodeForSqlServer = jdbcUrl.contains(":sqlserver:", ignoreCase = true)
enableGlobalNationalizedCharacterDataSupport(forceUnicodeForSqlServer)
build()
}