feat(data): unified @transactional for relational + document (v26.06.75)#102
Merged
Conversation
…s + bump v26.06.75 ONE @transactional annotation (pyfly.data) for both backends — Spring's uniform-annotation model. Backend-neutral core (pyfly/data/transactional.py, no sqlalchemy/motor at module scope) dispatches at call time by what the service exposes: - self._session_factory -> run_relational_transaction (propagation/isolation/read-only/rollback_for, repo session-patching); - self._motor_client -> run_mongo_transaction (session injected as 'session' kwarg, commit/abort with rollback_for/no_rollback_for parity). Each backend supplies a lazily-imported runner (hexagonal). 'from pyfly.data.relational.sqlalchemy import transactional' still works (same object); mongo_transactional is now a deprecated alias. Tested: tests/data/test_unified_transactional.py (8) — relational commit/rollback/isolation-applied + document commit/abort/no_rollback_for-commit/session-injection/missing-client (the Mongo path was previously UNTESTED). Updated test_transactional.py's no-manager error match. Docs (data.md, data-document.md) + implement-data-repository skill teach the single annotation; fixed the doc's broken @mongo_transactional(client) example. Gates: mypy --strict (639), ruff + format, full suite 3993 passed.
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.
One
@transactionalannotation for every backend (Spring's uniform-annotation model), addressing the request to "just use @transactional, no adapter-specific annotations."@transactionalinpyfly.data(imports neither SQLAlchemy nor Motor at module scope). At call time it dispatches to the transaction manager the service exposes:self._session_factory(relational) → SQLAlchemy txn with propagation/isolation/read-only/rollback_for;self._motor_client(document) → Mongo session+txn, session injected as thesessionkwarg, withrollback_for/no_rollback_forparity.run_relational_transaction/run_mongo_transaction) — hexagonal.from pyfly.data.relational.sqlalchemy import transactionalis the same object;mongo_transactionalis a deprecated alias.Proper tests + no stubs (the other half of the ask): the MongoDB transaction path was completely untested — now covered (commit / abort on
rollback_for/ commit-and-re-raise onno_rollback_for/ session injection / missing-client error). Relational isolation is now verified (assertsisolation_levelreaches the session). No stubs found in the transactional/repository code (verified). Docs + theimplement-data-repositoryskill updated to teach the single annotation; the doc's broken@mongo_transactional(client)example fixed.Gates: mypy --strict (639), ruff+format, full suite 3993.