diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index f8e54883..f59a6995 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -126,7 +126,7 @@ jobs: if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'run-compat-tests') strategy: matrix: - db: [ MARIADB ] + db: [ MARIADB, TIDB ] steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with: diff --git a/README.md b/README.md index 3ba8153f..b605c723 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Kapper is a lightweight, Dapper-inspired ORM (Object-Relational Mapping) library ![MSSQL](https://img.shields.io/badge/mssql-%23CC2927.svg?style=for-the-badge&logo=microsoftsqlserver&logoColor=white) ![DuckDB](https://img.shields.io/badge/duckdb-FFF000.svg?style=for-the-badge&logo=duckdb&logoColor=black) ![MariaDB](https://img.shields.io/badge/mariadb-003545.svg?style=for-the-badge&logo=mariadb&logoColor=white) +![TiDB](https://img.shields.io/badge/tidb-DD0031.svg?style=for-the-badge&logo=tidb&logoColor=white) See [Kapper](https://driessamyn.github.io/kapper/) for more information. diff --git a/core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt b/core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt index 5d48d0c8..acc28a94 100644 --- a/core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt +++ b/core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt @@ -10,6 +10,8 @@ import org.junit.jupiter.params.ParameterizedClass import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.Arguments.arguments import org.junit.jupiter.params.provider.MethodSource +import org.testcontainers.containers.GenericContainer +import org.testcontainers.utility.DockerImageName import org.testcontainers.containers.JdbcDatabaseContainer import org.testcontainers.containers.MSSQLServerContainer import org.testcontainers.containers.MariaDBContainer @@ -57,6 +59,13 @@ abstract class AbstractDbTests { MariaDBContainer("mariadb:11.7").also { it.start() } } + private val tidb by lazy { + GenericContainer(DockerImageName.parse("pingcap/tidb:v8.5.1")).apply { + withExposedPorts(4000) + start() + } + } + private val msSqlServer by lazy { MSSQLServerContainer("mcr.microsoft.com/mssql/server:2017-CU12") .acceptLicense() @@ -86,6 +95,11 @@ abstract class AbstractDbTests { "MSSQLSERVER" to { getConnection(msSqlServer) }, "ORACLE" to { getConnection(oracle) }, "MARIADB" to { getConnection(mariadb) }, + "TIDB" to { + DriverManager.getConnection( + "jdbc:mysql://${tidb.host}:${tidb.getMappedPort(4000)}/test?user=root&allowPublicKeyRetrieval=true&useSSL=false", + ) + }, ) val dbs = diff --git a/core/src/main/kotlin/net/samyn/kapper/internal/DbFlavourFunc.kt b/core/src/main/kotlin/net/samyn/kapper/internal/DbFlavourFunc.kt index 902c820f..39130579 100644 --- a/core/src/main/kotlin/net/samyn/kapper/internal/DbFlavourFunc.kt +++ b/core/src/main/kotlin/net/samyn/kapper/internal/DbFlavourFunc.kt @@ -11,7 +11,8 @@ fun Connection.getDbFlavour(): DbFlavour { productName.contains("postgres", ignoreCase = true) || productName.contains("enterprisedb", ignoreCase = true) -> DbFlavour.POSTGRESQL productName.contains("mysql", ignoreCase = true) || - productName.contains("mariadb", ignoreCase = true) -> DbFlavour.MYSQL + productName.contains("mariadb", ignoreCase = true) || + productName.contains("tidb", ignoreCase = true) -> DbFlavour.MYSQL productName.contains("sqlite", ignoreCase = true) -> DbFlavour.SQLITE productName.contains("oracle", ignoreCase = true) -> DbFlavour.ORACLE productName.contains("sql server", ignoreCase = true) || diff --git a/core/src/test/kotlin/net/samyn/kapper/internal/DbFlavourTest.kt b/core/src/test/kotlin/net/samyn/kapper/internal/DbFlavourTest.kt index 6ae54a6d..85f2822f 100644 --- a/core/src/test/kotlin/net/samyn/kapper/internal/DbFlavourTest.kt +++ b/core/src/test/kotlin/net/samyn/kapper/internal/DbFlavourTest.kt @@ -34,6 +34,8 @@ class DbFlavourTest { "MySQL Community Server", "MySQL Enterprise Server", "MariaDB", + "TiDB", + "TiDB Server", ], ) fun `when databaseProductName is mysql then getDbFlavour returns MYSQL`(value: String) {