Skip to content

Commit e7cf0f5

Browse files
committed
feat: add CockroachDB as a compatibility-tested database
1 parent c431fe4 commit e7cf0f5

7 files changed

Lines changed: 14 additions & 2 deletions

File tree

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ jobs:
126126
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'run-compat-tests')
127127
strategy:
128128
matrix:
129-
db: [ MARIADB ]
129+
db: [ MARIADB, COCKROACHDB ]
130130
steps:
131131
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
132132
with:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Kapper is a lightweight, Dapper-inspired ORM (Object-Relational Mapping) library
2222
![MSSQL](https://img.shields.io/badge/mssql-%23CC2927.svg?style=for-the-badge&logo=microsoftsqlserver&logoColor=white)
2323
![DuckDB](https://img.shields.io/badge/duckdb-FFF000.svg?style=for-the-badge&logo=duckdb&logoColor=black)
2424
![MariaDB](https://img.shields.io/badge/mariadb-003545.svg?style=for-the-badge&logo=mariadb&logoColor=white)
25+
![CockroachDB](https://img.shields.io/badge/cockroachdb-6933FF.svg?style=for-the-badge&logo=cockroachlabs&logoColor=white)
2526

2627
See [Kapper](https://driessamyn.github.io/kapper/) for more information.
2728

core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.junit.jupiter.params.ParameterizedClass
1010
import org.junit.jupiter.params.provider.Arguments
1111
import org.junit.jupiter.params.provider.Arguments.arguments
1212
import org.junit.jupiter.params.provider.MethodSource
13+
import org.testcontainers.containers.CockroachContainer
1314
import org.testcontainers.containers.JdbcDatabaseContainer
1415
import org.testcontainers.containers.MSSQLServerContainer
1516
import org.testcontainers.containers.MariaDBContainer
@@ -53,6 +54,10 @@ abstract class AbstractDbTests {
5354
.also { it.start() }
5455
}
5556

57+
private val cockroachdb by lazy {
58+
CockroachContainer("cockroachdb/cockroach:latest-v24.3").also { it.start() }
59+
}
60+
5661
private val mariadb by lazy {
5762
MariaDBContainer("mariadb:11.7").also { it.start() }
5863
}
@@ -86,6 +91,7 @@ abstract class AbstractDbTests {
8691
"MSSQLSERVER" to { getConnection(msSqlServer) },
8792
"ORACLE" to { getConnection(oracle) },
8893
"MARIADB" to { getConnection(mariadb) },
94+
"COCKROACHDB" to { getConnection(cockroachdb) },
8995
)
9096

9197
val dbs =

core/src/main/kotlin/net/samyn/kapper/internal/Converters.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ internal fun convertChar(value: Any): Char =
177177
internal fun convertInt(value: Any): Int =
178178
when (value) {
179179
is Integer -> value.toInt()
180+
is java.lang.Long -> value.toInt()
180181
is java.lang.Float -> value.toInt()
181182
is Float -> value.toInt()
182183
is BigDecimal -> value.toInt()

core/src/main/kotlin/net/samyn/kapper/internal/DbFlavourFunc.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import java.sql.Connection
88
fun Connection.getDbFlavour(): DbFlavour {
99
val productName = this.metaData.databaseProductName
1010
return when {
11+
productName.contains("cockroach", ignoreCase = true) -> DbFlavour.POSTGRESQL
1112
productName.contains("postgres", ignoreCase = true) ||
1213
productName.contains("enterprisedb", ignoreCase = true) -> DbFlavour.POSTGRESQL
1314
productName.contains("mysql", ignoreCase = true) ||

core/src/test/kotlin/net/samyn/kapper/internal/DbFlavourTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class DbFlavourTest {
1818
"PostgreSQL",
1919
"Postgres",
2020
"EnterpriseDB",
21+
"CockroachDB",
2122
],
2223
)
2324
fun `when databaseProductName is postgresql then getDbFlavour returns POSTGRESQL`(value: String) {

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ test-containers-mysql = { module = "org.testcontainers:mysql", version.ref = "te
5151
test-containers-oracle = { module = "org.testcontainers:oracle-free", version.ref = "test-containers" }
5252
test-containers-mariadb = { module = "org.testcontainers:mariadb", version.ref = "test-containers" }
5353
test-containers-postgresql = { module = "org.testcontainers:postgresql", version.ref = "test-containers" }
54+
test-containers-cockroachdb = { module = "org.testcontainers:cockroachdb", version.ref = "test-containers" }
5455

5556
# Example dependencies
5657
hibernate-community-dialects = { module = "org.hibernate.orm:hibernate-community-dialects", version = "7.3.0.Final" }
@@ -83,7 +84,8 @@ test-containers = [
8384
"test-containers-mysql",
8485
"test-containers-postgresql",
8586
"test-containers-mssqlserver",
86-
"test-containers-oracle"
87+
"test-containers-oracle",
88+
"test-containers-cockroachdb"
8789
]
8890
test-dbs = ["mariadb-driver", "mysql-driver", "postgresql-driver", "sqlite-jdbc", "duckdb-jdbc", "mssql-server-driver", "oracle-driver"]
8991

0 commit comments

Comments
 (0)