> On 9 May 2018, at 08:33, Lukas Eder <
lukas...@gmail.com> wrote:
>
> ... But before you move on, please make sure you properly understand PostgreSQL's implementation of TIMESTAMP WITH TIME ZONE. In 10 years of doing jOOQ, I've never encountered anyone (ab)using domains to patch time zones on their data types. It feels like the wrong approach. I'm sure PostgreSQL gets this right.
Many thanks for taking the time share this wisdom, which goes beyond the scope of JOOQ - very much appreciated.
For note, in my own (potentially deluded) mind, the objective of the domain was to specialize the built in TIMESTAMP WITH TIME ZONE type to make it impossible to insert a non-UTC timestamp into the database, either from an application or from a proc.
In my mind, this use of this domain is a way of re-using a check constraint across the entire schema. This check constraint applies to all columns of the domain type. I’ve also created a custom range type to extend from this domain, which inherits the check.
I am not asserting that the Postgres TIMESTAMP WITH TIME ZONE gets anything wrong. I am just observing that this data type allows clients to insert timestamps with arbitrary zone offsets. This is the behavior I want to prevent.
Note that I am ignorant of how Postgres would store this under the covers - for all I know Postgres could be storing the timestamp in UTC in addition to the offset.
So I will take your advice and seek clarification from the Postgres mailing list before moving on.
> And once you don't use domains, everything will be much easier on the jOOQ side as well.
Point taken.