dbsrgits / dbix-class-schema-loader

Official GitHub remote for git.shadowcat.co.uk DBIx-Class-Schema-Loader.git
http://dbix-class.org/
11 stars 34 forks source link

calling make_schema_at modifes @INC [rt.cpan.org #81742] #32

Open rabbiveesh opened 1 year ago

rabbiveesh commented 1 year ago

Migrated from rt.cpan.org#81742 (status was 'new')

Requestors:

From jds@cpan.org on 2012-12-06 13:40:06 :

Tested under Win32 strawberryperl 5.14.2.1 on a 64bit Windows 7 machine.

After a call to make_schema_at, the current directory '.' disappears
from @INC.

As an example consider the following method:

sub dump_schema {   
    my $attrs = {
        debug          => 0,
        dump_directory => '.',
        exclude => qr/(?^:\bBIN)/
    };

    my $connect_info = [ $dsn, $user, $password ];
    push @$connect_info, { on_connect_do => 'PRAGMA foreign_keys = ON' };
    make_schema_at( 'TDG::Schema', $attrs, $connect_info );

    eval {
        require TDG::Schema;
        TDG::Schema->import();
        1;
    } or do {
        my $error = $@;
        croak $error;
    };

    $dbic_schema = TDG::Schema->connect( $dsn, $user, $password, '' );

}

The error I got when executing it (using a connection to a SQLite
database) was:

Can't locate TDG/Schema.pm in @INC...

Before calling make_schema_at, we have:

  DB<2> x @INC
0  'C:/Dwimperl/perl/site/lib'
1  'C:/Dwimperl/perl/vendor/lib'
2  'C:/Dwimperl/perl/lib'
3  '.'

afterwards:

  DB<3> x @INC
0  'C:/Dwimperl/perl/site/lib'
1  'C:/Dwimperl/perl/vendor/lib'
2  'C:/Dwimperl/perl/lib'

Which explains the error.