crane icon indicating copy to clipboard operation
crane copied to clipboard

Request: Multi-column constraints

Open wnortje opened this issue 10 years ago • 3 comments

Please add support for multi-column constraints such as

CONSTRAINT "constraint_name" UNIQUE ("col1" , "col2", "col3")

wnortje avatar Oct 07 '15 13:10 wnortje

What is the advantage of this over the present system, aside from terseness?

eudoxia0 avatar Nov 01 '15 21:11 eudoxia0

The constraint means the combination of the named columns must be unique. I.e. in each of the named columns there may be non-unique entries as long as the combination remains unique.

With the present system you can only specify the unique constraint on a single column at a time, which will not allow any duplicates in any of the named columns.

wnortje avatar Nov 02 '15 06:11 wnortje

I've thought about this.

I think the deftable form should have an extra section :constraints for specifying multi-column UNIQUE constraints and possibly other extensions.

eudoxia0 avatar Jan 07 '16 23:01 eudoxia0