Closed xvaara closed 3 years ago
Another solution would be to parse the ISO8601 interval syntax if we can easily differentiate it. I believe I reimplemented the interval parser for performance reasons, so this should be feasible.
It seems that ISO8601 duration always starts with P, so that might be easy to check. I don't think it's possible for postgres interval/duration to start with a P.
I've decided to raise this as a documentation issue rather than a bug in PostGraphile. It'd be a lot of effort to support all the different styles of various datatypes that PostgreSQL supports, and since the workaround is easy (tell pgSettings
to set it back to the default value), I don't think it's worth spending time there.
Documentation updated here: https://github.com/graphile/graphile.github.io/commit/2005eae757daaad66350e3df4e78412ea368c6a1
It seems that ISO8601 duration always starts with P, so that might be easy to check. I don't think it's possible for postgres interval/duration to start with a P.
Doesn't it start with a P with intervalstyle = 'iso_8601'
?
Summary
Interval datatype doesn't work if intervalstyle = 'iso_8601', it returns 0 on every time element.
Possible Solution
so maybe issue a
SET intervalstyle = 'postgres';
on connection open if there are interval types in the schema? for fix the code to recognise at least the iso_8601 style. or note somewhere to run:ALTER DATABASE test SET intervalstyle = 'postgres';
or change postgresql.conf if it's global.