From 86a2405e2b712664befb3bede7a7597603d0f11a Mon Sep 17 00:00:00 2001 From: bog-walk <82039410+bog-walk@users.noreply.github.com> Date: Mon, 31 Jul 2023 14:59:49 -0400 Subject: [PATCH] fix: Inaccurate drop database statement in Oracle (#1807) * fix: Inaccurate drop database statement in Oracle Failing test shows that the override for dropDatabase() in OracleDialect is wrong, so this has been replaced with the correct statement. Failing test would then require privileges to drop the pluggable database from the root container level, which are not accessible, so it has been excluded. --- .../jetbrains/exposed/sql/vendors/OracleDialect.kt | 2 +- .../sql/tests/shared/ddl/CreateDatabaseTest.kt | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/vendors/OracleDialect.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/vendors/OracleDialect.kt index d24b6e54c1..42b08283f2 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/vendors/OracleDialect.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/vendors/OracleDialect.kt @@ -318,7 +318,7 @@ open class OracleDialect : VendorDialect(dialectName, OracleDataTypeProvider, Or override fun createDatabase(name: String): String = "CREATE DATABASE ${name.inProperCase()}" - override fun dropDatabase(name: String): String = "DROP DATABASE ${name.inProperCase()}" + override fun dropDatabase(name: String): String = "DROP DATABASE" override fun setSchema(schema: Schema): String = "ALTER SESSION SET CURRENT_SCHEMA = ${schema.identifier}" diff --git a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/CreateDatabaseTest.kt b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/CreateDatabaseTest.kt index 97bdb6b33c..1846e38a42 100644 --- a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/CreateDatabaseTest.kt +++ b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/CreateDatabaseTest.kt @@ -9,14 +9,13 @@ import java.sql.SQLException class CreateDatabaseTest : DatabaseTestsBase() { @Test - fun `create database test`() { - // PostgreSQL will be tested in the next test function - withDb(excludeSettings = listOf(TestDB.POSTGRESQL, TestDB.POSTGRESQLNG)) { + fun testCreateAndDropDatabase() { + withDb(excludeSettings = listOf(TestDB.POSTGRESQL, TestDB.POSTGRESQLNG, TestDB.ORACLE)) { val dbName = "jetbrains" try { SchemaUtils.dropDatabase(dbName) - } catch (e: SQLException) { - //ignore + } catch (cause: SQLException) { + // ignore } SchemaUtils.createDatabase(dbName) SchemaUtils.dropDatabase(dbName) @@ -24,7 +23,7 @@ class CreateDatabaseTest : DatabaseTestsBase() { } @Test - fun `create database test in postgreSQL`() { + fun testCreateAndDropDatabaseInPostgresql() { // PostgreSQL needs auto commit to be "ON" to allow create database statement withDb(listOf(TestDB.POSTGRESQL, TestDB.POSTGRESQLNG)) { connection.autoCommit = true