Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Multiple DUAL_UNIQUE generate conflicting statements
Multiple DUAL_UNIQUE generate conflicting statements [message #49869] Wed, 23 May 2018 11:36 Go to next message
busiek is currently offline  busiek
Messages: 43
Registered: February 2011
Location: Poland
Member
This is a problem for PostgreSQL backend for sure.
TABLE(T)
    ...
    DUAL_UNIQUE(A, B)
    DUAL_UNIQUE(C, D)
END_TABLE

will generate A_script.sql containing:
...
alter table T add constraint DQ_T unique (A, B);
alter table T add constraint DQ_T unique (C, D);

Constraint names should be unique. The way to fix it is to add column names to the constraint name separated by some special symbol.
Re: Multiple DUAL_UNIQUE generate conflicting statements [message #50047 is a reply to message #49869] Wed, 27 June 2018 10:35 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12096
Registered: November 2005
Ultimate Member
What about using UNIQUE_LIST instead?
Re: Multiple DUAL_UNIQUE generate conflicting statements [message #50048 is a reply to message #49869] Wed, 27 June 2018 15:50 Go to previous messageGo to next message
busiek is currently offline  busiek
Messages: 43
Registered: February 2011
Location: Poland
Member
Thanks, in UNIQUE_LIST you can name a constraint. I wasn't aware of that. I will use it.

Until now, I simply run A_script.sql manually, by editing the name of conflicting constraint.
Re: Multiple DUAL_UNIQUE generate conflicting statements [message #52066 is a reply to message #50048] Sun, 14 July 2019 02:30 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 590
Registered: December 2005
Location: Budapest, Hungary
Contributor
Fix:
-#define DUAL_UNIQUE(k1, k2)        ATTRIBUTE("alter table @t add constraint DQ_@t unique "\
+#define DUAL_UNIQUE(k1, k2)        ATTRIBUTE("alter table @t add constraint DQ_@t$" #k1 #k2 " unique "\
                                              "(" #k1 ", " #k2 ");",\
-                                             "alter table @t drop constraint DQ_@t;")
+                                             "alter table @t drop constraint DQ_@t$" #k1 #k2 ";")

Re: Multiple DUAL_UNIQUE generate conflicting statements [message #52084 is a reply to message #52066] Wed, 17 July 2019 10:42 Go to previous message
mirek is currently offline  mirek
Messages: 12096
Registered: November 2005
Ultimate Member
Thanks, applied, with a small addition:

#define DUAL_UNIQUE(k1, k2)        ATTRIBUTE("alter table @t add constraint DQ_@t$" #k1 "$" #k2 " unique "\
                                             "(" #k1 ", " #k2 ");",\
                                             "alter table @t drop constraint DQ_@t$" #k1 "$" #k2 ";")
Previous Topic: SQLite On delete cascade .sch ?
Next Topic: BOOL in SQLite
Goto Forum:
  


Current Time: Wed Nov 13 01:42:19 CET 2019

Total time taken to generate the page: 0.03732 seconds