[Dbix-class] relationshipchange with v0.06999_01 ?

Carl Franks fireartist at gmail.com
Tue May 30 20:40:38 CEST 2006


I'm just starting to develop an app, so upgraded to 0.06999_01 to test it out.
Judging by some file dates, it's likely that I had been running
v0.05007 before, but I can't verify that for sure, as the files were
deleted when I upgraded.

The following is some code that had been running OK:

   my $m = $c->model('lifemap::Home');

   my @home = $m->search( undef, {
       order_by => 'startdate',
   });

    $c->res->body( Dumper( map {$_->find_related('location')->title} @home ) );

Now, running 0.06999_01, the find_related('location') call is dying
with this error message:
Caught exception in LifeMap::Controller::Root->default
"DBIx::Class::Relationship::Base::find_related():
No such relationship location at
/[snip]/LifeMap/script/../lib/LifeMap/Controller/Root.pm line 47"

If I dump $m, the model object, I notice that all the '_relationships'
keys contain empty hashes.

Copied below is my model file, and all the Schema files.

I can't see anything wrong with my relationship setup, but I must be
doing something wrong!

Carl

#####

package LifeMap::Model::lifemap;

use strict;
use base 'Catalyst::Model::DBIC::Schema';

1;

#####

package LifeMap::Schema;
use base qw/ DBIx::Class::Schema /;
use strict;
use warnings;

__PACKAGE__->load_classes(qw/ Location Home Other /);

1;

#####

package LifeMap::Schema::Location;
use base qw/ DBIx::Class /;
use strict;
use warnings;

__PACKAGE__->load_components( qw/ PK::Auto::MySQL Core /);

__PACKAGE__->table("lifemap_location");

__PACKAGE__->add_columns(qw/ id lng lat title /);

__PACKAGE__->set_primary_key('id');

__PACKAGE__->might_have( home => 'Home', {'foreign.location_id' => 'self.id'} );

__PACKAGE__->might_have( other => 'Other', {'foreign.location_id' =>
'self.id'} );

1;

#####

package LifeMap::Schema::Home;
use base qw/ DBIx::Class /;
use strict;
use warnings;
use DateTime;
use DateTime::Format::Strptime;

__PACKAGE__->load_components( qw/ Core InflateColumn::DateTime /);

__PACKAGE__->table("lifemap_home");

__PACKAGE__->add_columns(qw/ location_id /);

__PACKAGE__->add_columns(
   startdate => {datatype => 'datetime'},
   enddate   => {datatype => 'datetime'},
);

__PACKAGE__->set_primary_key('location_id');

__PACKAGE__->belongs_to( location => 'Location', {'foreign.id' =>
'self.location_id'} );

1;

#####

package LifeMap::Schema::Other;
use base qw/ DBIx::Class /;
use strict;
use warnings;

__PACKAGE__->load_components( qw/ Core /);

__PACKAGE__->table("lifemap_other");

__PACKAGE__->add_columns(qw/ location_id /);

__PACKAGE__->set_primary_key('location_id');

__PACKAGE__->belongs_to( location => 'Location', {'foreign.id' =>
'self.location_id'} );

1;



More information about the Dbix-class mailing list