Skip to content

Commit

Permalink
Detect column casing name change SchemaUtils.addMissingColumnsStateme…
Browse files Browse the repository at this point in the history
…nt / Test fixed
  • Loading branch information
Tapac committed Nov 12, 2021
1 parent b906512 commit 6b51837
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,25 @@ class CreateMissingTablesAndColumnsTests : DatabaseTestsBase() {
}

withDb {
// withDb(db = listOf(TestDB.H2)) {
SchemaUtils.createMissingTablesAndColumns(t1)
if (db.supportsAlterTableWithAddColumn) {
SchemaUtils.createMissingTablesAndColumns(t1)

val missingStatements = SchemaUtils.addMissingColumnsStatements(t2)
val missingStatements = SchemaUtils.addMissingColumnsStatements(t2)

val expected = "ALTER TABLE ${t2.nameInDatabaseCase()} ALTER COLUMN ${t2.id.nameInDatabaseCase()} INT"
assertEquals(expected, missingStatements.firstOrNull())
val alterColumnWord = when (currentDialectTest) {
is MysqlDialect -> "MODIFY COLUMN"
is OracleDialect -> "MODIFY"
else -> "ALTER COLUMN"
}

SchemaUtils.drop(t1)
val expected = if (t1.id.nameInDatabaseCase() != t2.id.nameInDatabaseCase()) {
"ALTER TABLE ${t2.nameInDatabaseCase()} $alterColumnWord ${t2.id.nameInDatabaseCase()} INT"
} else null

assertEquals(expected, missingStatements.firstOrNull())

SchemaUtils.drop(t1)
}
}
}

Expand Down

0 comments on commit 6b51837

Please sign in to comment.