Skip to content

Commit

Permalink
fix: EXPOSED-137 SET DEFAULT option should not be supported in Oracle (
Browse files Browse the repository at this point in the history
…JetBrains#1830)

The following test fails when run on Oracle:

sqlite/ForeignKeyConstraintTests/'test ON DELETE SET DEFAULT for databases that support it without SQLite'()

Fails with:
java.sql.SQLException: ORA-03001: unimplemented feature

Oracle's ON DELETE clause only supports CASCADE or SET NULL reference options.

A warning is now logged and the option is not appended to the query string.
  • Loading branch information
bog-walk authored and saral committed Oct 3, 2023
1 parent 4bc4581 commit 4aa017e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ data class ForeignKeyConstraint(
"MySQL doesn't support FOREIGN KEY with SET DEFAULT reference option with ON DELETE clause. " +
"Please check your $fromTableName table."
)
is OracleDialect -> exposedLogger.warn(
"Oracle doesn't support FOREIGN KEY with SET DEFAULT reference option with ON DELETE clause. " +
"Please check your $fromTableName table."
)
else -> append(" ON DELETE $deleteRule")
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ class CreateTableTests : DatabaseTestsBase() {

@Test
fun createTableWithOnDeleteSetDefault() {
withDb(excludeSettings = listOf(TestDB.MARIADB, TestDB.MYSQL)) {
withDb(excludeSettings = listOf(TestDB.MARIADB, TestDB.MYSQL, TestDB.ORACLE)) {
val expected = listOf(
"CREATE TABLE " + addIfNotExistsIfSupported() + "${this.identity(Item)} (" +
"${Item.columns.joinToString { it.descriptionDdl(false) }}," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ForeignKeyConstraintTests : DatabaseTestsBase() {

@Test
fun `test ON DELETE SET DEFAULT for databases that support it without SQLite`() {
withDb(excludeSettings = listOf(TestDB.MARIADB, TestDB.MYSQL, TestDB.SQLITE)) {
withDb(excludeSettings = listOf(TestDB.MARIADB, TestDB.MYSQL, TestDB.SQLITE, TestDB.ORACLE)) {
testOnDeleteSetDefault()
}
}
Expand Down

0 comments on commit 4aa017e

Please sign in to comment.