Skip to content

Conversation

@jmsmkn
Copy link
Contributor

@jmsmkn jmsmkn commented Nov 17, 2025

Close #228

@jmsmkn
Copy link
Contributor Author

jmsmkn commented Nov 17, 2025

There are existing tests already to ensure that the migrations are carried out for objects with pictures and that nothing is done for objects without pictures, this PR is just making that 2nd step more direct.

Copy link
Owner

@codingjoe codingjoe left a comment

Choose a reason for hiding this comment

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

Nice! But just to be safe, be so kind and add a test case to prevent regression in future versions.

@codingjoe codingjoe added the bug Something isn't working label Nov 28, 2025
@codecov
Copy link

codecov bot commented Nov 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (32289a5) to head (8528f53).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #230   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines          495       495           
=========================================
  Hits           495       495           
Flag Coverage Δ
celery 85.05% <0.00%> (ø)
cleanup 88.48% <100.00%> (ø)
dj4.2 88.48% <100.00%> (ø)
dj5.1 88.48% <100.00%> (ø)
django-rq 85.05% <0.00%> (ø)
dramatiq 85.05% <0.00%> (ø)
drf 96.36% <100.00%> (ø)
macos-latest 88.68% <100.00%> (ø)
py3.10 88.48% <100.00%> (ø)
py3.11 88.48% <100.00%> (ø)
py3.12 88.48% <100.00%> (ø)
py3.13 88.48% <100.00%> (ø)
py3.14 88.48% <100.00%> (ø)
ubuntu-latest 88.48% <100.00%> (ø)
windows-latest 81.58% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codingjoe codingjoe changed the title Skip operations for objects with no pictures to migrate Fix #228 -- Skip migration for objects without files Nov 28, 2025
Copy link
Owner

@codingjoe codingjoe left a comment

Choose a reason for hiding this comment

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

I took the liberty of adding them :)

@codingjoe codingjoe added enhancement New feature or request and removed bug Something isn't working labels Nov 28, 2025
@codingjoe codingjoe requested a review from Copilot November 28, 2025 16:11
Copilot finished reviewing on behalf of codingjoe November 28, 2025 16:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #228 by adding logic to skip database objects that have empty or null file fields during migrations. This prevents errors when the migration code attempts to process file operations on non-existent files.

  • Added filtering to exclude objects with empty ("") or None values in the picture field before processing
  • Applied the fix consistently across all three migration methods
  • Added comprehensive test coverage for each migration method to verify the fix

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pictures/migrations.py Added .exclude(Q(**{self.name: ""}) | Q(**{self.name: None})) filtering to update_pictures, from_picture_field, and to_picture_field methods to skip objects without files
tests/test_migrations.py Added three new test methods (test_update_pictures__with_empty_pictures, test_from_picture_field__with_empty_pictures, test_to_picture_field__with_empty_pictures) to verify that migrations correctly handle mixed scenarios with both populated and empty picture fields

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@codingjoe codingjoe merged commit e9b6583 into codingjoe:main Nov 28, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

from_picture_field and to_picture_field iterate over all objects

2 participants