Skip to content

Commit

Permalink
UUID decoding broken with MariaDB driver 3.0.3 #1467
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapac committed Apr 9, 2022
1 parent f690924 commit 3753503
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ nexusPublishing {
}

repositories {
mavenLocal()
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,17 @@ class DBTestingPlugin : Plugin<Project> {
testRuntimeOnly("com.microsoft.sqlserver", "mssql-jdbc", Versions.sqlserver)
}

val mariadb = register<DBTestWithDockerCompose>("mariadbTest", Parameters("MARIADB", 3306)) {
testRuntimeOnly("org.mariadb.jdbc", "mariadb-java-client", Versions.mariaDB)
val mariadb_v2 = register<DBTestWithDockerCompose>("mariadb_v2Test", Parameters("MARIADB", 3306)) {
testRuntimeOnly("org.mariadb.jdbc", "mariadb-java-client", Versions.mariaDB_v2)
}

val mariadb_v3 = register<DBTestWithDockerCompose>("mariadb_v3Test", Parameters("MARIADB", 3306)) {
testRuntimeOnly("org.mariadb.jdbc", "mariadb-java-client", Versions.mariaDB_v3)
}

val mariadb = register<Test>("mariadbTest") {
group = "verification"
delegatedTo(mariadb_v2, mariadb_v3)
}

named<Test>("test") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ object Versions {
/** JDBC drivers **/
const val h2 = "1.4.199"
const val h2_v2 = "2.1.210"
const val mariaDB = "2.7.4"
const val mariaDB_v2 = "2.7.4"
const val mariaDB_v3 = "3.0.4"
const val mysql51 = "5.1.49"
const val mysql80 = "8.0.27"
const val oracle12 = "12.2.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.jetbrains.exposed.dao.id.IdTable
import org.jetbrains.exposed.sql.statements.DefaultValueMarker
import org.jetbrains.exposed.sql.statements.api.ExposedBlob
import org.jetbrains.exposed.sql.statements.api.PreparedStatementApi
import org.jetbrains.exposed.sql.vendors.MariaDBDialect
import org.jetbrains.exposed.sql.vendors.currentDialect
import java.io.InputStream
import java.lang.IllegalArgumentException
Expand Down Expand Up @@ -753,6 +754,11 @@ class UUIDColumnType : ColumnType() {
else -> error("Unexpected value of type UUID: ${value.javaClass.canonicalName}")
}

override fun readObject(rs: ResultSet, index: Int): Any? = when (currentDialect) {
is MariaDBDialect -> rs.getBytes(index)
else -> super.readObject(rs, index)
}

companion object {
private val uuidRegexp = Regex("[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}", RegexOption.IGNORE_CASE)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ class InsertTests : DatabaseTestsBase() {
}
}

fun nullableType():Int? = 42

@Test fun `test optReference allows null values`() {
withTables(EntityTests.Posts) {
val id1 = EntityTests.Posts.insertAndGetId {
Expand All @@ -550,6 +552,15 @@ class InsertTests : DatabaseTestsBase() {
it[category] = categoryId
it[board] = boardId.value
}

// val nullableCategoryID: UUID? = UUID.randomUUID()
// val nullableBoardId: Int? = 42
// EntityTests.Posts.insertAndGetId {
// it[board] = Op.nullOp()
// it[category] = nullableCategoryID
// it[board] = nullableType()
// }
}

}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ org.gradle.parallel=false
org.gradle.jvmargs=-Dfile.encoding=UTF-8
#
group=org.jetbrains.exposed
version=0.37.3
version=0.38.1-SNAPSHOT

0 comments on commit 3753503

Please sign in to comment.