Skip to content

Preserve field iterators when refreshing models - #2342

Merged
waketzheng merged 4 commits into
tortoise:developfrom
IlyaKhalafi:fix/refresh-field-iterators
Oct 24, 2026
Merged

waketzheng merged 4 commits into
tortoise:developfrom
IlyaKhalafi:fix/refresh-field-iterators

Conversation

@IlyaKhalafi

Copy link
Copy Markdown
Contributor

Description

This PR fixes refresh_from_db silently keeping stale values when fields are passed as an iterator. With this, the same field names are used for the query and the refresh.

Empty field iterators now refresh all fields, matching empty lists.

Fixes #2341.

How Has This Been Tested?

Six regression cases fail on the original code. The focused tests pass, and the full SQLite suite has 2014 passed, 149 skipped and two expected failures. All 17 new cases also pass on PostgreSQL 18 with both asyncpg and psycopg. make check passes. MySQL and MSSQL were not run locally.

Checklist

  • My code follows the project style
  • I have read the contribution guide
  • I have updated the parameter documentation
  • I have added a changelog entry
  • I have added regression tests
  • The new tests and existing SQLite suite pass

@codspeed

codspeed Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 21 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 24 untouched benchmarks


Comparing IlyaKhalafi:fix/refresh-field-iterators (ea59c2d) with develop (15330b9)

Open in CodSpeed

@IlyaKhalafi
IlyaKhalafi force-pushed the fix/refresh-field-iterators branch from 5668935 to 57c215e Compare October 23, 2026 16:35
@waketzheng
waketzheng merged commit 7e52b39 into tortoise:develop Oct 24, 2026
25 checks passed
d3vyce pushed a commit to d3vyce/tortoise-orm that referenced this pull request Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refresh_from_db silently ignores fields supplied as an iterator

2 participants