Skip to content

Commit

Permalink
Ignore missing fields instead of crashing on MySQL #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapac committed May 15, 2020
1 parent 686b34b commit 1c447c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ open class MysqlDialect : VendorDialect(dialectName, MysqlDataTypeProvider, Mysq
val constraintName = rs.getString("CONSTRAINT_NAME")!!
val targetTableName = rs.getString("REFERENCED_TABLE_NAME")!!
val targetColumnName = rs.getString("REFERENCED_COLUMN_NAME")!!.quoteIdentifierWhenWrongCaseOrNecessary(tr)
val targetColumn = allTables.getValue(targetTableName).columns.first { it.nameInDatabaseCase() == targetColumnName }
val targetColumn = allTables.getValue(targetTableName).columns.first {
it.nameInDatabaseCase().quoteIdentifierWhenWrongCaseOrNecessary(tr) == targetColumnName
}
val constraintUpdateRule = ReferenceOption.valueOf(rs.getString("UPDATE_RULE")!!.replace(" ", "_"))
val constraintDeleteRule = ReferenceOption.valueOf(rs.getString("DELETE_RULE")!!.replace(" ", "_"))
constraintsToLoad.getOrPut(fromTableName) { arrayListOf() }.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ class CreateMissingTablesAndColumnsTests : DatabaseTestsBase() {


@Test fun createTableWithReservedIdentifierInColumnName() {
withDb {
withDb(TestDB.MYSQL) {
addLogger(StdOutSqlLogger)
SchemaUtils.createMissingTablesAndColumns(T1, T2)
SchemaUtils.createMissingTablesAndColumns(T1, T2)

Expand All @@ -198,10 +199,11 @@ class CreateMissingTablesAndColumnsTests : DatabaseTestsBase() {
}
}

object T1: IntIdTable("ARRAY") {
object T1: Table("ARRAY") {
val name = integer("name").uniqueIndex()
val tmp = varchar("temp", 255)
}
object T2: Table("CHAIN") {
val ref = integer("ref").references(T1.id)
val ref = integer("ref").references(T1.name)
}
}

0 comments on commit 1c447c0

Please sign in to comment.