Skip to content

test: migrate test_remove_app_and_related_data_task to SQLAlchemy 2.0 select() API#34985

Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom
dataCenter430:refactor/sa2-integration-tests-remove-app-task
Apr 12, 2026
Merged

test: migrate test_remove_app_and_related_data_task to SQLAlchemy 2.0 select() API#34985
asukaminato0721 merged 1 commit intolanggenius:mainfrom
dataCenter430:refactor/sa2-integration-tests-remove-app-task

Conversation

@dataCenter430
Copy link
Copy Markdown
Contributor

Part of #22668

Summary

Migrates 25+ legacy session.query() calls in tests/integration_tests/tasks/test_remove_app_and_related_data_task.py. All occurrences are count assertions used to verify batch-deletion correctness:

  • session.query(WorkflowDraftVariable).filter_by(app_id=...).count()session.scalar(select(func.count()).select_from(WorkflowDraftVariable).filter_by(app_id=...))
  • session.query(WorkflowDraftVariableFile).where(...).count()session.scalar(select(func.count()).select_from(WorkflowDraftVariableFile).where(...))
  • session.query(UploadFile).where(...).count()session.scalar(select(func.count()).select_from(UploadFile).where(...))
  • session.query(WorkflowDraftVariable).where(id.in_(...)).count() → same pattern

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

No changes detected.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates legacy session.query(...).count() assertions in the integration test suite to SQLAlchemy 2.0 select()-style count queries, aligning tests with the project’s ongoing ORM API modernization (#22668).

Changes:

  • Replaced session.query(...).filter_by(...).count() with session.scalar(select(func.count()).select_from(...).filter_by(...)).
  • Replaced session.query(...).where(...).count() with session.scalar(select(func.count()).select_from(...).where(...)).
  • Added func/select imports needed for the new count queries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 12, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 12, 2026
Merged via the queue into langgenius:main with commit 7ba7086 Apr 12, 2026
31 of 32 checks passed
HanqingZ pushed a commit to HanqingZ/dify that referenced this pull request Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants