From bb6a967b2897a8b8599b572a4f33a742d6f9588f Mon Sep 17 00:00:00 2001 From: Chantal Loncle <82039410+bog-walk@users.noreply.github.com> Date: Fri, 28 Jul 2023 14:17:47 -0400 Subject: [PATCH 1/2] 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. --- .../kotlin/org/jetbrains/exposed/sql/vendors/OracleDialect.kt | 2 +- .../exposed/sql/tests/shared/ddl/CreateDatabaseTest.kt | 3 +-- 2 files changed, 2 insertions(+), 3 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 d64f953723..7c59516a80 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..139251a922 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 @@ -10,8 +10,7 @@ class CreateDatabaseTest : DatabaseTestsBase() { @Test fun `create database test`() { - // PostgreSQL will be tested in the next test function - withDb(excludeSettings = listOf(TestDB.POSTGRESQL, TestDB.POSTGRESQLNG)) { + withDb(excludeSettings = listOf(TestDB.POSTGRESQL, TestDB.POSTGRESQLNG, TestDB.ORACLE)) { val dbName = "jetbrains" try { SchemaUtils.dropDatabase(dbName) From 5f7b10f581132f0a4df867aa203890a1c0070ce0 Mon Sep 17 00:00:00 2001 From: Chantal Loncle <82039410+bog-walk@users.noreply.github.com> Date: Sun, 30 Jul 2023 17:48:35 -0400 Subject: [PATCH 2/2] fix: Inaccurate drop database statement in Oracle Change test names casing and exception name --- .../exposed/sql/tests/shared/ddl/CreateDatabaseTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 139251a922..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,13 +9,13 @@ import java.sql.SQLException class CreateDatabaseTest : DatabaseTestsBase() { @Test - fun `create database test`() { + 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) @@ -23,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