From a4ebab930cff22964f1aabf09c5cb1588be4c5a9 Mon Sep 17 00:00:00 2001 From: Chantal Loncle <82039410+bog-walk@users.noreply.github.com> Date: Wed, 26 Jul 2023 12:43:02 -0400 Subject: [PATCH] test: Fix failing exposed-tests in Oracle FunctionsTests/testLocate03() - Oracle substring search is also case sensitive. DDLTests/createTableWithForeignKeyToAnotherSchema() - SQL statement used in exec() is terminated with a semi-colon and also does not provide the required privileges to reference tables across schema. CreateTableTests/createTableWithQuotes() - Oracle has been excluded because it does not tolerate a quoted table identifier in a sequence name: CREATE SEQUENCE ""Parent"_id_seq" START WITH CreateTableTests/createTableWithSingleQuotes() - Oracle produces 2 DDL statements, , as a sequence must be created first for the auto-increment PK. --- .../exposed/sql/tests/shared/DDLTests.kt | 4 +--- .../sql/tests/shared/ddl/CreateTableTests.kt | 22 ++++++++----------- .../tests/shared/functions/FunctionsTests.kt | 15 ++++--------- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/DDLTests.kt b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/DDLTests.kt index d98c4bc46a..273efff218 100644 --- a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/DDLTests.kt +++ b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/DDLTests.kt @@ -922,7 +922,7 @@ class DDLTests : DatabaseTestsBase() { withSchemas(two, one) { SchemaUtils.create(TableFromSchemeOne) if (currentDialectTest is OracleDialect) { - exec("GRANT SELECT ON ${TableFromSchemeOne.tableName} to TWO;") + exec("GRANT REFERENCES ON ${TableFromSchemeOne.tableName} to TWO") } SchemaUtils.create(TableFromSchemeTwo) val idFromOne = TableFromSchemeOne.insertAndGetId { } @@ -1114,8 +1114,6 @@ class DDLTests : DatabaseTestsBase() { if (currentDialectTest is SQLServerDialect) { SchemaUtils.drop(tableA, tableB) } - } } - } diff --git a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/CreateTableTests.kt b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/CreateTableTests.kt index 72469e5077..6c5420dac2 100644 --- a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/CreateTableTests.kt +++ b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/CreateTableTests.kt @@ -335,8 +335,7 @@ class CreateTableTests : DatabaseTestsBase() { onDelete = ReferenceOption.NO_ACTION, ) } - withTables(excludeSettings = listOf(TestDB.H2_ORACLE), parent, child) { - // Different dialects use different mix of lowercase/uppercase in their names + withTables(excludeSettings = listOf(TestDB.H2_ORACLE, TestDB.ORACLE), parent, child) { val expected = listOf( "CREATE TABLE " + addIfNotExistsIfSupported() + "${this.identity(child)} (" + "${child.columns.joinToString { it.descriptionDdl(false) }}," + @@ -360,17 +359,14 @@ class CreateTableTests : DatabaseTestsBase() { onDelete = ReferenceOption.NO_ACTION, ) } - withTables(excludeSettings = listOf(TestDB.H2_ORACLE), parent, child) { - // Different dialects use different mix of lowercase/uppercase in their names - val expected = listOf( - "CREATE TABLE " + addIfNotExistsIfSupported() + "${this.identity(child)} (" + - "${child.columns.joinToString { it.descriptionDdl(false) }}," + - " CONSTRAINT ${"fk_Child2_parent_id__id".inProperCase()}" + - " FOREIGN KEY (${this.identity(child.parentId)})" + - " REFERENCES ${this.identity(parent)}(${this.identity(parent.id)})" + - ")" - ) - assertEqualCollections(child.ddl, expected) + withTables(parent, child) { + val expected = "CREATE TABLE " + addIfNotExistsIfSupported() + "${this.identity(child)} (" + + "${child.columns.joinToString { it.descriptionDdl(false) }}," + + " CONSTRAINT ${"fk_Child2_parent_id__id".inProperCase()}" + + " FOREIGN KEY (${this.identity(child.parentId)})" + + " REFERENCES ${this.identity(parent)}(${this.identity(parent.id)})" + + ")" + assertEquals(child.ddl.last(), expected) } } diff --git a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/functions/FunctionsTests.kt b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/functions/FunctionsTests.kt index 6f4c444bc5..4b7c36d136 100644 --- a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/functions/FunctionsTests.kt +++ b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/functions/FunctionsTests.kt @@ -12,12 +12,7 @@ import org.jetbrains.exposed.sql.tests.shared.assertEqualCollections import org.jetbrains.exposed.sql.tests.shared.assertEquals import org.jetbrains.exposed.sql.tests.shared.dml.DMLTestsData import org.jetbrains.exposed.sql.tests.shared.dml.withCitiesAndUsers -import org.jetbrains.exposed.sql.vendors.H2Dialect -import org.jetbrains.exposed.sql.vendors.OracleDialect -import org.jetbrains.exposed.sql.vendors.PostgreSQLDialect -import org.jetbrains.exposed.sql.vendors.SQLServerDialect -import org.jetbrains.exposed.sql.vendors.SQLiteDialect -import org.jetbrains.exposed.sql.vendors.h2Mode +import org.jetbrains.exposed.sql.vendors.* import org.junit.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull @@ -356,16 +351,14 @@ class FunctionsTests : DatabaseTestsBase() { @Test fun testLocate03() { withCitiesAndUsers { cities, _, _ -> - val isCaseSensitiveDialect = currentDialectTest is SQLiteDialect || - currentDialectTest is PostgreSQLDialect || - currentDialectTest is H2Dialect + val isNotCaseSensitiveDialect = currentDialectTest is MysqlDialect || currentDialectTest is SQLServerDialect val locate = cities.name.locate("p") val results = cities.slice(locate).selectAll().toList() - assertEquals(if (isCaseSensitiveDialect) 0 else 5, results[0][locate]) // St. Petersburg + assertEquals(if (isNotCaseSensitiveDialect) 5 else 0, results[0][locate]) // St. Petersburg assertEquals(0, results[1][locate]) // Munich - assertEquals(if (isCaseSensitiveDialect) 0 else 1, results[2][locate]) // Prague + assertEquals(if (isNotCaseSensitiveDialect) 1 else 0, results[2][locate]) // Prague } }