[Dbix-class] inflate_column and sql_maker->quote_char/name_sep

Matt S Trout dbix-class at trout.me.uk
Thu Mar 2 17:01:18 CET 2006


On Thu, Mar 02, 2006 at 04:39:08PM +0100, Bernhard Graf wrote:
> In my table class inflate_column doesn't seemed to do anything.
> 
> My table class looked like:
> 
> package TDW::Schema::User;
> 
> use base 'DBIx::Class';
> use strict;
> use DateTime::Format::MySQL;
> 
> __PACKAGE__->load_components(qw/RandomStringColumns Core/);
> __PACKAGE__->table('user');
> __PACKAGE__->add_columns(qw/id name email birthday/);
> __PACKAGE__->set_primary_key('id'); 
> __PACKAGE__->random_string_columns('id', {salt => '[a-z0-9]'});
> 
> __PACKAGE__->storage->sql_maker->quote_char('`');
> __PACKAGE__->storage->sql_maker->name_sep('.');
> 
> __PACKAGE__->inflate_column('birthday', {
>     inflate => sub { my $d = shift; defined($d) ? DateTime::Format::MySQL->parse_date($d) : $d },
>     deflate => sub { my $d = shift; defined($d) ? DateTime::Format::MySQL->format_date($d) : $d },
> });
> 1;
> 
> As soon as I place sql_maker->quote_char()/name_sep() below
> inflate_column() it works.
> 
> Weird!
> 
> Is there a bug or where is my fault?

There is no __PACKAGE__->storage unless you're using DB.pm, but the regex
to ensure DBIC doesn't barf when you have multiple packages defined in one
file eats the error message, unfortunately.

Move the sql_maker stuff into your Schema class and you should be fine.

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list