caribou / caribou-core

Core functionality for Caribou
44 stars 3 forks source link

Disjoint constraint on part association results in invalid sql statement #38

Open fpoms opened 10 years ago

fpoms commented 10 years ago

The disjoint constraint assumes that the name of the column is the name of the field. However, for the part association, the field name is appended with "_id" to create the field name.

Example:

(model/create :model
              {:name "Citizen"
               :fields [{:name "Motherland" :type "part"
                         :target-id (caribou.model/models :nation :id)
                         :reciprocal-name "Citizens"
                         :disjoint true}]})

Bad sql:

DEBUG :db alter table citizen add constraint citizen_motherland_unique unique (motherland)

Proper sql:

DEBUG :db alter table citizen add constraint citizen_motherland_unique unique (motherland_id)