Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix failing exposed-tests in Oracle #1803

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
bog-walk committed Jul 27, 2023

Verified

This commit was signed with the committer’s verified signature.
commit a4ebab930cff22964f1aabf09c5cb1588be4c5a9
Original file line number Diff line number Diff line change
@@ -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)
}

}
}

}
Original file line number Diff line number Diff line change
@@ -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)
}
}

Original file line number Diff line number Diff line change
@@ -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
}
}