[Dbix-class] Possible bug with InflateColumn::DateTime combined with accessor naming

Carl Vincent C.A.Vincent at newcastle.ac.uk
Thu Feb 22 12:05:09 GMT 2007


Hi,

I've had a quick discussion with Castaway on IRC about this, but I think
I've uncovered a problem with using InflateColumn::DateTime on a column
at the same time as asking for the accessor to have a non-standard name.

It looks like the accessor is created with the requested name, but
InflateColumn is creating it's code under the default name (that of the
column).

My grasp of the way DBIC creates methods on the fly is a bit hazy - can
anyone smarter confirm this or point me in the right direction!

Cheers

Carl (IRC: CaptainCarlos)

-- 
     -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     Carl Vincent             http://www.netskills.ac.uk/ (URL)
     Systems Manager                       0191 222 5003 (voice)
     Netskills, Newcastle University       0191 222 5001  (fax)
     Training  -  Accreditation  -  Consultancy  -  Development


The Schema Class:

use base qw/DBIx::Class/;

__PACKAGE__->load_components(qw/ InflateColumn::DateTime Core /);
__PACKAGE__->table('Authn');
__PACKAGE__->add_columns( qw/ person / );
__PACKAGE__->add_columns( created => { data_type => 'timestamp',
accessor => 'something_else' } );
__PACKAGE__->set_primary_key('person');

sub created {
    my $self = shift;
    return "HELLO";
}


And the test:

ok( $a1 = $schema->resultset('TestSchema')->find( 1 ), 'Retrieved by
id');
isa_ok( $a1->something_else(), 'DateTime', 'something_else() return
type');
print $a1->something_else()."\n";
is( $a1->created(), 'HELLO', 'created() return value');


Results:

ok 1 - Retrieved by id
not ok 2 - something_else() return type isa DateTime
#   Failed test 'something_else() return type isa DateTime'
#   at accessor_naming.t line 28.
#     something_else() return type isn't a reference
2007-02-22 10:48:04
not ok 3 - created() return value
#   Failed test 'created() return value'
#   at accessor_naming.t line 30.
#          got: '2007-02-22T10:48:04'
#     expected: 'HELLO'



More information about the Dbix-class mailing list