Skip to content

feat: add CockroachDB as a compatibility-tested database#316

Open
driessamyn wants to merge 1 commit into
mainfrom
feature/add-cockroachdb-compat
Open

feat: add CockroachDB as a compatibility-tested database#316
driessamyn wants to merge 1 commit into
mainfrom
feature/add-cockroachdb-compat

Conversation

@driessamyn
Copy link
Copy Markdown
Owner

@driessamyn driessamyn commented Mar 23, 2026

Summary

  • Adds CockroachDB compatibility testing (PostgreSQL wire-compatible, detected as DbFlavour.POSTGRESQL)
  • Uses CockroachContainer with cockroachdb/cockroach:latest-v24.3
  • Fixed convertInt to handle Long→Int conversion (CockroachDB returns INT8 for integer columns)
  • Added to nightly compatibility-test CI matrix

Test plan

  • Integration tests pass locally with -Ddb=COCKROACHDB
  • CI compatibility-test job runs successfully

Summary by CodeRabbit

  • New Features

    • Added CockroachDB as a supported database and included it in compatibility test runs.
  • Bug Fixes

    • Integer conversion now properly handles long values with range checking and clear errors for out-of-range inputs.
  • Tests

    • Extended database-detection tests and integration test matrix to cover CockroachDB.
  • Chores

    • Updated documentation badge and test tooling configuration to reflect CockroachDB support.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 23, 2026

Unit Tests

 61 files  ±0   61 suites  ±0   2m 44s ⏱️ -18s
518 tests +1  518 ✅ +1  0 💤 ±0  0 ❌ ±0 
534 runs  +1  534 ✅ +1  0 💤 ±0  0 ❌ ±0 

Results for commit da3b233. ± Comparison against base commit c431fe4.

This pull request removes 40 and adds 41 tests. Note that renamed tests count towards both.
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [10] LONGNVARCHAR, "LONGNVARCHAR", net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$1058/0x00007fba4c56aa20@51e1ee5b
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [11] LONGVARCHAR, "LONGVARCHAR", net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$1059/0x00007fba4c56ac40@539bf3b2
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [12] INSTANT, net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$960/0x00007fba4c545fe0@6802358e
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [12] NCHAR, "NCHAR", net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$1060/0x00007fba4c56a400@1ff4c3e
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [13] DATE, net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$961/0x00007fba4c546200@c210026
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [13] NCLOB, "NCLOB", net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$1061/0x00007fba4c570000@2bb34cd4
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [14] LOCALDATE, net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$962/0x00007fba4c546420@35c14d35
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [14] NVARCHAR, "NVARCHAR", net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$1062/0x00007fba4c570220@6a38c79f
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [15] LOCALDATETIME, net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$963/0x00007fba4c546640@4d81e2ae
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [15] ROWID, "ROWID", net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$1063/0x00007fba4c570440@77e734
…
net.samyn.kapper.internal.DbFlavourTest ‑ [4] "CockroachDB"
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [10] LONGNVARCHAR, "LONGNVARCHAR", net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$1082/0x00007fd8dc585100@52c563fb
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [11] LONGVARCHAR, "LONGVARCHAR", net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$1083/0x00007fd8dc585320@9c9bcbb
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [12] INSTANT, net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$961/0x00007fd8dc547a00@3dbef8e8
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [12] NCHAR, "NCHAR", net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$1084/0x00007fd8dc585540@a1b2cb0
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [13] DATE, net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$962/0x00007fd8dc547c20@4ff64f8e
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [13] NCLOB, "NCLOB", net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$1085/0x00007fd8dc585760@645fea31
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [14] LOCALDATE, net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$963/0x00007fd8dc542000@20bc9839
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [14] NVARCHAR, "NVARCHAR", net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$1086/0x00007fd8dc585980@8e1c04e
net.samyn.kapper.internal.automapper.SQLTypesConverterTest ‑ [15] LOCALDATETIME, net.samyn.kapper.internal.automapper.SQLTypesConverterTest$Companion$$Lambda$964/0x00007fd8dc542220@1bf8f493
…

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 23, 2026

Code Coverage

File Coverage [97.28%]
core/src/main/kotlin/net/samyn/kapper/internal/Converters.kt 97.01%
core/src/main/kotlin/net/samyn/kapper/internal/DbFlavourFunc.kt 100.00%
Total Project Coverage 97.73%

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

