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
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
Expand Down Expand Up @@ -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
Expand Up @@ -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) }}," +
Expand All @@ -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)
}
}

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

Expand Down