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

Add a support for H2 modes #720

Merged
merged 10 commits into from
Jun 13, 2024
Merged

Add a support for H2 modes #720

merged 10 commits into from
Jun 13, 2024

Conversation

zaleslaw
Copy link
Collaborator

@zaleslaw zaleslaw commented Jun 4, 2024

Now, two suits of tests are created: local with real database connection and full coverage, and they are staying ignored before Docker support and H2 test based on H2 ability to support different dialects.

Unfortunately, H2 supports dialects with limitations and doesn't support correctly many complex types as JSON or DateTime

Fixes #668

H2 database util has been refactored to inherit DbType, allowing for the use of different dialects. Updated the relevant test cases and added a function to correctly identify the dialect based on the URL. Added error handling for unsupported dialects.
The jts-core library was added to the project dependencies, allowing for usage in the codebase. Moreover, some improvements in the documentation of the code were made. Specifically, better explanations were provided for error cases in the `extractDBTypeFromConnection` and `extractDBTypeFromUrl` functions, and extensive documentation was added for the companion object in the H2.kt file.
Various minor formatting changes have been applied to improve code readability. This includes rearranging import statements in the 'postgresTest.kt' file, removing superfluous empty lines in 'mssqlTest.kt', and adjusting white-spacing for improved consistency in 'util.kt' and 'H2.kt'.
@zaleslaw zaleslaw marked this pull request as ready for review June 12, 2024 10:59
Copy link
Collaborator

@Jolanrensen Jolanrensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice we can now test (for the most part) all our supported jdbc databases :)

import java.util.UUID
import kotlin.reflect.typeOf

private const val URL = "jdbc:h2:mem:test3;DB_CLOSE_DELAY=-1;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE;DEFAULT_NULL_ORDERING=HIGH"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So setting the url like this and the dependency being there is all it takes to set up an h2 db with a certain dialect? :)

Performed a refinement in the H2 class and implemented test coverage for specific conditions. The H2 class now uses the class reference for comparison instead of the simple name, eliminating string comparison. Additionally, a test has been added to check that an exception is properly thrown when specifying an H2 database with H2 dialect. Minor import adjustments were also made in the readJdbc and mssqlTest files.
@zaleslaw zaleslaw merged commit c40fb04 into Kotlin:master Jun 13, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

Add to JDBC module ability to set up a testing H2 database with the specific dialect
2 participants