I have a bug in my code that’s caught me completely off guard, and I’m
hoping that maybe my IT folks updated a gem somewhere that changed
something I didn’t know about.
I’ve got a field, mq_unsubscribe, in my mail_queue table. It has a
non-null constraint on it, and a default value of empty string ‘’. (I
did not set it up.)
I’ve got a simple Model pointed at this table, and have been generating
items like this:
MailQueueItem.create :template=>3, :subject=>‘Foo’, :email=>‘duane’…
and so on, which turns nicely into an INSERT into mail_queue
(mq_unsubscribe
, template
, subject
, email
) VALUES (``, 3, Foo
,
duane
)
Note that it recognizes the empty string, and uses that.
However, I just discovered I’m now getting this:
INSERT into mail_queue (mq_unsubscribe
, template
, subject
,
email
) VALUES (NULL, 3, Foo
, duane
)
where it’s generating a NULL for my non-specified field, and that’s
breaking the constraint. To the best of my ability to figure it out,
the code that does the MailQueueItem.create has not in any way changed.
I’m hoping that somebody can say “Yes, version X of ActiveRecord now
behaves differently in that circumstance…”
Fingers crossed!
Duane