| 64 | |
| 65 | When the view is changed to have a coalesce, the coalesce value appears in the ORM. |
| 66 | {{{ |
| 67 | blxa=> create view blxadmin_nextschedule as select row_number() over (order by scheduled) as id, scheduled, exact_schedule_id, coalesce(v.id, 0) as negative_schedule_id from (select '2022-03-21'::date + '01:00:00'::time as scheduled, 1 as exact_schedule_id) as u left join blxadmin_negativeschedule as v on (u.scheduled between v.from_datetime and v.to_datetime) order by scheduled asc; |
| 68 | CREATE VIEW |
| 69 | blxa=> select * from blxadmin_nextschedule ; |
| 70 | id | scheduled | exact_schedule_id | negative_schedule_id |
| 71 | ----+---------------------+-------------------+---------------------- |
| 72 | 1 | 2022-03-21 01:00:00 | 1 | 1 |
| 73 | (1 row) |
| 74 | }}} |
| 75 | |
| 76 | {{{ |
| 77 | >>> NextSchedule.objects.all()[0].scheduled, NextSchedule.objects.all()[0].exact_schedule_id, NextSchedule.objects.get(id=1).negative_schedule_id |
| 78 | (datetime.datetime(2022, 3, 21, 1, 0), 1, 0) |
| 79 | }}} |