Adds CockroachDB support: CI matrix now runs compatibility tests for COCKROACHDB, README badge added, Testcontainers setup for CockroachDB included in integration tests, DbFlavour detects CockroachDB as PostgreSQL, converter improved for Long→Int handling, and test coverage updated.

Changes

Cohort / File(s) Summary
CI & Docs
.github/workflows/build-and-test.yml, README.md
Added COCKROACHDB to the CI compatibility test matrix and added a CockroachDB badge to README.
Testcontainers & Tests
core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt, core/src/test/kotlin/net/samyn/kapper/internal/DbFlavourTest.kt
Introduced a lazily-initialized CockroachDB Testcontainers container and added COCKROACHDB to test database parameterization; extended DbFlavour tests to include "CockroachDB".
Dependency Catalog
gradle/libs.versions.toml
Added test-containers-cockroachdb library and included it in the test-containers bundle.
Runtime Detection & Conversion
core/src/main/kotlin/net/samyn/kapper/internal/DbFlavourFunc.kt, core/src/main/kotlin/net/samyn/kapper/internal/Converters.kt
Mapped database product names containing "cockroach" to DbFlavour.POSTGRESQL; convertInt now accepts java.lang.Long with range check and throws KapperParseException on out-of-range values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

run-compat-tests

Poem

🐰 I hopped into tests where containers play,
Cockroach joined Postgres in the CI ballet.
Conversions checked, flavours align,
Integration hops run one more time.
Hooray — more databases in the rabbit's den!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding CockroachDB as a compatibility-tested database, which is reflected across all modified files (workflow, tests, converters, and documentation).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/add-cockroachdb-compat

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 23, 2026

POSTGRESQL Integration Tests

10 files  ±0  10 suites  ±0   27s ⏱️ -2s
46 tests ±0  46 ✅ ±0  0 💤 ±0  0 ❌ ±0 
76 runs  ±0  76 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit da3b233. ± Comparison against base commit c431fe4.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 23, 2026

SQLITE Integration Tests

10 files  ±0  10 suites  ±0   26s ⏱️ -2s
46 tests ±0  46 ✅ ±0  0 💤 ±0  0 ❌ ±0 
76 runs  ±0  76 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit da3b233. ± Comparison against base commit c431fe4.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 23, 2026

DUCKDB Integration Tests

10 files  ±0  10 suites  ±0   27s ⏱️ +3s
46 tests ±0  46 ✅ ±0  0 💤 ±0  0 ❌ ±0 
76 runs  ±0  76 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit da3b233. ± Comparison against base commit c431fe4.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 23, 2026

MYSQL Integration Tests

10 files  ±0  10 suites  ±0   50s ⏱️ +3s
46 tests ±0  46 ✅ ±0  0 💤 ±0  0 ❌ ±0 
76 runs  ±0  76 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit da3b233. ± Comparison against base commit c431fe4.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 23, 2026

MSSQLSERVER Integration Tests

10 files  ±0  10 suites  ±0   46s ⏱️ -1s
46 tests ±0  46 ✅ ±0  0 💤 ±0  0 ❌ ±0 
76 runs  ±0  76 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit da3b233. ± Comparison against base commit c431fe4.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 23, 2026

ORACLE Integration Tests

10 files  ±0  10 suites  ±0   1m 22s ⏱️ -1s
46 tests ±0  46 ✅ ±0  0 💤 ±0  0 ❌ ±0 
76 runs  ±0  76 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit da3b233. ± Comparison against base commit c431fe4.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt (1)

57-59: Consider pinning to a specific patch version for reproducibility.

The latest-v24.3 tag is a floating reference that updates with new patch releases. Other database containers in this file use fixed versions (e.g., postgres:16, mysql:8.4). While this ensures you get security patches automatically, it could cause non-deterministic CI failures if a new patch introduces regressions.

