pgschema
pgschema copied to clipboard
Invalid statement ordering with CREATE DOMAIN CHECK constraints with function references
Absolutely loving pgschema, thank you!
I'm using typeid to provide type safe ID's all the way down to the database. Unfortunately pgschema doesn't seem to correctly order statements when a function is referenced in a CREATE DOMAIN CHECK constraint. To use typeid you create a new domain like so:
CREATE DOMAIN user_id AS typeid CHECK (typeid_check(value, 'user'));
CREATE TABLE example (
id user_id NOT NULL PRIMARY KEY
);
However, as can be seen in this example run, both the CREATE DOMAIN and CREATE TABLE are reordered before the required function is defined, as can be seen in the ordering of the original SQL.
Mmm there does seem to be another ordering bug in there as well. If you remove the CREATE DOMAIN and CREATE TABLE you get the following error:
Error: failed to execute concatenated statements in group 1: ERROR: function typeid_parse(character varying) does not exist (SQLSTATE 42883)