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

JDBC H2, CHAR(10) column read as Char? instead of String? #701

Closed
Jolanrensen opened this issue May 17, 2024 · 2 comments · Fixed by #855
Closed

JDBC H2, CHAR(10) column read as Char? instead of String? #701

Jolanrensen opened this issue May 17, 2024 · 2 comments · Fixed by #855
Assignees
Labels
bug Something isn't working databases JDBC related issues
Milestone

Comments

@Jolanrensen
Copy link
Collaborator

@zaleslaw
From an H2 database, a CHAR(10) column is read as Char? instead of String?

This issue can be reproduced easily by editing the fun `read from huge table`() in h2Test.kt by adding the line:
schema.columns["characterCol"]!!.type shouldBe typeOf<String?>()
The column contains ["ABC", "DEF", "GHI"] so I gotta agree it's not supposed to be a Char.

I discovered it by exploring whether the DataColumnImpl.type actually matches the types found in DataColumnImpl.values, which mismatches in this case. It might be a good check to do for all type conversions :).

@zaleslaw
Copy link
Collaborator

zaleslaw commented Jun 4, 2024

@Jolanrensen what kind of dialect is set by default for H2 in your example?

@zaleslaw zaleslaw self-assigned this Jun 4, 2024
@zaleslaw zaleslaw added the databases JDBC related issues label Jun 4, 2024
@zaleslaw zaleslaw added this to the 0.14.0 milestone Jun 4, 2024
@Jolanrensen
Copy link
Collaborator Author

@zaleslaw not sure, I just ran your read from huge table test in h2Test.kt, so looking at that file, the connection URL is created like this:

private const val URL = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=MySQL;DATABASE_TO_UPPER=false"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working databases JDBC related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants