You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Model.objects.all() does not convert types in primary keys #147
I can confirm this is still an issue on current main — Model.objects.all() extracts path fields (like the primary key) from the filename as strings, and because those fields aren't stored in the file contents, they never pass through the field's converter in Mapper.load() (which deliberately excludes pattern fields).
I've opened #501 with a fix: all() now coerces the path-derived values to their declared types via the existing map_type() machinery before calling get(). I also removed the xfail marker on test_values_are_filled_from_disk, which now passes.
Verification: pytest tests/ is 128 passed / 1 skipped / 4 xfailed (remaining xfails are unrelated pre-existing issues), and mypy/black/isort/pylint/pydocstyle all pass. Happy to adjust if you'd prefer a different approach.
Activity
nielslerches commentedon Sep 19, 2022
Hi,
Is this issue still relevant?
If so, I'd like to take a crack at solving the issue, as I have a potential use case for this feature.
jacebrowning commentedon Sep 19, 2022
@nielslerches yes, it's still an issue. You can confirm that by removing the
xfailmarker to see the test fail.Let me know if you have any more questions!
jacebrowning#147 Convert types in primary key fields
Yuren0312 commentedon Oct 18, 2026
I can confirm this is still an issue on current
main—Model.objects.all()extracts path fields (like the primary key) from the filename as strings, and because those fields aren't stored in the file contents, they never pass through the field's converter inMapper.load()(which deliberately excludes pattern fields).I've opened #501 with a fix:
all()now coerces the path-derived values to their declared types via the existingmap_type()machinery before callingget(). I also removed thexfailmarker ontest_values_are_filled_from_disk, which now passes.Verification:
pytest tests/is 128 passed / 1 skipped / 4 xfailed (remaining xfails are unrelated pre-existing issues), andmypy/black/isort/pylint/pydocstyleall pass. Happy to adjust if you'd prefer a different approach.