Hi monnks
I'm trying to use populate to fill three tables at once, and getting invalid SQL. With two tables this works, but with three tables there's a missing IN. By adding some debug code to DBIx::Class::Storage::DBI I was able output the SQL, and this is what is being sent to _prepare_sth:
That looks like it should work if there were only an IN between the WHERE and director. Below is the perl I'm using to demonstrate the problem. Is this a known DBIC limitation, or am I creating the relations in the schema incorrectly?INSERT INTO scenes ( film, time, title) VALUES ( (SELECT me.title FROM movies me WHERE ( ( director (SELECT me.name FROM directors me WHERE ( name = ? )) AND title = ? ) )), ?, ? )
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 => 'Scene' ); }; 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( nasties => 'Film' ); }; 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", nasties => [ { title => 'Alligator', scenes => [ { title => '1st swamp pan', time => '05:36-12:01', }, ] } ] } ); $rs->populate( \@population ); } sub deploy_new_to_temp_file { my $schema = TestDB->connect('dbi:SQLite:dbname=test'); $schema->deploy( { add_drop_table => 1 } ); return $schema; } };
Thanks for any help
In reply to SQL Syntax error from recursive DBIx::Class populate by Boldra
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |