using inject_base (was Backcompat tests for the dev version of DBIx::Class::Schema::Loader)

2 messages Options
Embed this post
Permalink
Zbigniew Lukasiak

using inject_base (was Backcompat tests for the dev version of DBIx::Class::Schema::Loader)

Reply Threaded More More options
Print post
Permalink
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@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.


--
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/

_______________________________________________
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@...
Peter Rabbitson-2

Re: using inject_base (was Backcompat tests for the dev version of DBIx::Class::Schema::Loader)

Reply Threaded More More options
Print post
Permalink
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@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.



_______________________________________________
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@...