Skip to content

test(basic): contract read-only and keyless models - #30

Merged
vistart merged 3 commits into
release/v1.0.0.dev17from
feature/readonly-models
Nov 9, 2026
Merged

vistart merged 3 commits into
release/v1.0.0.dev17from
feature/readonly-models

Conversation

@vistart

@vistart vistart commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds the shared sync/async contracts for read-only models and keyless models, and covers their interaction with the newly merged find_one_or_create.

  • Read-only contract: ReadOnlyMixin declaration, the read_only() predicate, the value-based gate, every refused write path, ReadOnlyError type and fields, and reads that stay available.
  • Keyless contract: __primary_key__ = None, empty key columns/tuples, provenance-based is_new_record, and UnaddressableRecordError for identity-based access.
  • find_one_or_create interaction: an existing read-only row is returned without writing; a missing row reaches the same save gate and raises ReadOnlyError.
  • Sync and async classes share method names, and the contracts reuse the provider's existing users table without adding DDL.
  • Companion core PR: rhosocial/python-activerecord #135.

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/readonly-models adds ReadOnlyMixin, ReadOnlyError, keyless models and object declarations.
  • Backend repositories will add one-line wrapper tests importing the new testsuite basic/readonly and basic/nopk modules after the core/testsuite batch 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 [specify backend/DB versions].

Test Plan:

pytest src/rhosocial/activerecord/testsuite/feature/basic/readonly/test_readonly_models.py
pytest src/rhosocial/activerecord/testsuite/feature/basic/readonly/test_readonly_models_async.py
pytest src/rhosocial/activerecord/testsuite/feature/basic/nopk/test_keyless_models.py
pytest src/rhosocial/activerecord/testsuite/feature/basic/nopk/test_keyless_models_async.py

The find_one_or_create interaction tests also pass locally against SQLite. The companion core PR runs the full 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.

Add sync/async cross-backend contracts for ReadOnlyMixin, the value-based write gate, every refused write path, reads that stay available, __primary_key__ = None, and UnaddressableRecordError. The contracts reuse the provider's users table and add no DDL.
@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 d00c393 into release/v1.0.0.dev17 Nov 9, 2026
2 checks passed
@vistart
vistart deleted the feature/readonly-models 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