SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
FR: Exclusion constraints

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
FR: Exclusion constraints
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post FR: Exclusion constraints Reply with quote
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
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 View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Reply with quote
SysOp wrote:
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!

SysOp wrote:
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:
Code:

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:
Code:

---- 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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
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 View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
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


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.