Skip to content

feat(postgres): add expression-level COLLATE support - #40

Merged
vistart merged 5 commits into
release/v1.0.0.dev15from
feature/collation-expression
Jun 4, 2026
Merged

vistart merged 5 commits into
release/v1.0.0.dev15from
feature/collation-expression

Conversation

@vistart

@vistart vistart commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description

Adds PostgreSQL expression-level COLLATE support for SQL value expressions.

This introduces PostgreSQL collation name validation, integrates dialect-level collation formatting with the core CollateExpression hook, and adds backend-specific tests for plain, quoted, and schema-qualified collation names.

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 feature)
  • revert: Reverts a previous commit

Breaking Change

  • Yes
  • No

Applicable rhosocial-activerecord Version Range:
Compatible with the core version that provides expression-level CollateExpression dialect hooks.

Related Repositories/Packages

This PR depends on the corresponding core python-activerecord COLLATE support, merged in PR #97. Related backend plugin PRs should use the same CollateExpression-based validation contract.

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 PostgreSQL.

Test Plan:

  • Local full test suite was skipped during PR preparation by request.
  • CI is expected to run the full PostgreSQL matrix after PR creation.

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

PostgreSQL allows schema-qualified collation names. The validator accepts an optional schema collation option and quotes each identifier segment through the dialect identifier quoting path.

vistart and others added 4 commits June 4, 2026 12:34
Add PostgreSQL collation validation and dialect formatting so COLLATE
expressions remain schema-aware and safe for query composition.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Return the PostgreSQL collation SQL representation from validate_collation_name
so COLLATE formatting validates backend-specific names in one place.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Annotate validate_collation_name with CollationName so the PostgreSQL dialect
hook documents the structured collation argument it receives.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adapt COLLATE validation to consume the full CollateExpression while preserving PostgreSQL schema-qualified collation handling.

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

codecov Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.08%. Comparing base (bd2a129) to head (bd39475).

Files with missing lines Patch % Lines
...cial/activerecord/backend/impl/postgres/dialect.py 71.42% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##           release/v1.0.0.dev15      #40      +/-   ##
========================================================
+ Coverage                 71.03%   71.08%   +0.05%     
========================================================
  Files                       231      232       +1     
  Lines                     10240    10272      +32     
  Branches                   1617     1621       +4     
========================================================
+ Hits                       7274     7302      +28     
- Misses                     2439     2442       +3     
- Partials                    527      528       +1     
Flag Coverage Δ
postgres-18 71.08% <87.50%> (+0.05%) ⬆️
python-3.14 71.08% <87.50%> (+0.05%) ⬆️
unittests 71.08% <87.50%> (+0.05%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@vistart vistart self-assigned this Jun 4, 2026
@vistart vistart added the feature label Jun 4, 2026
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jun 4, 2026

Copy link
Copy Markdown

@vistart
vistart merged commit dc78743 into release/v1.0.0.dev15 Jun 4, 2026
15 checks passed
@vistart vistart mentioned this pull request Jun 15, 2026
7 of 12 tasks
vistart added a commit that referenced this pull request Jun 15, 2026
* feat(postgres): add expression-level COLLATE support

Add PostgreSQL collation validation and dialect formatting so COLLATE
expressions remain schema-aware and safe for query composition.

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

* refactor(postgres): validate COLLATE names via dialect hook

Return the PostgreSQL collation SQL representation from validate_collation_name
so COLLATE formatting validates backend-specific names in one place.

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

* style(postgres): type COLLATE validation hook parameter

Annotate validate_collation_name with CollationName so the PostgreSQL dialect
hook documents the structured collation argument it receives.

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

* refactor(postgres): accept collation expression in validation

Adapt COLLATE validation to consume the full CollateExpression while preserving PostgreSQL schema-qualified collation handling.

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

* chore: add changelog fragment for PR #40

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

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@vistart
vistart deleted the feature/collation-expression branch October 1, 2026 03:51
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