On Tue, Feb 17, 2009 at 2:00 PM, Dermot <[email protected]> wrote: > Hi, > > I have a hashref like so: > > { > 'file' => 'cheese-biscuits_cutout_12-10-08_1.jpg', > 'path' => '/data/scanning/fast_track/ydm/12-10-08_1.jpg', > 'user_reference' => '12-10-08_1', > 'keywords' => 'Cheese biscuits, biscuits, biscuit, stack, > baked goods, cut out, white', > 'caption' => 'Cheese biscuits', > 'title' => 'Cheese biscuits' > }, > > > That I am trying to INSERT with find_or_create like this > > my $row = $schema->resultset('MetaData')->find_or_create({ > id => undef, > title => $hashref->{'title'}, > keywords => $hashref->{'keywords'}, > caption => $hashref->{'caption'},, > users_reference => $hashref->{'users_reference'}, > file => [ { path => $hashref->{'path'} } ], # > has_one > });
I don't know about the error you are getting now - but 'id => undef' is also not quite correct here - because create will then try to create a NULL id (which is presumably your primary key) - and this will fail on many databases. By the way this is why I wrote http://search.cpan.org/~zby/DBIx-Class-ResultSet-RecursiveUpdate-v0.002/ - you might like to try it out I've released it just yesterday. It is still experimental though. -- Zbigniew Lukasiak http://brudnopis.blogspot.com/ http://perlalchemy.blogspot.com/ _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[email protected]
