On Tue, 17 Feb 2009 13:00:04 +0000, 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
> });
>
>
$hashref->{'users_reference'} does nox exist. I had problems with undef
variables in a hash. I generally put a "scalar" in front of my variables,
this fixes the "undef value in hash"-problem
e.g.
->find_or_create({
...
users_reference => scalar $hashref->{'users_reference'},
...
});
_______________________________________________
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]