Skip to content

Comments

fix: swev-id: django__django-14007 apply returning converters#554

Open
casey-brooks wants to merge 1 commit intodjango__django-14007from
work/django__django-14007-fix-returning-converters
Open

fix: swev-id: django__django-14007 apply returning converters#554
casey-brooks wants to merge 1 commit intodjango__django-14007from
work/django__django-14007-fix-returning-converters

Conversation

@casey-brooks
Copy link

Summary

  • add regression coverage to assert Field.from_db_value is applied to INSERT-returned primary keys, bulk results, and last_insert_id backends
  • ensure SQLInsertCompiler runs field/backend converters for returned rows/columns and adapts plain Fields via Col wrappers

Fixes #553

Reproduction

  1. Install test dependencies (e.g., via nix profile add nixpkgs#python311{,Packages.{asgiref,sqlparse,pytz,tzdata,flake8}}).
  2. Run:
    PYTHONPATH="$PWD:$PWD/tests:/nix/store/hcm7w4jsaxwwdvhvyld5z1y2wzj0hri6-python3.11-asgiref-3.9.1/lib/python3.11/site-packages:/nix/store/lc0y6krlvr0qsppynhrk7zqamw63fbi0-python3.11-sqlparse-0.5.3/lib/python3.11/site-packages:/nix/store/k3azcgrqbl88l2rpw69ygmj3n2kymmzq-python3.11-pytz-2025.2/lib/python3.11/site-packages:/nix/store/g5psb5hhzazxnsz465bfgiwmlhz9b1n7-python3.11-tzdata-2025.2/lib/python3.11/site-packages" \
    DJANGO_SETTINGS_MODULE=tests.test_sqlite \
    python3 tests/runtests.py queries.test_db_returning --parallel=1
  3. Observe the failure prior to this fix:
    FAIL: test_insert_uses_field_converters (queries.test_db_returning.ReturningLastInsertIdTests.test_insert_uses_field_converters)
    AssertionError: 1 is not an instance of <class 'queries.models.WrappedId'>
    

Testing

  • PYTHONPATH="$PWD:$PWD/tests:/nix/store/hcm7w4jsaxwwdvhvyld5z1y2wzj0hri6-python3.11-asgiref-3.9.1/lib/python3.11/site-packages:/nix/store/lc0y6krlvr0qsppynhrk7zqamw63fbi0-python3.11-sqlparse-0.5.3/lib/python3.11/site-packages:/nix/store/k3azcgrqbl88l2rpw69ygmj3n2kymmzq-python3.11-pytz-2025.2/lib/python3.11/site-packages:/nix/store/g5psb5hhzazxnsz465bfgiwmlhz9b1n7-python3.11-tzdata-2025.2/lib/python3.11/site-packages" DJANGO_SETTINGS_MODULE=tests.test_sqlite python3 tests/runtests.py queries.test_db_returning --parallel=1
  • flake8 django/db/models/sql/compiler.py tests/queries/test_db_returning.py tests/queries/models.py

@casey-brooks casey-brooks requested a review from a team January 13, 2026 21:40
@casey-brooks
Copy link
Author

Test & Lint Summary

  • PYTHONPATH="$PWD:$PWD/tests:/nix/store/hcm7w4jsaxwwdvhvyld5z1y2wzj0hri6-python3.11-asgiref-3.9.1/lib/python3.11/site-packages:/nix/store/lc0y6krlvr0qsppynhrk7zqamw63fbi0-python3.11-sqlparse-0.5.3/lib/python3.11-site-packages:/nix/store/k3azcgrqbl88l2rpw69ygmj3n2kymmzq-python3.11-pytz-2025.2/lib/python3.11/site-packages:/nix/store/g5psb5hhzazxnsz465bfgiwmlhz9b1n7-python3.11-tzdata-2025.2/lib/python3.11/site-packages" DJANGO_SETTINGS_MODULE=tests.test_sqlite python3 tests/runtests.py queries.test_db_returning --parallel=1 (7 tests, 6 skipped, 0 failures)
  • flake8 django/db/models/sql/compiler.py tests/queries/test_db_returning.py tests/queries/models.py (no issues)

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

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

Applying returning-field converters in SQLInsertCompiler now mirrors the SELECT path, and the new tests verify BigAutoField.from_db_value coverage for create/bulk/last_insert_id backends. Looks good.

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.

2 participants