You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
class Foo
property :num1, Integer, :unique => :scope_name
property :num2, Integer, :unique => :scope_name
belongs_to :bar, :unique => :scope_name
end
This example results into a perfectly working unique index "unique_foos_scope_name" with three fields ('num1', 'num2' and 'bar_id'). But the validation won't work and would throw the following exception:
raise(ArgumentError,"Could not find property to scope by: #{subject}. Note that :unique does not currently support arbitrarily named groups, for that you should use :unique_index with an explicit validates_uniqueness_of.")
Following the instructions from the exception this would lead to the following model:
class Foo
property :num1, Integer
property :num2, Integer, :unique => [:num1, :bar]
belongs_to :bar
end
Now the Validation is working but the generated indexes are crap (unique index with only one field: 'num2').
The only solution to fix this would be to address the constraints separately:
Given a model
This example results into a perfectly working unique index "unique_foos_scope_name" with three fields ('num1', 'num2' and 'bar_id'). But the validation won't work and would throw the following exception:
dm-validations/lib/dm-validations/validators/uniqueness_validator.rb
Line 39 in c874faf
Following the instructions from the exception this would lead to the following model:
Now the Validation is working but the generated indexes are crap (unique index with only one field: 'num2').
The only solution to fix this would be to address the constraints separately:
But this also breaks the application because belongs_to can't handle the :unique_index option correctly. So you'll have to use:
This seems to work but I don't think this is what the most people want :-)
The text was updated successfully, but these errors were encountered: