Skip to content

Commit

Permalink
SchemaUtils.createMissingTablesAndColumns raise NoSuchElementException
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapac committed Oct 2, 2022
1 parent 8caecbc commit 070bff8
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,17 @@ class JdbcDatabaseMetadataImpl(database: String, val metadata: DatabaseMetaData)
metadata.getImportedKeys(databaseName, currentScheme, table).iterate {
val fromTableName = getString("FKTABLE_NAME")!!
val fromColumnName = identifierManager.quoteIdentifierWhenWrongCaseOrNecessary(getString("FKCOLUMN_NAME")!!)
val fromColumn = allTables.getValue(fromTableName).columns.firstOrNull {
val fromColumn = allTables[fromTableName]?.columns?.firstOrNull {
identifierManager.quoteIdentifierWhenWrongCaseOrNecessary(it.name) == fromColumnName
} ?: return@iterate null // Do not crash if there are missing fields in Exposed's tables
val constraintName = getString("FK_NAME")!!
val targetTableName = getString("PKTABLE_NAME")!!
val targetColumnName = identifierManager.quoteIdentifierWhenWrongCaseOrNecessary(
identifierManager.inProperCase(getString("PKCOLUMN_NAME")!!)
)
val targetColumn = allTables.getValue(targetTableName).columns.first {
val targetColumn = allTables[targetTableName]?.columns?.firstOrNull {
identifierManager.quoteIdentifierWhenWrongCaseOrNecessary(it.nameInDatabaseCase()) == targetColumnName
}
} ?: return@iterate null // Do not crash if there are missing fields in Exposed's tables
val constraintUpdateRule = ReferenceOption.resolveRefOptionFromJdbc(getInt("UPDATE_RULE"))
val constraintDeleteRule = ReferenceOption.resolveRefOptionFromJdbc(getInt("DELETE_RULE"))
ForeignKeyConstraint(
Expand Down

0 comments on commit 070bff8

Please sign in to comment.