Skip to content

refactor: migrate session.query to select API in small task files batch - #34684

Merged
asukaminato0721 merged 2 commits into
langgenius:mainfrom
ai-mountain:refactor/sqlalchemy-select-tasks-small-batch1
Apr 7, 2026
Merged

asukaminato0721 merged 2 commits into
langgenius:mainfrom
ai-mountain:refactor/sqlalchemy-select-tasks-small-batch1

Conversation

@ai-mountain

Copy link
Copy Markdown
Contributor

Summary

  • Migrate session.query() to SQLAlchemy 2.0 select() API in 3 small task files
  • tasks/delete_account_task.py: .query(Account).where(...).first() → session.scalar(select(...).limit(1))
  • tasks/batch_create_segment_to_index_task.py: session.query(func.max(...)).scalar() → session.scalar(select(func.max(...))...)
  • tasks/duplicate_document_indexing_task.py: .query(Dataset).where(...).first() → session.scalar(select(...).limit(1))

Test plan

  • Unit tests updated for delete_account_task (mock updated from .query().where().first() to .scalar())
  • All 15 unit tests pass locally

Part of #22668

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. refactor labels Apr 7, 2026
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Diff

No changes detected.

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Diff

No changes detected.

@asukaminato0721
asukaminato0721 added this pull request to the merge queue Apr 7, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 7, 2026
Merged via the queue into langgenius:main with commit cb55176 Apr 7, 2026
26 of 27 checks passed
@ai-mountain
ai-mountain deleted the refactor/sqlalchemy-select-tasks-small-batch1 branch April 7, 2026 23:18
HanqingZ pushed a commit to HanqingZ/dify that referenced this pull request Apr 23, 2026
…ch (langgenius#34684)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Ssazurov pushed a commit to Ssazurov/dify that referenced this pull request Aug 8, 2026
…ch (langgenius#34684)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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 refactor size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants