Skip to content

refactor: set cascade_backrefs=False for SavedQuery#42212

Open
rusackas wants to merge 1 commit into
masterfrom
refactor/sqla2-cascade-savedquery
Open

refactor: set cascade_backrefs=False for SavedQuery#42212
rusackas wants to merge 1 commit into
masterfrom
refactor/sqla2-cascade-savedquery

Conversation

@rusackas

Copy link
Copy Markdown
Member

See #40273

SUMMARY

Enable errors for the "SavedQuery" object is being merged into a Session along the backref cascade path RemovedIn20Warning, and adopt the SQLAlchemy 2.0 behavior for both SavedQuery backrefs (User.saved_queries and Database.saved_queries).

Constructing SavedQuery(database=...) or SavedQuery(user=...) no longer implicitly merges the new object into the parent's session. All code paths that persist saved queries already call session.add() explicitly, so no call sites needed changes.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

$ SQLALCHEMY_WARN_20=1 TZ=UTC python3 -m pytest tests/unit_tests/

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

Enable the pytest error filter for the "'SavedQuery' object is being
merged into a Session along the backref cascade path" RemovedIn20Warning
and adopt the SQLAlchemy 2.0 behavior for both SavedQuery backrefs
(User.saved_queries and Database.saved_queries).

Constructing SavedQuery(database=...) or SavedQuery(user=...) no longer
implicitly merges the new object into the parent's session. All
persisting code paths already add saved queries explicitly.

See discussion #40273.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e52282

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: da88be6..da88be6
    • pytest.ini
    • superset/models/sql_lab.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.19%. Comparing base (42a2aed) to head (da88be6).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42212      +/-   ##
==========================================
- Coverage   65.19%   65.19%   -0.01%     
==========================================
  Files        2768     2768              
  Lines      156081   156081              
  Branches    35719    35719              
==========================================
- Hits       101754   101751       -3     
- Misses      52365    52367       +2     
- Partials     1962     1963       +1     
Flag Coverage Δ
hive 38.61% <ø> (ø)
mysql 57.86% <ø> (ø)
postgres 57.92% <ø> (-0.01%) ⬇️
presto 40.55% <ø> (ø)
python 59.32% <ø> (-0.01%) ⬇️
sqlite 57.54% <ø> (ø)
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant