[Dbix-class] Problems with copy()

Carl Vincent C.A.Vincent at newcastle.ac.uk
Tue Apr 11 11:33:30 CEST 2006


Hi,

As I mentioned on IRC, I'm having trouble with copying an object.

I'm running DBIx-Class 0.06001 though I've tested this against trunk.

I've pared it down to a minimal test case - does this help anyone figure
out why it fails? It's probably something stupid I'm doing...

I'm using MySQL 5.0.16 and DBD::mysql 3.0002

And the outout I get is (with debug on):

INSERT INTO Test (author) VALUES (?): `1'
ok 1 - Created Article object
Can't call method "insert" on an undefined value at ...
/path/removed/lib/perl5/site_perl/5.8.8/DBIx/Class/Row.pm line 69.
# Looks like you planned 2 tests but only ran 1.
# Looks like your test died just after 1.


Thanks

Carl

       -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
       Carl Vincent             http://www.netskills.ac.uk/ (URL)
       Systems Manager                       0191 222 5003 (voice)
       NETSKILLS - Quality Internet Training 0191 222 5001  (fax)



## NWS3/Schema.pm:

package NWS3::Schema;

use strict;
use warnings;

use base qw/DBIx::Class::Schema/;

__PACKAGE__->load_classes();

1;



##NWS3/Schema/NA.pm

package NWS3::Schema::NA;

use strict;
use warnings;

use base qw/DBIx::Class/;

# DBIC configuration:
__PACKAGE__->load_components(qw/  Core /);
__PACKAGE__->table('Test');
__PACKAGE__->add_columns(qw/ id author / );
__PACKAGE__->set_primary_key('id');
1;
#CREATE TABLE  `Test` (
#  `id` int(10) unsigned NOT NULL auto_increment,
#  `author` varchar(100) NOT NULL default '',
#  PRIMARY KEY  (`id`)
#) ENGINE=InnoDB DEFAULT CHARSET=latin1;



##NA.t - test script:

use Test::More tests => 2;
use strict;
use NWS3::Schema;
my
$schema=NWS3::Schema->connect('DBI:mysql:database=nws3-test;host=xxx.xxx
.xxx.xxx',
                      'xxxx',
                      'xxxx'
);


my $article = { author        => 1, };


my ($a1, $a2, $a3, $a4);

ok( $a1 = $schema->resultset('NA')->create( $article ), "Created Article
object");

# Test copying
ok( $a4 = $a1->copy({}), 'Copy Article ok');










More information about the Dbix-class mailing list