Skip to content

fix(tests): drop removed subtransactions= kwarg from Session.begin() - #42866

Open
rusackas wants to merge 1 commit into
masterfrom
fix/session-begin-subtransactions-removed
Open

fix(tests): drop removed subtransactions= kwarg from Session.begin()#42866
rusackas wants to merge 1 commit into
masterfrom
fix/session-begin-subtransactions-removed

Conversation

@rusackas

@rusackas rusackas commented Aug 6, 2026

Copy link
Copy Markdown
Member

SUMMARY

TestDatasource.setUp (tests/integration_tests/datasource_tests.py) explicitly opened a transaction with db.session.begin(subtransactions=True) before each test, relying on tearDown's rollback() to isolate them.

subtransactions= was already deprecated in SQLAlchemy 1.4 and is removed outright in 2.0 (TypeError: scoped_session.begin() got an unexpected keyword argument 'subtransactions'). It surfaced while investigating discussion #40273's SQLAlchemy 2.0 bump, but it's a standalone fix independent of that work — Session autobegins on first use under both 1.4 and 2.0, so the explicit begin() call is unnecessary either way, and tearDown's rollback() still correctly discards whatever the test did without it.

TESTING INSTRUCTIONS

Ran the full file locally against sqlite (with Redis up for the two cache-dependent tests):

pytest tests/integration_tests/datasource_tests.py -v
# 31 passed

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

TestDatasource.setUp explicitly opened a transaction with
db.session.begin(subtransactions=True) before each test, relying on
tearDown's rollback() to isolate them. subtransactions was already
deprecated in SQLAlchemy 1.4 and is removed outright in 2.0
(TypeError: unexpected keyword argument 'subtransactions'), surfacing
as a failure while investigating discussion #40273's SQLAlchemy 2.0
bump.

The explicit begin() is unnecessary either way: Session autobegins on
first use under both 1.4 and 2.0, so tearDown's rollback() still
correctly discards whatever the test did without it.
@bito-code-review

bito-code-review Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #1fb897

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 9db868f..9db868f
    • tests/integration_tests/datasource_tests.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

@rusackas
rusackas requested review from sadpandajoe and villebro and a lite review from Copilot August 6, 2026 22:04
@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 9db868f
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a7504be8a29730008c04eed
😎 Deploy Preview https://deploy-preview-42866--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Removes an explicit SQLAlchemy transaction begin in TestDatasource.setUp that relies on the removed subtransactions= kwarg, keeping test isolation via tearDown() rollback.

Changes:

  • Drops db.session.begin(subtransactions=True) from TestDatasource setup to avoid SQLAlchemy 2.0 TypeError.
  • Continues to rely on db.session.rollback() in tearDown() for per-test isolation.

rusackas pushed a commit that referenced this pull request Aug 6, 2026
SQLAlchemy 2.0 removed the subtransactions= parameter from
Session.begin(); TestDatasource.setUp() called it unconditionally,
failing every test in the class with "TypeError: scoped_session.begin()
got an unexpected keyword argument 'subtransactions'" before the test
body ever ran.

Same fix as #42866 (open at the time of this commit,
not yet merged to master despite this branch already having merged
master's tip) - applying it directly here since it's blocking all
further local verification of tests/integration_tests/datasource_tests.py
and is independent of the rest of this branch's SQLAlchemy 2.0 work.
Once #42866 merges to master, a future master-merge into this branch
will no-op on this file.

Verified locally (sqlite): all 31 tests in datasource_tests.py pass.
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.

3 participants