Skip to content

Commit

Permalink
fix: Inaccurate drop database statement in Oracle (JetBrains#1807)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
bog-walk authored and saral committed Oct 3, 2023
1 parent 2cd28f1 commit b7e2c15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@ 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)
}
}

@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
Expand Down

0 comments on commit b7e2c15

Please sign in to comment.