diff --git a/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/sql/statements/jdbc/JdbcDatabaseMetadataImpl.kt b/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/sql/statements/jdbc/JdbcDatabaseMetadataImpl.kt index 27bfefa0d1..9e7ebd5641 100644 --- a/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/sql/statements/jdbc/JdbcDatabaseMetadataImpl.kt +++ b/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/sql/statements/jdbc/JdbcDatabaseMetadataImpl.kt @@ -64,7 +64,7 @@ class JdbcDatabaseMetadataImpl(database: String, val metadata: DatabaseMetaData) field = try { when (databaseDialectName) { MysqlDialect.dialectName, MariaDBDialect.dialectName -> metadata.connection.catalog.orEmpty() - OracleDialect.dialectName -> databaseName + OracleDialect.dialectName -> metadata.connection.schema ?: databaseName else -> metadata.connection.schema.orEmpty() } } catch (_: Throwable) { diff --git a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/CreateIndexTests.kt b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/CreateIndexTests.kt index 5c439c9aac..a302e426ff 100644 --- a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/CreateIndexTests.kt +++ b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/CreateIndexTests.kt @@ -69,8 +69,8 @@ class CreateIndexTests : DatabaseTestsBase() { } @Test - fun `test possibility to create indexes when table exists in different schemas`() { - val TestTable = object : Table("test_table") { + fun testCreateIndexWithTableInDifferentSchemas() { + val testTable = object : Table("test_table") { val id = integer("id").uniqueIndex() val name = varchar("name", length = 42).index("test_index") init { @@ -81,16 +81,15 @@ class CreateIndexTests : DatabaseTestsBase() { val schema2 = Schema("Schema2") withSchemas(listOf(TestDB.SQLITE, TestDB.SQLSERVER), schema1, schema2) { SchemaUtils.setSchema(schema1) - SchemaUtils.createMissingTablesAndColumns(TestTable) - assertEquals(true, TestTable.exists()) + SchemaUtils.createMissingTablesAndColumns(testTable) + assertEquals(true, testTable.exists()) SchemaUtils.setSchema(schema2) - assertEquals(false, TestTable.exists()) - SchemaUtils.createMissingTablesAndColumns(TestTable) - assertEquals(true, TestTable.exists()) + assertEquals(false, testTable.exists()) + SchemaUtils.createMissingTablesAndColumns(testTable) + assertEquals(true, testTable.exists()) } } - @Test fun testCreateAndDropPartialIndexWithPostgres() { val partialIndexTable = object : IntIdTable("PartialIndexTableTest") {