Skip to content

Fixed #36892 -- Handled lazy objects in serializer_factory#20613

Closed
Ahmedshammas wants to merge 4 commits intodjango:mainfrom
Ahmedshammas:fix-serialization-36892
Closed

Fixed #36892 -- Handled lazy objects in serializer_factory#20613
Ahmedshammas wants to merge 4 commits intodjango:mainfrom
Ahmedshammas:fix-serialization-36892

Conversation

@Ahmedshammas
Copy link
Copy Markdown

Trac ticket number

ticket-36892

Branch description

This patch ensures that django.utils.functional.lazy objects (such as lazy tuples used for field choices) are correctly unwrapped before serialization.

Previously, these objects were being serialized as strings, causing the migration autodetector to falsely identify changes and generate redundant migrations on every run. I have updated serializer_factory to use _proxy____cast() for Promise objects and added a regression test in tests/migrations/test_serializer.py.

AI Assistance Disclosure (REQUIRED)

  • [x ] No AI tools were used in preparing this PR.
  • If AI tools were used, I have disclosed which ones, and fully reviewed and verified their output.

Checklist

  • [x ] This PR follows the contribution guidelines.
  • [x ] This PR does not disclose a security vulnerability (see vulnerability reporting).
  • [ x] This PR targets the main branch.
  • [ x] The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • [ x] I have checked the "Has patch" ticket flag in the Trac system.
  • [ x] I have added or updated relevant tests.
  • [ x] I have added or updated relevant docs, including release notes if applicable.
  • [ x] I have attached screenshots in both light and dark modes for any UI changes.

@github-actions
Copy link
Copy Markdown

📊 Coverage Report for Changed Files

-------------
Diff Coverage
Diff: origin/main...HEAD, staged and unstaged changes
-------------
django/db/migrations/serializer.py (100%)
-------------
Total:   1 line
Missing: 0 lines
Coverage: 100%
-------------


Note: Missing lines are warnings only. Some lines may not be covered by SQLite tests as they are database-specific.

For more information about code coverage on pull requests, see the contributing documentation.

@jacobtylerwalls
Copy link
Copy Markdown
Member

Hi 👋

The PR contains unrelated changes, no tests, and doesn't follow the PR checklist for commit messages. Feel free to resubmit a PR when you have something closer to the target.

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.

3 participants