Consider using a specific version like cockroachdb/cockroach:v24.3.0 for more predictable builds, or document the rationale for using the floating tag.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt` around
lines 57 - 59, The CockroachDB test container uses the floating tag
"cockroachdb/cockroach:latest-v24.3" which can introduce non-deterministic CI
failures; update the lazy val cockroachdb initialization (the
CockroachContainer(...) call) to use a fixed patch version (e.g.,
"cockroachdb/cockroach:v24.3.0" or another concrete patch) for reproducible
builds, or add a comment documenting why a floating tag is intentionally used.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@core/src/main/kotlin/net/samyn/kapper/internal/Converters.kt`:
- Line 180: The pattern branch matching "is java.lang.Long -> value.toInt()"
silently truncates out-of-range Longs; replace it with a guarded conversion that
checks the Long against Int.MIN_VALUE..Int.MAX_VALUE (or the specific INT8 range
if converting for INT8) and throws an explicit exception (e.g.,
IllegalArgumentException or ArithmeticException) when out of range, so the
conversion in Converters.kt fails fast instead of truncating; locate the branch
matching "is java.lang.Long" and update the logic to validate the range before
calling toInt() and add/adjust unit tests to cover overflow cases.

---

Nitpick comments:
In `@core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt`:
- Around line 57-59: The CockroachDB test container uses the floating tag
"cockroachdb/cockroach:latest-v24.3" which can introduce non-deterministic CI
failures; update the lazy val cockroachdb initialization (the
CockroachContainer(...) call) to use a fixed patch version (e.g.,
"cockroachdb/cockroach:v24.3.0" or another concrete patch) for reproducible
builds, or add a comment documenting why a floating tag is intentionally used.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 62711d38-4051-4e63-b3a4-1c7c999c6b80

📥 Commits

Reviewing files that changed from the base of the PR and between c431fe4 and e7cf0f5.

📒 Files selected for processing (7)
  • .github/workflows/build-and-test.yml
  • README.md
  • core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt
  • core/src/main/kotlin/net/samyn/kapper/internal/Converters.kt
  • core/src/main/kotlin/net/samyn/kapper/internal/DbFlavourFunc.kt
  • core/src/test/kotlin/net/samyn/kapper/internal/DbFlavourTest.kt
  • gradle/libs.versions.toml

Comment thread core/src/main/kotlin/net/samyn/kapper/internal/Converters.kt Outdated
@driessamyn driessamyn force-pushed the feature/add-cockroachdb-compat branch from e7cf0f5 to da3b233 Compare March 24, 2026 07:34
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt (1)

57-59: Consider pinning to a specific image version for reproducibility.

The latest-v24.3 tag will pull the latest patch version within the v24.3 series. While this ensures security updates, it may cause non-deterministic builds if a new patch introduces behavioral changes. Other containers in this file use fully pinned versions (e.g., postgres:16, mysql:8.4).

Consider using a specific tag like cockroachdb/cockroach:v24.3.0 for more predictable CI behavior, or document the rationale for using the floating tag if this is intentional.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt` around
lines 57 - 59, The CockroachContainer image tag is floating
("cockroachdb/cockroach:latest-v24.3") which can make CI non-deterministic;
update the image string in the cockroachdb lazy property (the cockroachdb
variable in AbstractDbTests.kt) to a fully pinned version such as
"cockroachdb/cockroach:v24.3.0" (or another explicit patch tag you choose) so
test containers are reproducible, or alternatively add a brief comment next to
the cockroachdb definition documenting why the floating tag is intentionally
used.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt`:
- Around line 57-59: The CockroachContainer image tag is floating
("cockroachdb/cockroach:latest-v24.3") which can make CI non-deterministic;
update the image string in the cockroachdb lazy property (the cockroachdb
variable in AbstractDbTests.kt) to a fully pinned version such as
"cockroachdb/cockroach:v24.3.0" (or another explicit patch tag you choose) so
test containers are reproducible, or alternatively add a brief comment next to
the cockroachdb definition documenting why the floating tag is intentionally
used.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fa2df30f-a2eb-4c8c-a2c0-69030d1c114c

📥 Commits

Reviewing files that changed from the base of the PR and between e7cf0f5 and da3b233.

📒 Files selected for processing (7)
  • .github/workflows/build-and-test.yml
  • README.md
  • core/src/integrationTest/kotlin/net/samyn/kapper/AbstractDbTests.kt
  • core/src/main/kotlin/net/samyn/kapper/internal/Converters.kt
  • core/src/main/kotlin/net/samyn/kapper/internal/DbFlavourFunc.kt
  • core/src/test/kotlin/net/samyn/kapper/internal/DbFlavourTest.kt
  • gradle/libs.versions.toml
✅ Files skipped from review due to trivial changes (3)
  • core/src/main/kotlin/net/samyn/kapper/internal/DbFlavourFunc.kt
  • README.md
  • core/src/main/kotlin/net/samyn/kapper/internal/Converters.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/build-and-test.yml

@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant