Skip to content

Use model names for default field projections - #2339

Merged
waketzheng merged 4 commits into
tortoise:developfrom
IlyaKhalafi:fix/default-source-field-projections
Oct 23, 2026
Merged

waketzheng merged 4 commits into
tortoise:developfrom
IlyaKhalafi:fix/default-source-field-projections

Conversation

@IlyaKhalafi

Copy link
Copy Markdown
Contributor

Description

This PR fixes dict(model) and default values_list() for fields with source_field. With this, renamed fields keep their model names and no longer cause missing tuples or attribute errors.

Fixes #2337

Motivation and Context

These defaults iterate model attributes, so they need projection keys rather than database column names. Explicit field selections keep their existing behavior. The related refresh_from_db fix is covered by #2335.

How Has This Been Tested?

The 17 new tests include eight failures on the original code and nine passing controls. The full SQLite suite passes with 1991 passed, 149 skipped and two expected failures. make check passes. All 17 new cases pass on PostgreSQL 18 with both asyncpg and psycopg. MySQL and MSSQL were not run locally.

Checklist

  • My code follows the project style
  • I have read the contribution guide
  • I have added regression tests
  • I have added a changelog entry
  • All new and existing SQLite tests passed

@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/default-source-field-projections (b077aa4) with develop (925c2c6)

Open in CodSpeed

@waketzheng
waketzheng merged commit abc91d7 into tortoise:develop Oct 23, 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.

Renamed fields break dict(model) and default values_list

2 participants