Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: SQL Syntax error from recursive DBIx::Class populate

by ribasushi (Pilgrim)
on Dec 05, 2016 at 08:12 UTC ( #1177201=note: print w/replies, xml ) Need Help??


in reply to SQL Syntax error from recursive DBIx::Class populate

Hi Paul,

This is an actual bug introduced by (I think) https://github.com/dbsrgits/dbix-class/commit/d0cefd99a. I will fix that shortly after the current permission dispute is resolved and I can get back to actually working on things.

In the meantime - use create() instead, it will be a tad (not much) slower, and will DTRT.

Minimal reproduction based on the DBIC test suite:

~$ perl -It/lib -MDBICTest -e ' DBICTest->init_schema->resultset("Artist")->populate([{ name => "beh", cds => [{ cdid => 666, year => 0, title => "buh", tracks => [{ title => "eeeh" }] }] }]) '

The working example with create() instead:

~$ DBIC_TRACE_PROFILE=console perl -It/lib -MDBICTest -e ' my $s = DBICTest->init_schema; $s->storage->debug(1); $s->resultset("Artist")->create({ name => "beh", cds => [{ cdid => 666, year => 0, title => "buh", tracks => [{ title => "eeeh" }] }] }) ' BEGIN WORK INSERT INTO artist( name ) VALUES( 'beh' ) INSERT INTO cd( artist, cdid, title, year ) VALUES( '4', '666', 'buh', '0' ) SELECT me.position FROM track me WHERE cd = '666' ORDER BY position DESC LIMIT '1' INSERT INTO track( cd, position, title ) VALUES( '666', '1', 'eeeh' ) COMMIT

Replies are listed 'Best First'.
Re^2: SQL Syntax error from recursive DBIx::Class populate
by Boldra (Deacon) on Dec 05, 2016 at 10:30 UTC
    Thanks Ribasushi! I've refactored to make two populate calls, and that works fine for me. I didn't measure the performance difference, but I can leave a note for future maintainers that if the bug is fixed they can use one populate call to improve performance.


    - Boldra

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1177201]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2020-10-24 17:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (246 votes). Check out past polls.

    Notices?