[Dbix-class] Possible bug with InflateColumn::DateTime combined
with accessor naming
Jason Kohles
email at jasonkohles.com
Thu Feb 22 18:59:47 GMT 2007
On Feb 22, 2007, at 7:05 AM, Carl Vincent wrote:
> 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!
>
I haven't tried it, but it looks like you should be able to fix it by
changing InflateColumn/DateTime.pm slightly. After the call to
next::method, add:
if ( exists $info->{ 'accessor' } ) { $column = $info->{ 'accessor' } };
> 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'
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive: http://www.mail-archive.com/dbix-
> class at lists.rawmode.org/
>
--
Jason Kohles
email at jasonkohles.com
http://www.jasonkohles.com/
"A witty saying proves nothing." -- Voltaire
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070222/e47a8929/attachment.htm
More information about the Dbix-class
mailing list