[Dbix-class] result_source_instance error using inflate_column
Mark Hedges
hedges at scriptdolphin.com
Fri Nov 13 00:24:36 GMT 2009
I get this error for any class in which I try to use
inflate_column(), even if I have empty stub coderefs for
inflate and deflate. This is in a test script by itself,
I'm not using Catalyst. I saw some archive messages about
this error and tried the suggestions but I don't see what
I'm doing wrong...
Can't locate object method "result_source_instance" via package "DeSpam::DC::Lame" at /usr/lib/perl5/site_perl/5.8.8/DBIx/Class/ResultSourceProxy.pm line 47, <DATA> line 114.
perl 5.8.8 for CentOS 5.3 ... which has other very subtle problems
with perl so I wouldn't be surprised if this works elsewhere.
Other classes work just fine, including ones with InflateColumn::DateTime.
However I do notice that result_source_instance() is in DBIx::Class::DB
which is deprecated, if that is relevant.
It also doesn't matter if I put %allowed in the example
below inside the subref without a closure or outside in the
package declared only once.
Any ideas what I'm doing wrong with InflateColumn? Sorry
it's been a while since I've had my head in this space.
Thanks. --mark--
##############
mysql> create table lame ( lame varchar(64), lamer varchar(64), primary key (lame) );
###############
package DeSpam::DC;
use strict;
use warnings FATAL => 'all';
use English '-no_match_vars';
use base qw( DBIx::Class::Schema::Loader );
###########
package DeSpam::DC::Lame;
use strict;
use warnings FATAL => 'all';
use English '-no_match_vars';
use base qw( DBIx::Class );
__PACKAGE__->load_components(qw( InflateColumn Core ));
my %allowed = map {($_ => 1)} qw( foo bar biz baz );
__PACKAGE__->inflate_column('lamer', {
inflate => sub { [ split m{\s*,\s*}mxs, shift ] },
deflate => sub {
my $value = shift;
die "non-array reftype for deflating lamer" if ref $value ne 'ARRAY';
die "lamer value '$_' not allowed" for grep !exists $allowed{$_}, @{$value};
return join q{,}, @{$value};
},
});
###############
$ perl -c lib/DeSpam/DC/Lame.pm
lib/DeSpam/DC/Lame.pm syntax OK
###############
not ok 46 - use DeSpam::DC::Lame;
# Failed test 'use DeSpam::DC::Lame;'
# at ./t/00-load.t line 55.
# Tried to use 'DeSpam::DC::Lame'.
# Error: Can't locate object method "result_source_instance" via package "DeSpam::DC::Lame" at /usr/lib/perl5/site_perl/5.8.8/DBIx/Class/ResultSourceProxy.pm line 47, <DATA> line 114.
# Compilation failed in require at (eval 1225) line 2, <DATA> line 114.
# BEGIN failed--compilation aborted at (eval 1225) line 2, <DATA> line 114.
More information about the DBIx-Class
mailing list