Repository navigation
fix(db): tenant scoping for bulk, nested and value-subquery DML shapes - #817
Merged
Merged
Conversation
Tenant scoping now applies to: - ORM bulk UPDATE by primary key (execute(update(Model), rows)): each row gets WHERE tenant_id = <bound>; the session's own-tenant objects are synchronized as synchronize_session="evaluate" would; - update().ordered_values(): assigning tenant_id raises like .values(); - subqueries in an INSERT's values, multi-row values and on_conflict_do_update() set_/where, whatever the insert target (strict mode with no tenant raises); - UPDATE / DELETE embedded as a CTE in another statement; - UPDATE / DELETE on an aliased Core table; - a table read only through an UPDATE's SET values (UPDATE ... FROM). Refused outside all_tenants() (TenantIsolationError): an INSERT into a tenant table embedded as a CTE, SQLite INSERT OR REPLACE into a tenant table while a tenant is bound, and Session.bulk_save_objects / bulk_insert_mappings / bulk_update_mappings on a MultiTenantMixin model while a tenant is bound or strict mode is on. The predicate factories move from query_filter to scope_predicates. Claude-Session: https://claude.ai/code/session_01FXHA3ZicrtZ4C5QPEgxfgq
…per, share sqlite skip helper Claude-Session: https://claude.ai/code/session_01FXHA3ZicrtZ4C5QPEgxfgq
Deploying simple-module-python with
|
| Latest commit: |
9ecdebd
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://dc4130b1.simple-module-python.pages.dev |
| Branch Preview URL: | https://fix-db-review-dml-scope.simple-module-python.pages.dev |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Summary
simple_module_dbnow applies to more statement shapes:session.execute(update(Model), rows));update().ordered_values()assigningtenant_id(it now raises, like.values());RETURNINGandon_conflict_do_update()set_/where;add_cte();SET(UPDATE … FROM).TenantIsolationErrorunless run insideall_tenants():INSERT OR REPLACEinto a tenant table while a tenant is bound;Session.bulk_*methods onMultiTenantMixinmodels while a tenant is bound or strict mode is on.docs/framework/multi-tenancy.md,docs/database/mixins.md, the database skill and the CHANGELOG describe the covered and refused shapes.Verification
make lintpassed, along with these suites:make test-py: 7647 passedmake test-js: 891 passedmake doctor: cleanframework/db/testson a disposable Postgres database: 698 passed.Test plan
framework/db)framework/db/tests/test_db_{dml_target_scope,insert_value_subqueries,nested_dml_and_bulk_api}.pycover each shapehttps://claude.ai/code/session_01FXHA3ZicrtZ4C5QPEgxfgq