Skip to content

feat(dialect): require version adaptation before using Postgres dialect - #37

Merged
vistart merged 2 commits into
release/v1.0.0.dev14from
feature/dialect-version-guard
May 17, 2026
Merged

vistart merged 2 commits into
release/v1.0.0.dev14from
feature/dialect-version-guard

Conversation

@vistart

@vistart vistart commented May 17, 2026

Copy link
Copy Markdown
Contributor

Description

PostgresDialect now defaults to version=None, requiring introspect_and_adapt() or explicit version before version-dependent features can be used. This prevents silent SQL errors from incorrect version assumptions.

Problem: Backend dialects had default versions that could mismatch actual server capabilities, causing silent SQL errors when using features the server doesn't support.

Solution: Part of the dialect version guarding initiative across the rhosocial-activerecord ecosystem. Dialects now default to None version and throw DialectNotAdaptedException at use time.

Key Changes:

  • Change PostgresDialect.__init__ default version to None
  • Remove hardcoded (9, 6, 0) from backend dialect construction
  • Update tests to use explicit version (13, 0, 0)

Type of change

  • feat: A new feature
  • docs: Documentation only changes
  • perf: A code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • chore: Changes to the build process or auxiliary tools
  • ci: Changes to our CI configuration files and scripts
  • build: Changes that affect the build system or external dependencies
  • revert: Reverts a previous commit

Breaking Change

  • Yes
  • No

Impact on End-Users:
No backward-incompatible changes are expected for typical end-user applications. The context() and configure() methods continue to work as before, automatically calling introspect_and_adapt().

Impact on Backend Developers:
Custom backend implementations must ensure dialect version is set either:

  1. Explicitly via constructor: PostgresDialect(version=(X, Y, Z))
  2. Automatically via introspect_and_adapt() which sets the version from server detection

Applicable rhosocial-activerecord Version Range:

=1.0.0,<2.0.0

Related Repositories/Packages

  • python-activerecord: Core package with DialectNotAdaptedException and version guarding logic (PR #89)
  • python-activerecord-mysql: MySQL dialect version guarding changes

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

Test Plan:

  • Tests updated to use explicit version (13, 0, 0)
  • CI will verify all tests pass across Python versions

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.
  • My changes generate no new warnings.
  • I have added a Changelog fragment.
  • I have verified that my changes do not introduce SQL injection vulnerabilities.
  • I have checked for potential performance regressions.

Commits in this PR

  1. 965ea3e - feat(dialect): require version adaptation before using Postgres dialect

PostgresDialect now defaults to version=None, requiring
introspect_and_adapt() or explicit version before version-dependent
features can be used. This prevents silent SQL errors from incorrect
version assumptions.

- Change PostgresDialect.__init__ default version to None
- Remove hardcoded (9, 6, 0) from backend dialect construction
- Update tests to use explicit version (13, 0, 0)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vistart vistart self-assigned this May 17, 2026
@codecov

codecov Bot commented May 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.74%. Comparing base (9f117b5) to head (4389aa2).

Additional details and impacted files
@@                  Coverage Diff                  @@
##           release/v1.0.0.dev14      #37   +/-   ##
=====================================================
  Coverage                 68.74%   68.74%           
=====================================================
  Files                       230      230           
  Lines                     10058    10059    +1     
  Branches                   1599     1600    +1     
=====================================================
+ Hits                       6914     6915    +1     
  Misses                     2621     2621           
  Partials                    523      523           
Flag Coverage Δ
postgres-18 68.74% <100.00%> (+<0.01%) ⬆️
python-3.14 68.74% <100.00%> (+<0.01%) ⬆️
unittests 68.74% <100.00%> (+<0.01%) ⬆️

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 5b05ec7 into release/v1.0.0.dev14 May 17, 2026
14 checks passed
@vistart vistart mentioned this pull request May 29, 2026
vistart added a commit that referenced this pull request May 29, 2026
…ct (#37)

* feat(dialect): require version adaptation before using Postgres dialect

PostgresDialect now defaults to version=None, requiring
introspect_and_adapt() or explicit version before version-dependent
features can be used. This prevents silent SQL errors from incorrect
version assumptions.

- Change PostgresDialect.__init__ default version to None
- Remove hardcoded (9, 6, 0) from backend dialect construction
- Update tests to use explicit version (13, 0, 0)

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

* chore: add changelog fragment for PR #37

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@vistart
vistart deleted the feature/dialect-version-guard branch May 30, 2026 12:49
@vistart vistart mentioned this pull request Jun 15, 2026
7 of 12 tasks
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