[Dbix-class] Defaulting a column by configuration

Rob Kinyon rob.kinyon at gmail.com
Sun Jun 3 13:54:33 GMT 2012


On Fri, Jun 1, 2012 at 5:42 PM, Bill Moseley <moseley at hank.org> wrote:
>
>
> On Fri, Jun 1, 2012 at 3:09 PM, fREW Schmidt <frioux at gmail.com> wrote:
>>
>>
>> Why not just add a database level default?  That would be easy, clean, and
>> correct.  Plus if do that to remove the actual nulls from the DB
>
>
> That only applies to new rows inserted.   These are old and existing
> databases and trying to solve this outside of the database.

This sounds like a really bad solution. Technically, it could work.
But, this is a prime example of "Action at a Distance" and a violation
of the "Single Responsibility Principle". You're taking an existing
row, loading it into a business application, using it in a completely
unrelated way, and then defaulting the timezone if the row changes in
any way. I hope you realize how disruptive this can be.

The right solution is to fix the errant rows in the database
separately from the business application in a one-time script. That
fixes the existing rows. Then, apply a default at the database level
to make sure new rows from any source are setup properly.
-- 
Thanks,
Rob Kinyon



More information about the DBIx-Class mailing list