Skip to content

feat(database): typed constraint violations across dialects - #95

Open
artile wants to merge 3 commits into
MapleTechLabs:mainfrom
artile:feat/constraint-errors
Open

artile wants to merge 3 commits into
MapleTechLabs:mainfrom
artile:feat/constraint-errors

Conversation

@artile

@artile artile commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

No description provided.

…tement timeout

ClickHouse code 469 is VIOLATED_CONSTRAINT (a failed CHECK). Effect's Node
driver reads it as StatementTimeoutError, which says retry. The HTTP client
copied that; it now gives ConstraintError.
refineConstraints turns a DatabaseError or TransactionCommitFailed for a
broken constraint into UniqueViolation, ForeignKeyViolation,
NotNullViolation or CheckViolation, with the constraint, table and column
the server named. Postgres: SQLSTATE 23505, 23503, 23502, 23514. ClickHouse:
code 469 is CheckViolation, named from the message.

DatabaseError and TransactionCommitFailed keep the server's numeric code as
errorCode, which sqlStateOf dropped for ClickHouse.
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 53267220-11f7-48d3-9ea8-fe9618189817
Commits

Reviewing files that changed from the base of the PR and between c5fa679 and d0efaaf.

Files selected for processing: 14
  • .changeset/constraint-errors.md
  • design/gap-review.md
  • docs/database.md
  • docs/reference.md
  • src/clickhouse-http/client.test.ts
  • src/clickhouse-http/client.ts
  • src/database.ts
  • src/database/constraint.test.ts
  • src/database/constraint.ts
  • src/database/database.test-d.ts
  • src/database/database.ts
  • src/database/errors.ts
  • src/database/sql-error.ts
  • tests/database.clickhouse.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@artile
artile marked this pull request as ready for review October 25, 2026 15:02
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