Thank you.

Luiz

On 10 out, 14:04, Jeremy Evans <[email protected]> wrote:
> On Oct 10, 7:40 am, Luiz <[email protected]> wrote:
>
>
>
> > My table (postgres):
>
> > CREATE TABLE user
> > (
> >   id serial NOT NULL,
> >   name character varying(100) NOT NULL,
> >   CONSTRAINT user_pkey PRIMARY KEY (id)
> > )
>
> > My model:
>
> > class User< Sequel::Model(:user)
>
> > end
>
> > I tried:
>
> > >> u = User.new
>
> > => #<User #values={}>
>
> > >> u.name = nil
>
> > => Sequel::InvalidValue: nil/NULL is not allowed for the name column
>
> > Why it's validating before I call u.valid? ?
> > I think it should work like this:
>
> > >> u = User.new
>
> > => #<User #values={}>
>
> > >> u.name = nil
> > >> u.valid?
>
> > => false
>
> Sequel typecasts on assignment and raises errors when the typecasting
> fails by default.  It considers the assignment of nil to a column that
> doesn't allow NULL to be a typecasting error.
>
> You can change the default behavior by setting
> User.raise_on_typecast_failure = false.  Then it will not raise an
> error, and you can add a validation to check for the nil values.
>
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to