ActiveRecord, Mysql, NULL columns and uniqueness

Hi all.
Mysql allows to set multiple NULLs on columns with unique constraint,
it’s normal SQL. Well, but when I try to submit some form, all
unspecified values will be consodered as ‘’ (empty string) and
(Mysql::Error: Duplicate entry occurs (((. How I can teach ActiveRecord
to consider empty fields as NULL?

On 5-aug-2006, at 5:02, zven wrote:

Hi all.
Mysql allows to set multiple NULLs on columns with unique constraint,
it’s normal SQL. Well, but when I try to submit some form, all
unspecified values will be consodered as ‘’ (empty string) and
(Mysql::Error: Duplicate entry occurs (((. How I can teach
ActiveRecord
to consider empty fields as NULL?
It has not that much to do with SQL than with ActiveRecord, which
doesn’t coerce empty strings to nil. Try this:
http://julik.textdriven.com/svn/tools/rails_plugins/attribute_cleanup/


Julian ‘Julik’ Tarkhanov
please send all personal mail to
me at julik.nl

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs