Repository navigation
feat(postgres): add datetime interval expressions with EXPLAIN examples - #42
Merged
vistart merged 3 commits intoJun 5, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Cover temporal expression queries against indexed datetime filters while allowing PostgreSQL planner cost choices between eligible datetime indexes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/v1.0.0.dev15 #42 +/- ##
========================================================
+ Coverage 71.09% 71.13% +0.04%
========================================================
Files 232 232
Lines 10269 10284 +15
Branches 1617 1619 +2
========================================================
+ Hits 7301 7316 +15
Misses 2441 2441
Partials 527 527
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
7 of 12 tasks
vistart
added a commit
that referenced
this pull request
Jun 15, 2026
…es (#42) * feat(postgres): add datetime interval expression formatting Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * test(postgres): add datetime interval EXPLAIN examples Cover temporal expression queries against indexed datetime filters while allowing PostgreSQL planner cost choices between eligible datetime indexes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * chore: add changelog fragment for PR #42 --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Adds PostgreSQL dialect support for datetime interval expressions and EXPLAIN-backed index usage verification.
This PR covers:
EXTRACT/DATE_PART), datetime truncation (DATE_TRUNC), datetime add/subtract withINTERVAL, and datetime diff (DATE_PARTfor difference).backend.impl.postgres.functions.SELECTlist.SET enable_seqscan = offto verify index availability.Related to python-activerecord#99 (coordinated backend support for datetime interval feature).
Type of change
feat: A new featuretest: Adding missing tests or correcting existing tests (for the new feature)Breaking Change
Impact on End-Users:
No backward-incompatible changes are expected for typical end-user applications.
Impact on Backend Developers (Custom Implementations):
No existing formatter signatures were removed. Custom dialects can opt into the new temporal expression support by implementing the corresponding formatter methods.
Applicable
rhosocial-activerecordVersion Range:>=1.0.0.dev15,<2.0.0Related Repositories/Packages
Coordinated backend support has been added separately for:
Testing
Test Plan:
source .venv3.8/bin/activate pytest tests/rhosocial/activerecord_postgres_test/feature/backend/test_postgres_datetime_interval_explain_examples.py -v pytest tests/rhosocial/activerecord_postgres_test/feature/backend/postgres/test_postgres_datetime_interval_expressions.py -v pytest tests/rhosocial/activerecord_postgres_test/feature/backend/test_backend_explain.py -v deactivateResults:
4 passed— PostgreSQL datetime interval EXPLAIN examples46 passed— PostgreSQL datetime interval expression tests216 passed— PostgreSQL backend explain testsPostgreSQL test conclusions:
QueryExpression,Column,Literal,ComparisonPredicate,LogicalPredicate,OrderByClause, and temporal expression factories.EXPLAINresults confirm that indexed datetime predicates produce efficient plans usingidx_temporal_category_created,idx_temporal_created_at, oridx_temporal_started_endedindexes when the planner chooses to use them.SET enable_seqscan = offrather than forcing specific plan choices.extract,date_trunc,date_add,date_sub, anddate_diffin the SELECT list does not prevent thecategory + created_atindexed filter from being used.Checklist
README.md, etc.).changelog.d/<issue_number>.<type>.md).Additional Notes
The EXPLAIN example tests intentionally build verification queries through
QueryExpressionand predicate/expression objects rather than raw SQL strings, so they validate end-to-end expression semantics as well as backend-specific SQL generation.