On Jul 7, 7:25 am, François Beausoleil <[email protected]>
wrote:
> Hi!
>
> I'm writing a constraint and I'm stuck. I'm trying to validate that
> the column's length is 10, and nothing else. I wrote:
>
> constraint :number_has_length_10, :length.sql_function(:number) ==
> 10
>
> The generated SQL is:
>
> CREATE TABLE (
> ...
> , CONSTRAINT "number_is_proper_length" CHECK false
> );
>
> The false is generated because :length.sql_function(:number) is
> obviously NOT equal to Fixnum 10, thus the return value of false. I
> know Sequel has a rule where no overridding of core Ruby methods is
> allowed, but I wonder how I should be writing this? Should I use a
> literal?
Equality in Sequel's DSL is done with hashes:
constraint :number_has_length_10,
{:length.sql_function(:number)=>10}
Jeremy
--
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.