Skip to content

feat(backend): add PostgreSQL constraint support protocol - #27

Merged
vistart merged 3 commits into
release/v1.0.0.dev10from
feature/ddl-constraint-expressions
Apr 11, 2026
Merged

vistart merged 3 commits into
release/v1.0.0.dev10from
feature/ddl-constraint-expressions

Conversation

@vistart

@vistart vistart commented Apr 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds # (issue)

Type of change

  • feat: A new feature
  • docs: Documentation only changes (if related to the new feature)
  • perf: A code change that improves performance (if part of the feature)
  • test: Adding missing tests or correcting existing tests (for the new feature)
  • chore: Changes to the build process or auxiliary tools and libraries suchs as documentation generation (if related to the new feature)
  • ci: Changes to our CI configuration files and scripts (if related to the new feature)
  • build: Changes that affect the build system or external dependencies (if related to the new feature)
  • revert: Reverts a previous commit

Breaking Change

  • Yes
  • No

Related Repositories/Packages

Testing

  • I have added new tests to cover my changes.
  • I have updated existing tests to reflect my changes.
  • All existing tests pass.
  • This change has been tested on [specify backend/DB versions].

Test Plan:

Checklist

  • My code follows the project's code style guidelines.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation (Docstrings, README.md, etc.).
  • My changes generate no new warnings.
  • I have added a Changelog fragment (changelog.d/<issue_number>.<type>.md).
  • I have verified that my changes do not introduce SQL injection vulnerabilities.
  • I have checked for potential performance regressions.

Additional Notes

Commits in this PR:

  • a7639ba feat(postgres): add constraint DDL support with EXCLUDE and NOT VALID
  • 0ea068e feat(backend): add PostgreSQL constraint support protocol

vistart and others added 2 commits April 11, 2026 14:55
Add PostgreSQL-specific constraint DDL formatting directly in
PostgresDialect (not via mixin override, due to Python C3 MRO
placing SQLDialectBase before mixins):

- EXCLUDE constraint support with USING, elements, WHERE, DEFERRABLE
- NOT VALID suffix for skipping validation of existing rows
- format_add_table_constraint_action overrides base class for PG extensions
- PostgresConstraintMixin retained as organizational placeholder

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add PostgresConstraintSupport protocol for PostgreSQL-proprietary
  constraint features (NOT VALID, EXCLUDE constraints)
- Implement supports_constraint_enforced() returning False
  (PostgreSQL uses NOT VALID instead of ENFORCED/NOT ENFORCED)
- Add supports_constraint_novalidate() and supports_exclude_constraint()
  to PostgresConstraintMixin
@vistart vistart self-assigned this Apr 11, 2026
@codecov

codecov Bot commented Apr 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 22.05882% with 53 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.51%. Comparing base (91f82bd) to head (e99e306).
⚠️ Report is 1 commits behind head on release/v1.0.0.dev10.

Files with missing lines Patch % Lines
...cial/activerecord/backend/impl/postgres/dialect.py 5.76% 49 Missing ⚠️
...ord/backend/impl/postgres/mixins/ddl/constraint.py 60.00% 2 Missing ⚠️
.../backend/impl/postgres/protocols/ddl/constraint.py 71.42% 2 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##           release/v1.0.0.dev10      #27      +/-   ##
========================================================
- Coverage                 72.98%   72.51%   -0.48%     
========================================================
  Files                       126      128       +2     
  Lines                      7193     7261      +68     
  Branches                   1178     1194      +16     
========================================================
+ Hits                       5250     5265      +15     
- Misses                     1512     1565      +53     
  Partials                    431      431              
Flag Coverage Δ
postgres-18 72.51% <22.05%> (-0.48%) ⬇️
python-3.14 72.51% <22.05%> (-0.48%) ⬇️
unittests 72.51% <22.05%> (-0.48%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

@vistart
vistart merged commit ce1dae4 into release/v1.0.0.dev10 Apr 11, 2026
12 of 14 checks passed
@vistart vistart mentioned this pull request Apr 12, 2026
4 of 12 tasks
vistart added a commit that referenced this pull request Apr 12, 2026
* feat(postgres): add constraint DDL support with EXCLUDE and NOT VALID

Add PostgreSQL-specific constraint DDL formatting directly in
PostgresDialect (not via mixin override, due to Python C3 MRO
placing SQLDialectBase before mixins):

- EXCLUDE constraint support with USING, elements, WHERE, DEFERRABLE
- NOT VALID suffix for skipping validation of existing rows
- format_add_table_constraint_action overrides base class for PG extensions
- PostgresConstraintMixin retained as organizational placeholder

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat(backend): add PostgreSQL constraint support protocol

- Add PostgresConstraintSupport protocol for PostgreSQL-proprietary
  constraint features (NOT VALID, EXCLUDE constraints)
- Implement supports_constraint_enforced() returning False
  (PostgreSQL uses NOT VALID instead of ENFORCED/NOT ENFORCED)
- Add supports_constraint_novalidate() and supports_exclude_constraint()
  to PostgresConstraintMixin

* chore: add changelog fragment for PR #27

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@vistart
vistart deleted the feature/ddl-constraint-expressions branch May 30, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant