[Dbix-class] Should this work?

Dermot paikkos at googlemail.com
Tue Sep 15 19:49:03 GMT 2009


Hi,

I'm getting this error:
DBIx::Class::ResultSet::create(): create needs a hashref at insert.t line 22

from the script below.  I believe I am passing a hashref. I suspect
there is a problem with my Perl (5.10.0) but I might also be making a
newbie error.

Thanx,
Dp.


=============== script ===========
#!/bin/perl

use strict;
use warnings;
#use Crap;          # Why isn't there a crap in my distro?
use FindBin qw/$Bin/;
use Data::Dumper;

use lib "$Bin/../lib";
use SPL::Schema;

my $hashref = {
    number   => 'A100/0002',
    title          => 'A Title',
    codixId     => 651000002,
    };

my $schema = SPL::Schema->resultset('Assets');
             die "Can't connect $@\n" unless $schema;
print Dumper($ref);
$schema->create->($ref) or warn "Error inserting: $@\n";

======== output ========
$VAR1 = {
          'codixId' => 651000002,
          'title' => 'A Title',
          'splNumber' => 'A100/0002'
        };
create needs a hashref at
/usr/local/share/perl/5.10.0/DBIx/Class/Schema.pm line 1027
	DBIx::Class::Schema::throw_exception('SPL::Schema', 'create needs a
hashref') called at
/usr/local/share/perl/5.10.0/DBIx/Class/ResultSet.pm line 3090
	DBIx::Class::ResultSet::throw_exception('DBIx::Class::ResultSet=HASH(0x861a4e8)',
'create needs a hashref') called at
/usr/local/share/perl/5.10.0/DBIx/Class/ResultSet.pm line 2298
	DBIx::Class::ResultSet::create('DBIx::Class::ResultSet=HASH(0x861a4e8)')
called at insert.t line 22



More information about the DBIx-Class mailing list