[Dbix-class] Should this work?

Ash Berlin ash_cpan at firemirror.com
Tue Sep 15 21:32:46 GMT 2009


On 15 Sep 2009, at 22:25, Dermot wrote:

> 2009/9/15 Matt Whipple <matt at mattwhipple.com>:
>>
>>> You want to pass the ref as an argument to create
>>>
>>> $schema->create($ref)
>
> I've made some alterations (including the mega laughable typos) but
> I'm still getting un-expected results:
>
> Can't call method "select_single" on an undefined value at
> /usr/local/share/perl/5.10.0/DBIx/Class/ResultSet.pm line 740.
>
>
> ==============
> #!/bin/perl
>
> use strict;
> use warnings;
> use Carp; 			
> use FindBin qw/$Bin/;
> use Data::Dumper;
>
> use lib "$Bin/../lib";
> use SPL::Schema;
>
> my $ref = {
> 	number	        => 'A100/0002',
> 	title		        => 'A Title',
> 	codixId		=> 651000002,
> 	};
>
>
> my $schema = SPL::Schema->resultset('Assets');
> # my $schema = SPL::Schema->resultset('Assets')->search();
> die "Can't connect $@\n" unless $schema;
> print Dumper($ref);
> $schema->find_or_create($ref) or warn "Error inserting: $@\n";
> #$schema->create($ref) or warn "Error inserting: $@\n";  prints Can't
> call method "insert" on an undefined val
> ======================
>
> Can anyone spot the error of my ways?
> Thanx,
> Dp.

Looks like never connected your schema to a DB. However the error it  
gives leaves a lot to be desired. If you feel up to it, a patch would  
be good, otherwise a bug on rt.cpan.org please.

-ash



More information about the DBIx-Class mailing list