Skip to content

Add CockroachDB RETURNING-based identity select and CI test matrix#1896

Draft
zainforbjs wants to merge 8 commits intodevelopfrom
cockroachdb-enhacement
Draft

Add CockroachDB RETURNING-based identity select and CI test matrix#1896
zainforbjs wants to merge 8 commits intodevelopfrom
cockroachdb-enhacement

Conversation

@zainforbjs
Copy link
Contributor

@zainforbjs zainforbjs commented Feb 25, 2026

Summary

Completes CockroachDB adapter support with proper identity select and full CI coverage.

  • RETURNING clause: CockroachDB doesn't support pg_get_serial_sequence()/currval(), so INSERTs now use RETURNING pk to retrieve generated keys — no race condition
  • Version detection fallback: CockroachDB uses the PostgreSQL JDBC driver, so SELECT version() disambiguates when driver_name reports "PostgreSQL"
  • CI test matrix: CockroachDB added to Docker Compose, all CFConfig datasources, and the test workflow with proper readiness checks
  • Adapter name lists: CockroachDB added to sql.cfc and update.cfc adapter checks for UPDATE with include

Changes from original PR

  • CockroachDBModel now extends PostgreSQLModel (not Base) — inherits query helpers, only overrides what differs
  • Boolean maps to cf_sql_boolean (not cf_sql_bit) — CockroachDB enforces strict type checking
  • CockroachDBMigrator kept as-is from develop (extends PostgreSQLMigrator with unique_rowid())
  • Removed unrelated server.json change
  • Removed currval() fallback (unsupported by CockroachDB)
  • Replaced sleep 10 in start.sh with proper readiness loop
  • Adapted to new engine-grouped CI workflow structure

Closes #1971, closes #1973

🤖 Generated with Claude Code

bpamiri and others added 3 commits March 17, 2026 15:45
CockroachDB uses the PostgreSQL wire protocol, so some JDBC drivers
report "PostgreSQL" as the driver name. Add a SELECT version() fallback
in Model.cfc and migrator/Base.cfc to detect CockroachDB when the
driver doesn't expose it in database_productname.

Also add CockroachDB to adapter name lists in sql.cfc and update.cfc
so UPDATE with include works correctly.

Co-Authored-By: Zain Ul Abideen <zainforbjs@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CockroachDB doesn't support pg_get_serial_sequence()/currval(), so use
a RETURNING clause on INSERTs to retrieve the generated primary key.

- CockroachDBModel extends PostgreSQLModel (inherits query helpers)
- $querySetup appends RETURNING to INSERT statements
- $identitySelect handles generatedKey (Lucee) and returningIdentity (ACF)
- Base.cfc passes returningIdentity from cfquery result to adapters
- Boolean stays mapped to cf_sql_boolean (CockroachDB strict typing)

Co-Authored-By: Zain Ul Abideen <zainforbjs@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add cockroachdb service to compose.yml with init scripts
- Add wheelstestdb_cockroachdb datasource to all 8 CFConfig files
- Add cockroachdb to CI database list and readiness checks
- Add cockroachdb column to test matrix summary grid
- Update test runner to accept cockroachdb as valid db param
- Update populate.cfm with CockroachDB-specific identity column type
- Loosen test assertions for integer types (bigint for CockroachDB keys)
- Use readiness loop instead of fixed sleep in start.sh

Co-Authored-By: Zain Ul Abideen <zainforbjs@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bpamiri bpamiri force-pushed the cockroachdb-enhacement branch from c4e8467 to 0f2d61f Compare March 18, 2026 11:54
@bpamiri bpamiri changed the title Fix cockroachdb getting last id issue Add CockroachDB RETURNING-based identity select and CI test matrix Mar 18, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Wheels Test Matrix

Engine MySQL PostgreSQL SQL Server H2 Oracle SQLite CockroachDB
lucee5 ❌ 29
lucee6 ❌ 29
lucee7 ❌ 29
adobe2018 -- -- ❌ 29
adobe2021 -- ❌ 29
adobe2023 -- ❌ 29
adobe2025 -- ❌ 29
boxlang -- ❌ 39

Results for commit ac5a8d8.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Wheels Test Results

    50 files  +     8       1 errors  4 655 suites  +749   35m 53s ⏱️ + 10m 11s
93 895 tests +14 215  93 220 ✅ +14 012  472 💤 +84  119 ❌ +119  84 🔥 ±0 
96 982 runs  +14 656  96 307 ✅ +14 453  472 💤 +84  119 ❌ +119  84 🔥 ±0 

For more details on these parsing errors, failures and errors, see this check.

Results for commit 6b54f83. ± Comparison against base commit 63a6bdc.

♻️ This comment has been updated with latest results.

bpamiri and others added 5 commits March 18, 2026 12:24
Tests $getType boolean mapping, $generatedKey, $identitySelect with
generatedKey/returningIdentity/column-list-guard/non-INSERT guard,
and migrator addPrimaryKeyOptions with unique_rowid().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CRUD lifecycle, boolean handling, sequential identity select,
and findAll. Guarded to only run when db=cockroachdb.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…dation type map

$getValidationType mapped CF_SQL_BIT to "boolean" but had no case for
CF_SQL_BOOLEAN, causing CockroachDB boolean columns to fall through to
"string". This made hasChanged() report false positives when comparing
boolean values like "false" against the persisted false.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ance

CFML closures execute in their defining scope, not the scope they're
assigned to. The injected action closures couldn't find renderText()
and renderNothing() because those are controller variables-scope
methods. Fix by capturing the controller instance in a local var and
calling ctrl.renderText()/ctrl.renderNothing() explicitly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CFML void functions don't assign null to a variable — the variable
simply doesn't exist, causing 'variable [RV] doesn't exist' errors.
Use IsNull() on the raw function call instead of toBeNull() on a var.

Verified: 1979 specs, 0 failures, 0 errors on Lucee 6 + MySQL.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CockroachDB: add to CI test matrix and Docker Compose CockroachDB: $identitySelect may fail with unique_rowid()

2 participants