Hi Boldra,

with some minor modifications your script works as intended:

package TestDB::Scene { use parent 'DBIx::Class::Core'; __PACKAGE__->table('scenes'); __PACKAGE__->add_columns(qw<title time description film>); __PACKAGE__->set_primary_key(qw<time>); }; package TestDB::Film { use parent 'DBIx::Class::Core'; __PACKAGE__->table('movies'); __PACKAGE__->add_columns(qw<title director>); __PACKAGE__->set_primary_key(qw<title>); __PACKAGE__->has_many( scenes => 'TestDB::Scene', 'time' ); }; package TestDB::Director { use parent 'DBIx::Class::Core'; __PACKAGE__->table('directors'); __PACKAGE__->add_columns(qw<name>); __PACKAGE__->set_primary_key(qw<name>); __PACKAGE__->has_many( movies => 'TestDB::Film', 'title' ); }; package TestDB { use parent 'DBIx::Class::Schema'; __PACKAGE__->load_classes(qw<Film Director Scene>); }; package main { use Modern::Perl; main: { my $schema = deploy_new_to_temp_file(); my $rs = $schema->resultset('Director'); my @population = ( { name => "Lesly Tack", movies => [ { title => 'Alligator', director => '#Lesly Tack', scenes => [ { title => '1st swamp pan', time => '05:36-12:01', description => 'Murder in a Swamp base +d Collection', film => '#Alligator', }, ] } ] } ); my @sources = $schema->sources; # for my $source (@sources) { # print "Table: ", $source, "\n"; # print "Columns: ", (join ", ", $schema->source($source)- +>columns), "\n"; # print "Relationships: ", $schema->source($source)->relat +ionships, "\n"; # } $rs->populate( \@population ); } sub deploy_new_to_temp_file { my $schema = TestDB->connect('dbi:SQLite:dbname=test.db'); $schema->deploy( { add_drop_table => 1 } ); return $schema; } };

But I think, you have to redesign your database a little, because the columns 'director' in table movies and 'film' in table scenes seem redundant.

Cheers Brian


In reply to Re: SQL Syntax error from recursive DBIx::Class populate by Anonymous Monk
in thread SQL Syntax error from recursive DBIx::Class populate by Boldra

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!
  • 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, details, 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, summary, 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.