[Dbix-class] DBIx::Class::Resultset - DBI Exception near PATH

Dermot paikkos at googlemail.com
Tue Feb 17 13:20:31 GMT 2009


2009/2/17 Zbigniew Lukasiak <zzbbyy at gmail.com>:
> On Tue, Feb 17, 2009 at 2:00 PM, Dermot <paikkos at googlemail.com> 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.

I may have thrown you a bit there because I manually modified the keys
in my email rather than cut and pasted them. So the hash key
'users_reference' is a typo of user_reference. Sorry.


I don't get the issue if I comment out

file => [ { path => path => $hashref->{'path'} } ]

So this is where the problem is and the error refers to PATH

DBIx::Class::ResultSet::find_or_create(): DBI Exception:
DBD::SQLite::db prepare_cached failed: near "PATH": syntax error(1) at
dbdimp.c line 271 [for Statement "SELECT me.id, me.photog_id, me.path,
me.file_data_id FROM files me WHERE ( ( ( ( me.id PATH ? ) ) ) )"] at
script/import.pl line 87

I was thinking my schema's has_one relationship wasn't set-up correctly.

Thanx,
Dp.



More information about the DBIx-Class mailing list