 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
FR: Exclusion constraints |
|
Postgres has these nice little exclusion constraints. While fetching the code for a table also retrieves those as well, but they are not shown in the Database Explorer tree the same way eg. unique constraints are shown in Keys or like Checks have their own folder. The only thing that hints at their existence is the appearance of the index that makes them possible. Could you make those constraints "visible" somehow?
|
|
Tue Aug 15, 2023 5:23 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
We currently support showing check constraints in checks folder if they are defined, and all primary and unique keys in Keys folder. I guess we can add Exclusions too, requires some effort.
You can find exclusion constraints in the Table Properties dialog, there is a separate tab for them.
|
|
Tue Aug 15, 2023 9:52 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
 |
 |
We currently support showing check constraints in checks folder if they are defined, and all primary and unique keys in Keys folder. I guess we can add Exclusions too, requires some effort. |
That would be great, thanks!
 |
 |
You can find exclusion constraints in the Table Properties dialog, there is a separate tab for them. |
Er... Yes, having to open the Table Properties was the effort I'd wanted to save. But now that I think about it, having to expand the Tables and Constraints or the Exclusions folders (in case that will be implemented) won't be that much faster either...
EDIT:
Hmm, I checked the details of the Exclusion Constraints again, and it does not seem to be complete. This was the statement that created the constraint:
 |
 |
ALTER TABLE "tm"."employee"
ADD CONSTRAINT "excl_employee$personnel_id_validity"
EXCLUDE USING gist("personnel_id" WITH =, tsrange("valid_from", "valid_to", '[)') WITH &&);
|
and this is the code the Script button produces for the constraint created with the above:
 |
 |
---- Exclude Constraints ----
ALTER TABLE "tm"."employee"
DROP CONSTRAINT "excl_employee$personnel_id_validity";
ALTER TABLE "tm"."employee"
ADD CONSTRAINT "excl_employee$personnel_id_validity" EXCLUDE USING gist(
"personnel_id" ASC NULLS LAST WITH =
);
|
Not exactly the same.
|
|
Wed Aug 16, 2023 5:03 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
You're correct, unfortunately this is a bug or rather a current limitation. The Properties dialog cannot correctly load function based exclusion constraints using tsrange( ) function and operators, it can handle simpler cases only. I submitted a report asking to enhance it to provide support for more complex cases of exclusion constraints.
One of possible workarounds is using Show DDL menu for the object, which should output correct script for the entire table including exclusion constraints.
|
|
Wed Aug 16, 2023 11:47 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|