[Dbix-class] Should this work?

Dermot paikkos at googlemail.com
Tue Sep 15 21:25:04 GMT 2009


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.



More information about the DBIx-Class mailing list