[Dbix-class] result_source_instance error using inflate_column

Peter Rabbitson rabbit+dbic at rabbit.us
Fri Nov 13 00:32:42 GMT 2009


Mark Hedges wrote:
> 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.
> 
> ###########
> 
> 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};
>     },
> });
> 
> ###############

^^^ A resultsource is useless until you declare a table() on it (this is not only
an accessor but also an initializer).

Cheers



More information about the DBIx-Class mailing list