hi,

i guess this is more of a concept/design question.. i'll like to ask
how is this different from the use of validates?

suppose that i want to enforce the constraint that price should be
greater than or equal to zero.
should i put this as a validates block, or as a constraint
"check ..."? is there a better practice?

how will the check constraint throw an error when the price is lesser
than zero?
will it fail as a validation error?

thanks in advance!!

cheers,
winston



On Jan 16, 11:59 pm, Sharon Rosner <[EMAIL PROTECTED]> wrote:
> sequel_core in the trunk now contains code for defining constraints.
> here's an example:
>
>   create_table(:items) do
>     ...
>     check {:price < 100}
>   end
>
> you can also define named constraints:
>
>   create_table(:items) do
>     ...
>     constraint(:valid_price) {:price < 100}
>   end
>
> you can also pass a hash or string instead of a block:
>
>   check :price => 0..100
>   check 'price < 100'
>   check 'price < ?', 100
>
> etc.
>
> your comments please. Next step is to add code for adding and dropping
> constraints (for databases that support these operations).
>
> best
> Sharon
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to