Luca Sas
04/27/2021, 6:48 PMoverride fun tableExists(table: Table): Boolean {
val tableScheme = table.tableName.substringBefore('.', "").takeIf { it.isNotEmpty() }
val scheme = tableScheme?.inProperCase() ?: TransactionManager.current().connection.metadata { currentScheme }
val allTables = getAllTableNamesCache().getValue(scheme)
return allTables.any {
when {
tableScheme != null -> it == table.nameInDatabaseCase()
scheme.isEmpty() -> it == table.nameInDatabaseCase()
else -> it == "$scheme.${table.tableNameWithoutScheme}".inProperCase()
}
}
}
What happens here by looking at the debugger is that alltables
is [ "public.tablename", "public.someothertablename" ]
but table.name
misses the schema name and I am not sure why. The code is fairly straightforward and I used SchemaUtils.create
successfully in the past.tapac
04/28/2021, 7:24 PM