Opened 7 weeks ago
Last modified 6 weeks ago
#36078 assigned Cleanup/optimization
Postgres date and time range fields change after saving object — at Version 1
Reported by: | Mapiarz | Owned by: | |
---|---|---|---|
Component: | contrib.postgres | Version: | 4.2 |
Severity: | Normal | Keywords: | postgres |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Pull Requests: | 19056 build:success | ||
Description (last modified by ) ¶
This short test exemplifies the problem:
now = timezone.now() empty_range = psycopg2_range.DateTimeTZRange(empty=True) test_model = TestModel(range=psycopg2_range.DateTimeTZRange(now, now)) self.assertFalse(test_model.range.isempty) self.assertNotEqual(test_model.range, empty_range) test_model.save() test_model.refresh_from_db() self.assertTrue(test_model.range.isempty) self.assertEqual(test_model.range, empty_range)
I would expect the field value not to change after saving, and it should continue to have the lower, upper and boundary fields set.
Repro project: https://github.com/Mapiarz/django_postgres_range_repro/tree/master
The example is for DateTimeRange, but DateRange Is also affected. Other ranges possibly too, I haven't tested.
According to the ticket's flags, the next step(s) to move this issue forward are:
- For anyone except the patch author to review the patch using the patch review checklist and either mark the ticket as "Ready for checkin" if everything looks good, or leave comments for improvement and mark the ticket as "Patch needs improvement".
Note:
See TracTickets
for help on using tickets.