Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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/Schema.pm in @INC (@INC contains: C:/strawberry/per +l/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib) at f +ind_num_roots.pl 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, 'dbic_schema_dump.pl' ) . ' --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

Title:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (15)
    As of 2014-07-25 15:13 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (172 votes), past polls