refactor: set cascade_backrefs=False for Query#42210
Conversation
Enable the pytest error filter for the "'Query' object is being merged into a Session along the backref cascade path" RemovedIn20Warning and adopt the SQLAlchemy 2.0 behavior for the Database.queries backref. Constructing Query(database=...) no longer implicitly merges the new object into the Database's session. All persisting code paths already add queries to the session explicitly; the ephemeral Query built in SupersetSecurityManager.raise_for_access no longer needs an unconditional expunge, so it is now guarded the same way as Database.resolve_default_schema. See discussion #40273. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Code Review Agent Run #1a7d11Actionable Suggestions - 0Additional Suggestions - 2
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #42210 +/- ##
==========================================
- Coverage 65.19% 65.18% -0.01%
==========================================
Files 2767 2768 +1
Lines 156062 156082 +20
Branches 35717 35720 +3
==========================================
+ Hits 101741 101749 +8
- Misses 52361 52369 +8
- Partials 1960 1964 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
See #40273
SUMMARY
Enable errors for the
"Query" object is being merged into a Session along the backref cascade pathRemovedIn20Warning, and fix the code that relied on the reverse cascade.Database.queriesbackref now setscascade_backrefs=False, which is the SQLAlchemy 2.0 behavior: constructingQuery(database=...)no longer implicitly merges the new object into the Database's session. All code paths that persist queries already callsession.add()explicitly.SupersetSecurityManager.raise_for_accessbuilds an ephemeralQueryfor access checks and unconditionally expunged it from the session. Since the object is no longer implicitly merged, the expunge is now guarded, matching the existing pattern inDatabase.resolve_default_schema.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
🤖 Generated with Claude Code