Skip to content

feat(postgres): render seconds_between as EXTRACT(EPOCH) - #65

Merged
vistart merged 6 commits into
release/v1.0.0.dev17from
feature/extract-epoch
Nov 8, 2026
Merged

vistart merged 6 commits into
release/v1.0.0.dev17from
feature/extract-epoch

Conversation

@vistart

@vistart vistart commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Description

Implements the backend half of the portable seconds_between expression added in
rhosocial/python-activerecord#129: format_seconds_between_expression() renders
end - start in signed, fractional seconds. Subtracting two PostgreSQL timestamps yields an interval, so the formatter wraps the difference in EXTRACT(EPOCH FROM (end - start)), which already carries the sign and the microseconds.

The core raises UnsupportedFeatureError until a dialect adapts the hook, so this
change is what makes the expression usable on this engine. The implementation lives in
src/rhosocial/activerecord/backend/impl/postgres/mixins/datetime.py.

Type of change

  • feat: A new feature
  • docs: Documentation for the new capability
  • test: Tests for the new capability
  • chore: CI installs the core from the feature branch (see below)
  • perf / ci / build / revert: not applicable

Breaking Change

  • Yes, for end-users (backward-incompatible API changes)
  • Yes, for backend developers (internal architectural changes that may affect custom implementations)
  • No breaking changes

Impact on End-Users:
No backward-incompatible changes are expected: the expression is new, and nothing
existing changes shape.

Impact on Backend Developers (Custom Implementations):
None. The dialect hook is additive; implementations that do not override it keep
inheriting the core refusal.

Related Repositories/Packages

Requires rhosocial/python-activerecord#129 (branch feature/extract-epoch).

.github/workflows/test.yml now installs the core from feature/extract-epoch
instead of release/v1.0.0.dev30, so CI exercises the core change and this backend
together (see the chore(ci) commit on this branch). That pin is temporary: it should
go back to the release branch once the core PR merges.

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 the target engine.

Test Plan:

  • tests/rhosocial/activerecord_postgres_test/feature/backend/postgres/test_postgres_seconds_between.py

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 (added in a follow-up commit, once the PR number is known).
  • I have verified that my changes do not introduce SQL injection vulnerabilities.
  • I have checked for potential performance regressions.

Additional Notes

The changelog fragment is intentionally deferred until the PR number exists; it is
added as changelog.d/<pr_number>.added.md right after the PR opens.

@codecov

codecov Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 77.90%. Comparing base (28b001e) to head (11025a7).

Files with missing lines Patch % Lines
...iverecord/backend/impl/postgres/mixins/datetime.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           release/v1.0.0.dev17      #65   +/-   ##
=====================================================
  Coverage                 77.90%   77.90%           
=====================================================
  Files                       355      355           
  Lines                     17504    17509    +5     
  Branches                   2805     2805           
=====================================================
+ Hits                      13636    13641    +5     
  Misses                     2870     2870           
  Partials                    998      998           
Flag Coverage Δ
postgres-18 77.90% <83.33%> (+<0.01%) ⬆️
python-3.14 77.90% <83.33%> (+<0.01%) ⬆️
unittests 77.90% <83.33%> (+<0.01%) ⬆️

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.

@sonarqubecloud

sonarqubecloud Bot commented Nov 8, 2026

Copy link
Copy Markdown

@vistart
vistart merged commit 33b3cf7 into release/v1.0.0.dev17 Nov 8, 2026
17 checks passed
@vistart vistart self-assigned this Nov 8, 2026
@vistart vistart added the enhancement New feature or request label Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant