[Dbix-class] Defaulting a column by configuration

fREW Schmidt frioux at gmail.com
Sat Jun 2 14:14:02 GMT 2012


Responding from my phone, pardon the top post.

Yeah, I see what you're saying.  What you're doing is fairly simple and I
can't imagine it ever really breaking.  The one thing i'd recommend you do
is at least make an accessor on the schema for the tz to abstract out the
looking at the connect info.
On Jun 1, 2012 4:45 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.
>
> Really, all I'm asking is a good way to pass in a default outside of the
> database.  My example with an extra key in connect_info seems to work.
> Can you see that breaking anything in the future?
>
> Same code works with more than one database and the default is different
> for each database.   So the code need to either look at something like the
> dsn to determine what database is connected (and lookup the default in a
> hash) or use some other value as I showed passed in with connect_info.
>
> And it's a bit more complex (always is), because (sadly) NULL time_zone
> means two things.  It means either "my timezone is undefined because I use
> my "parent's" time_zone, and if that isn't set then default to the config
> value" or it means, well, it's not defined and therefore need to use an
> appropriate default.
>
>    return $self->parent ? $self->parent->time_zone : $default_time_zone;
>
> Yes, a bit ugly.
>
>
> --
> Bill Moseley
> moseley at hank.org
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120602/e52=
cdd58/attachment.htm


More information about the DBIx-Class mailing list