[Dbix-class] using inject_base (was Backcompat tests for the dev version of DBIx::Class::Schema::Loader)

Peter Rabbitson rabbit+dbic at rabbit.us
Sat Sep 12 10:54:31 GMT 2009


Zbigniew Lukasiak wrote:
> Hi,
> 
> Continuing the backcompat work for Loader, as suggested at IRC, I
> tried to use inject_base, but the documentation for it is rather
> scarce and I don't seem to get the call right.  I added it to the
> beginning of the test script - but then it seems that the ISA of
> DBIx::Class::Schema::Loader::DBI is replaced instead of just having
> one more value pushed on it:
> 
> package dbixcsl_backcompat;
> 
> use strict;
> use warnings;
> 
> use Test::More;
> use DBIx::Class::Schema::Loader::Compat::v0_040;
> use File::Path;
> use  Class::C3::Componentised;
> 
> use parent 'dbixcsl_common_tests';
> 
> Class::C3::Componentised->inject_base (
>     'DBIx::Class::Schema::Loader::DBI',
>     'DBIx::Class::Schema::Loader::Compat::v0_040',
> );
> 
> 
> -----------------
> zby at zby:~/progs/bc$ perl -Ilib t/30backcompat.t
> 1..10
> not ok 1 - Loader initialization
> #   Failed test 'Loader initialization'
> #   at t/lib/dbixcsl_backcompat.pm line 80.
> # Can't locate object method "new" via package
> "DBIx::Class::Schema::Loader::DBI" at lib/DBIx/Class/Schema/Loader.pm
> line 161.
> 

You need to use DBIx::Class::Schema::Loader::DBI; *before* playing with
the symbol table. The inject_base call, effectively creates an empty
Loader::DBI which use base ::Compat::v0_040. Any further requires of
said module will noop, as perl thinks it is already loaded.





More information about the DBIx-Class mailing list