Skip to content

test(feature-relation): contract HasMany order_by across access paths - #28

Merged
vistart merged 3 commits into
release/v1.0.0.dev17from
feature/ordered-has-many
Nov 9, 2026
Merged

vistart merged 3 commits into
release/v1.0.0.dev17from
feature/ordered-has-many

Conversation

@vistart

@vistart vistart commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds the shared sync/async contract for HasMany(..., order_by=...) and AsyncHasMany(..., order_by=...).

  • Covers direct relation access, {relation}_query(), chained where, top-level eager loading, nested eager loading, and relation cache.
  • Asserts the declared order comes first and a with_ modifier's ordering is appended as secondary ordering.
  • Covers primary-key tie-breakers for stable results, empty relations, and order_by=None preserving plain HasMany behavior.
  • Asserts unknown model fields and derived fields raise ValueError on the first query build.
  • Sync and async test classes share method names and the provider-backed User/Post/Comment fixtures.
  • Companion core PR: rhosocial/python-activerecord #133.

Adds: N/A (no tracking 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

(If Yes, please describe the impact and migration path below):

N/A

Applicable rhosocial-activerecord Version Range:

rhosocial-activerecord>=1.0.0.dev30,<2.0.0

Related Repositories/Packages

  • Core: rhosocial/python-activerecord branch feature/ordered-has-many adds the relation feature.
  • Backend repositories will add one-line wrapper tests importing these new modules after the core/testsuite batch merges; no backend implementation change is expected.

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:

pytest src/rhosocial/activerecord/testsuite/feature/relation/ordering/test_has_many_order_by.py
pytest src/rhosocial/activerecord/testsuite/feature/relation/ordering/test_has_many_order_by_async.py

The companion core PR installs this testsuite branch and runs the full core matrix.

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

This repository has no self-test workflow. The shared tests are validated by the companion core CI run. The changelog fragment is intentionally added after the PR number and CI result are known.

@vistart vistart added the enhancement New feature or request label Nov 9, 2026
@vistart vistart self-assigned this Nov 9, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@vistart
vistart merged commit 073dac1 into release/v1.0.0.dev17 Nov 9, 2026
2 checks passed
@vistart
vistart deleted the feature/ordered-has-many branch November 9, 2026 17:22
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