On May 12, 6:27 am, byrnejb <[email protected]> wrote:
> We have an ActiveRecord model class which is choking on an attribute
> that has both a default value of 'infinity' and a NOT NULL
> constraint. Basically, AR tries to insert a NULL because Ruby does
> not understand 'infinity' and AR explicitly sets all columns with
> defaults to those values (when it understands them) when inserting a
> row.
>
> I am contemplating moving this class to Sequel but I would like to
> know whether Sequel handles this situation any differently?
My previous message was perhaps a bit misguided. I misread your post
and thought you were trying to explicitly set 'infinity' as a float
value. If you only care about the database using the default value if
the user has not overridden it, then that is the default behavior in
Sequel. For new records, Sequel only includes the columns with values
you have assigned in the insert statement. All other columns are
excluded and will be set to their default values by the database. In
code:
DB.create_table(:foos){Integer :a; Integer :b}
Sequel::Model(:foos).create(:a=>1)
# INSERT INTO foos (a) VALUES (1)
However, if you plan on updating existing records, my previous message
has a lot of useful information. :)
Thanks,
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.