Snowflake-Labs / django-snowflake

MIT License
59 stars 15 forks source link

Add support for interval math with NULL #26

Open timgraham opened 2 years ago

timgraham commented 2 years ago

A queryset like:

Experiment.objects.annotate(shifted=ExpressionWrapper(
    F('completed') - Value(None, output_field=DurationField()),
    output_field=DateField(),
))

generates

SELECT ("experiment"."completed" - INTERVAL 'NULL MICROSECONDS') AS "shifted" FROM "experiment"

which fails with syntax error line 1 at position 0 unexpected 'NULL'.

On other databases, interval math with a null interval results in NULL. Perhaps this could be fixed in Snowflake.