Repository navigation
Drop dead select_related from the importer's foreign-key query - #988
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every importer test emitted
RemovedInDjango2028Warning: Calling select_related() with no arguments is deprecatedfromcodex/librarian/scribe/importer/query/foreign_keys.py:45.QueryForeignKeysQueryImporter.query_existing_mdscalledselect_related(*MODEL_SELECT_RELATED.get(model, ())). For a model with no entry, that becomes a bareselect_related(). The call also did nothing:values_list()ends inQuery.set_values(), which setsselect_related = False. The joins come from the__namelookups in thevalues_listfields.select_relatedcall inquery_existing_mds.MODEL_SELECT_RELATEDand_IDENTIFIED_SELECT_RELATEDfromimporter/const.py.This is internal cleanup with no user-visible change, so there's no NEWS entry.
Verification
select_relatedargs 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 noRemovedInDjangoentries and none undercodex/.🤖 Generated with Claude Code