Skip to content

Drop dead select_related from the importer's foreign-key query - #988

Merged
ajslater merged 1 commit into
developfrom
claude/sweet-bose-ab6970
Oct 20, 2026
Merged

ajslater merged 1 commit into
developfrom
claude/sweet-bose-ab6970

Conversation

@ajslater

Copy link
Copy Markdown
Owner

Summary

Every importer test emitted RemovedInDjango2028Warning: Calling select_related() with no arguments is deprecated from codex/librarian/scribe/importer/query/foreign_keys.py:45.

QueryForeignKeysQueryImporter.query_existing_mds called select_related(*MODEL_SELECT_RELATED.get(model, ())). For a model with no entry, that becomes a bare select_related(). The call also did nothing: values_list() ends in Query.set_values(), which sets select_related = False. The joins come from the __name lookups in the values_list fields.

  • Remove the select_related call in query_existing_mds.
  • Remove the now-unused MODEL_SELECT_RELATED and _IDENTIFIED_SELECT_RELATED from importer/const.py.

This is internal cleanup with no user-visible change, so there's no NEWS entry.

Verification

  • The generated SQL is byte-identical with and without the old select_related args for every model that had an entry (Publisher, Imprint, Series, Volume, Credit, Identifier).
  • pytest tests/importer -W error::django.utils.deprecation.RemovedInDjango2028Warning: 86 passed.
  • make fix (no extra changes), make lint, make ty: clean.
  • make test: 1712 passed, 1 xfailed (pytest); 1033 passed (vitest). The warnings summary has no RemovedInDjango entries and none under codex/.

🤖 Generated with Claude Code

QueryForeignKeysQueryImporter.query_existing_mds called
select_related(*MODEL_SELECT_RELATED.get(model, ())). For models with no
entry that is select_related() with no arguments, which Django 6
deprecates, so every importer test emitted RemovedInDjango2028Warning.

The call never did anything: values_list() ends in Query.set_values(),
which sets select_related = False. The joins come from the __name
lookups in the values_list fields, so the SQL is unchanged. Remove the
call and the now-unused MODEL_SELECT_RELATED and
_IDENTIFIED_SELECT_RELATED constants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ajslater
ajslater merged commit e07387b into develop Oct 20, 2026
9 checks passed
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.

1 participant