Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Update / Bug found!

I found the reason why the module could not be loaded. Before the call to the method make_schema_at of DBIx::Class::Schema::Loader, @INC contained the current directory '.'. After the call, though, this entry has disappeared from @INC. Would you consider this as a bug or am I too reckless assuming @INC would not be touched?

Dear Perl Monks,

as I am trying to get something to work using DBIx::Class::Schema::Loader , I keep bumping my head against some issues. The first is the following:

I have an SQLite database on disk and want to dump its DBIx::Class schema and connect to the schema immediately afterwards. The test code is as follows:

sub dump_and_import_schema { my ($dsn, $user, $password) = @_; 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, '' ); }

If I run this (passing appropriate connection parameters), I get the following error:

'Can\'t locate TDG/ in @INC (@INC contains: C:/strawberry/per +l/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib) at f line 57.

Now, if I put the call to make_schema_at in a separate script and call it as follows:

sub dump_and_import_schema { my ($dsn, $user, $password) = @_; my $cmd = 'perl ' . File::Spec->catdir( $own_path, '' ) . ' --dsn ' . $dsn; $cmd .= ' --user ' . $user if $user; $cmd .= ' --password ' . $password if $password; $cmd .= ' --dumpdir .'; $cmd .= ' --exclude \bBIN'; system($cmd) == 0 or croak "system $cmd failed: $?"; eval { require TDG::Schema; ...
everything works fine. Or, if I run the original script two times, the first time after having added an exit() after the call to make_schema_at and the second time after having commented out the call to make_schema_at, everything runs fine, too.

I ran the program in a debugger and put a breakpoint immediately after the call to make_schema_at, made a backup of the resulting schema dump and compared it to the result one gets when exiting after having dumped it. There is no difference, i.e. it was not the case that something has not been written to disk yet.

Please enlighten my troubled brain: Why does dump_and_import_schema not work as expected?

Update: Improved readability of title and first sentence.

In reply to DBIx::Class::Schema::Loader: can't load schema by jds17

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (4)
    As of 2018-06-19 23:08 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (116 votes). Check out past polls.