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

UUID decoding broken with MariaDB driver 3.0.3 #1467

Closed
nielsvanvelzen opened this issue Mar 7, 2022 · 1 comment
Closed

UUID decoding broken with MariaDB driver 3.0.3 #1467

nielsvanvelzen opened this issue Mar 7, 2022 · 1 comment

Comments

@nielsvanvelzen
Copy link

nielsvanvelzen commented Mar 7, 2022

A weird issue popped up after upgrading the MariaDB driver (org.mariadb.jdbc:mariadb-java-client) from 2.7.5 to 3.0.3.

A column with UUID type fails to properly decode the UUID after upgrading. A small example which is partially copied from our codebase:

object ClientTable : Table("client") {
	val id = uuid("id").autoGenerate()

	override val primaryKey = PrimaryKey(id)
}

transaction {
	val id = UUID.fromString("d4ae5273-6cbd-4b0a-a032-b7c79834151e")
	val client = ClientTable.select { ClientTable.id.eq(id) }.firstOrNull()
	requireNotNull(client) { "Client not found" }
	require(client[ClientTable.id] == id) { "${client[ClientTable.id]} != $id" }
}

The above sample fails with this exception:

Exception in thread "main" java.lang.IllegalArgumentException: d4ae5273-6cef-bfbd-4b0a-efbfbd32efbf != d4ae5273-6cbd-4b0a-a032-b7c79834151e

As you can see, the id (which should be d4ae5273-6cbd-4b0a-a032-b7c79834151e) changed to a different value (d4ae5273-6cef-bfbd-4b0a-efbfbd32efbf). Looking at the database values in the database explorer within IntelliJ shows the correct UUID. Looking at this, I assume that encoding/serializing the UUID works fine, but decoding/deserializing the data from the database is somehow broken.

edit: The issue also happens for 3.0.0-alpha, 3.0.1-beta and 3.0.2-rc.

@suniastar
Copy link

suniastar commented Apr 7, 2022

I have exactly the same problem.
Testing was done with Exposed 3.0.3 and a basic mariadb docker container.
This also happens when using a "UUIDTable".

Edit: I've also tried a postgres database and as that one has an uuid type build-in there is no such error.
I guess its related to the encoding/decoding in sql/ColumnType as @nielsvanvelzen mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants