[Dbix-class] Can't find source for XXX question
Mitchell Elutovich
melutovich at gmail.com
Sat Dec 1 17:26:56 GMT 2018
If the data is coming from the DB it does not use the "new" sub it uses a
sub inflate_result.
Start by looking at these
(search for inflate_result)
https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/Manual/Cookbook.pod
https://metacpan.org/pod/DBIx::Class::Row#inflate_result
On Fri, Nov 30, 2018 at 12:58 AM ejm <mansky at mindspring.com> wrote:
> Hi All,
>
> Another newbie question about the "Can't find source for XXX" error
> message.
>
> I've been able to establish a connection to my MySQL DB by specifying a
> storage type for my Schema,
> but I keep getting the "Can't find source for XXX" error message when I
> try searching the table XXX.
>
> In my Schema object I have :
>
> __PACKAGE__->load_namespaces();
>
> and the usual "use base qw(DBIx::Class::Schema);
>
> so that methods are correctly inherited from DBIx::Class::Schema.
>
> Then I have a new constructor in my Schema object which blesses my object
> in the namespace I need it in:
>
> sub new {
> my ($proto, $db) = @_;
> my $class = ref($proto) || $proto;
> my $self = bless {}, $class;
>
> $self->storage_type('::DBI::mysql');
> return $self->connect($dsn, $dbuser, $dbpw, { AutoCommit => 1});
> }
>
> where $db is the MySQL DB I need to access and $dbuser, $dbpw are local
> variables containing the usual User and PW.
>
> and $dsn = "dbi:mysql:database=$db";
>
> I've checked the object returned by the constructor and it has the
> expected entries:
>
> class_mappings => { 'X::Y::Z::Result::Table1' => 'Table1',
> 'X::Y::Z::Result::Table2' => 'Table2',
> ...
> },
>
> source_registrations => {
> 'Table1' => bless( { 'result_class' =>
> 'X::Y::Z::Result::Table1',
> 'resultset_class' =>
> 'X::Y::Z::ResultSet::Table1',
> 'name' => 'Table1',
> 'source_name' => 'Table1',
> ...
> },
> 'DBIx::Class::ResultSource::Table'},
>
> ...
> },
>
> storage => { '_connect_info' => [ 'dbi:mysql:database=VSO',
> 'dbuser',
> 'dbpw',
> {
> 'AutoCommit' => 1
> },
> '_conn_pid' => 10779,
> ...
>
> }
>
>
> I see an entry in source_registrations for each of the tables in the DB
> VSO, all with their correct columns.
> However, I noted that the objects are all blessed into the generic
> DBIx::Class::ResultSource::Table class and not
> the X::Y::Z::ResultSource::Table1 class as I would have expected.
>
> Is that why I am getting the "Can't find source ..." error message ?
>
> I have a package for each table in X::Y::Z::Result namespace and
> additionally a package for the table I am testing
> in both X::Y::Z::ResultSource::Table1 and X::Y::Z::ResultSet::Table1
>
> I noted that the resultset_class key above was indeed set to my
> namespace-specific package for my test table.
>
> Any tips or ideas would be greatly appreciated.
>
>
> Thanks,
>
> --Ed
>
>
>
>
>
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20181201/5b01a39c/attachment.htm>
More information about the DBIx-Class
mailing list