In postgresql, ExpressionWrapper and DurationField does not work.

39 views
Skip to first unread message

김정진

unread,
Jan 17, 2021, 9:39:15 PM1/17/21
to Django users
Hi.

I used mariadb and have migrated into postgresql 12 now.
One of source code generates an error on postgresql.

... Q(active_at__lt=now()- ExpressionWrapper(F('configuration__interval') * 1.5 * 1000000 * 60, output_field=DurationField()))) ...

is compile as : str(queryset.query)

"active_at" IS NULL OR "device"."active_at" < ((2021-01-18 02:06:57.738175+00:00 - ((("confirugation"."interval" * 1.5) * ....

And in postgres error log :
U0."active_at" < (('2021-01-18T02:24:04.962734+00:00'::timestamptz - (((U1."wakeup_interval" * 1.5) * 1000000) * 60)))))))

"Interval" keyword is missed in front of (((U1."wakeup_interval".... .

Python 3.7.9, django 2.2.14, psycopg2 2.8.6.

How can I this ORM make use to 'interval' keyword?

Thanks.
Reply all
Reply to author
Forward
0 new messages