Skip to content

Conversation

@hongkongkiwi
Copy link

Summary

This PR adds CockroachDB support to SeaORM. CockroachDB is wire-compatible with PostgreSQL, so most functionality works with the existing sqlx-postgres driver.

Changes

  • Added cockroachdb feature flag
  • Added DatabaseBackend::Cockroach variant
  • Added URL scheme handling (cockroachdb://, postgres://, postgresql://)
  • Added schema generation for IDENTITY columns (not SERIAL)
  • Added documentation
  • Added tests

Feature Flags

Feature Description
cockroachdb Enable CockroachDB support
cockroachdb-use-identity-pk Use IDENTITY columns for primary keys

Testing

Added tests/cockroachdb_tests.rs with tests for:

  • Backend detection with various URL schemes
  • Schema generation using IDENTITY columns
  • Boolean value conversion

Breaking Changes

None - all changes are gated behind the new cockroachdb feature flag.


Related: #2929

- Added DatabaseBackend::Cockroach variant
- Added cockroachdb feature flag
- Added schema generation for IDENTITY columns
- Added documentation and tests

Related: SeaQL/sea-query#329
@hongkongkiwi hongkongkiwi changed the title Add CockroachDB support feat: Add CockroachDB support Jan 26, 2026
@hongkongkiwi hongkongkiwi mentioned this pull request Jan 26, 2026
10 tasks
hongkongkiwi and others added 2 commits January 28, 2026 23:53
- Fix non-exhaustive pattern matching in statement.rs for CockroachDB variant
- Add cockroachdb feature to test macro cfg attributes
- Add CockroachDB to tracing spans db_system_name
- Add CockroachDB to paginator i64 count handling
- Add CockroachDB to proxy database connector
- Add CockroachDB to schema discovery
- Expand test coverage with 5 new tests:
  * Statement building test
  * Schema statements test
  * Mock database test
  * INSERT building test

Co-Authored-By: Claude <[email protected]>
The option-cockroachdb-use-identity feature was defined but never used.
CockroachDB already requires GENERATED BY DEFAULT AS IDENTITY columns,
which is the default behavior of PostgresQueryBuilder when
option-postgres-use-serial is not enabled.

Cleanup: removed from both sea-query and sea-orm Cargo.toml files.

Co-Authored-By: Claude <[email protected]>
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