On Jan 15, 2008 8:48 AM, Sharon Rosner <[EMAIL PROTECTED]> wrote:
>
> > You also bring up something I was not thinking about, how do you
> > specify DB based constraints without causing problems when moving from
> > one DB to another. Not to mention keeping you migrations straight with
> > your current model. It seems to me that the constraints need to be
> > somehow defined model side to keep all that model logic in one place.
> > Meh, I don't have a good idea on how to solve that one.
>
> I think validations should be separate from constraints. Those are
> really two different things with different capabilities. I really
> don't see the connection between them, and IMO there's no chance of
> implementing something like that will work decently. Too coupled, too
> complicated.
>
> On the other hand, it would be good to have a way to add constraints
> when creating or altering a table. Maybe something like:
>
> DB.create_table :items do
> ...
> constraint {:price > 0}
> constraint :valid_discount {:discounted_price < :price}
> end
>
> DB.add_constraint :valid_discount {:discounted_price < :price}
>
> I think that should satisfy those who need validations in the
> database.
Yes - IMO these should be separate.
This way you can do a quick validates_uniqueness_of in model code to
catch 99.999% of the cases which is sufficient for many apps. If you
really want to garentee uniqueness you can add a constraint as well.
Zack
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---