Skip to content

Override $identitySelect for CockroachDB adapter#1989

Closed
bpamiri wants to merge 1 commit intodevelopfrom
peter/1971-cockroachdb-identity-select
Closed

Override $identitySelect for CockroachDB adapter#1989
bpamiri wants to merge 1 commit intodevelopfrom
peter/1971-cockroachdb-identity-select

Conversation

@bpamiri
Copy link
Collaborator

@bpamiri bpamiri commented Mar 16, 2026

Summary

  • CockroachDB inherits PostgreSQL's $identitySelect() which uses pg_get_serial_sequence() and currval() — neither of which CockroachDB supports
  • Overrides the method in CockroachDBModel.cfc with a MAX-based query, since CockroachDB's unique_rowid() generates monotonically increasing values
  • Follows the same pattern used by the Oracle adapter, with BoxLang compatibility from the PostgreSQL adapter

Closes #1971

Test plan

  • Verify model("Foo").create(...) returns the correct primary key on CockroachDB
  • Verify explicit PK inserts still work (no identity select triggered)
  • Confirm no regression on PostgreSQL (parent adapter unchanged)

🤖 Generated with Claude Code

CockroachDB doesn't support pg_get_serial_sequence() or currval() which
the inherited PostgreSQL adapter uses. Override with a MAX-based query
since CockroachDB's unique_rowid() generates monotonically increasing
values (same approach as the Oracle adapter).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2026

Wheels Test Matrix

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

Results for commit 2828efa.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2026

Wheels Test Results

    42 files  ±0   3 906 suites  ±0   25m 11s ⏱️ -25s
79 512 tests ±0  79 124 ✅ ±0  388 💤 ±0  0 ❌ ±0 
82 158 runs  ±0  81 770 ✅ ±0  388 💤 ±0  0 ❌ ±0 

Results for commit 066a10f. ± Comparison against base commit e57ecf8.

♻️ This comment has been updated with latest results.

@bpamiri
Copy link
Collaborator Author

bpamiri commented Mar 17, 2026

Closing in favor of #1896's RETURNING-based approach, which avoids the race condition inherent in SELECT MAX(pk).

@bpamiri bpamiri closed this Mar 17, 2026
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: $identitySelect may fail with unique_rowid()

1 participant