Skip to content

test(feature-mixins): assert the stale-record exception contract - #27

Merged
vistart merged 2 commits into
release/v1.0.0.dev17from
feature/stale-record-error
Nov 9, 2026
Merged

vistart merged 2 commits into
release/v1.0.0.dev17from
feature/stale-record-error

Conversation

@vistart

@vistart vistart commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds the shared contract for the optimistic-lock stale-record exception, so every backend can assert the same behavior.

  • The existing optimistic-lock contract now expects StaleRecordError instead of a bare DatabaseError.
  • Asserts the concrete exception carries model, primary_key, expected_version and operation.
  • Adds a contract that StaleRecordError remains catchable through DatabaseError, so existing handlers keep working.
  • Adds a contract that a plain integrity failure stays IntegrityError and is not a StaleRecordError.
  • Covers sync and async paths, and updates the combined-mixin articles tests to the narrowed exception type.
  • Companion core PR: rhosocial/python-activerecord #131.

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

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 SQLite through the core test suite.

Test Plan:

pytest src/rhosocial/activerecord/testsuite/feature/mixins/test_optimistic_lock.py
pytest src/rhosocial/activerecord/testsuite/feature/mixins/test_optimistic_lock_async.py
pytest src/rhosocial/activerecord/testsuite/feature/mixins/test_combined_articles.py
pytest src/rhosocial/activerecord/testsuite/feature/mixins/test_combined_articles_async.py

The core workflow dispatched on feature/stale-record-error passed Python 3.8–3.15 including free-threaded variants.

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 8ac081a into release/v1.0.0.dev17 Nov 9, 2026
2 checks passed
@vistart
vistart deleted the feature/stale-record-error branch November 9, 2026 17:23
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