[Dbix-class] Help with relationships

Jess Robinson castaway at desert-island.me.uk
Tue May 8 09:19:29 GMT 2007



On Fri, 4 May 2007, Jason Kaskel wrote:

> I'm in full head banging mode now. And I'm not talking about rock!
>
> The simplified version of my problem:
>
> Variant Class:
> package JAK::Schema::Variant;
>
> # Created by DBIx::Class::Schema::Loader v0.03009 @ 2007-05-04 15:38:46
>
> use strict;
> use warnings;
>
> use base 'DBIx::Class';
>
> __ PACKAGE__->load_components("PK::Auto", "Core");
> __ PACKAGE__->table("variant");
> __ PACKAGE__->add_columns(
>  "variant_id",
>  { data_type => "INT", default_value => undef, is_nullable => 0, size => 11
> },
>  "game",
>  { data_type => "ENUM", default_value => undef, is_nullable => 1, size =>
> 16 },
>  "scenario",
>  { data_type => "ENUM", default_value => undef, is_nullable => 1, size =>
> 15 },
>  "goal",
>  {
>    data_type => "VARCHAR",
>    default_value => "10,10,10,10",
>    is_nullable => 0,
>    size => 32,
> },
> );
> __ PACKAGE__->has_many("meetings" => "JAK::Schema::Meeting");
> __ PACKAGE__->set_primary_key("variant_id");
> 1;
>
> Meeting Class:
> package JAK::Schema::Meeting;
>
> # Created by DBIx::Class::Schema::Loader v0.03009 @ 2007-05-04 18:48:46
>
> use strict;
> use warnings;
>
> use base 'DBIx::Class';
>
> __ PACKAGE__->load_components("PK::Auto", "Core");
> __ PACKAGE__->table("meeting");
> __ PACKAGE__->add_columns(
>  "meeting_id",
>  { data_type => "INT", default_value => undef, is_nullable => 0, size => 11
> },
>  "start_time",
>  {
>    data_type => "DATETIME",
>    default_value => "0000-00-00 00:00:00",
>    is_nullable => 0,
>    size => 19,
>  },
>  "variant",
>  { data_type => "INT", default_value => 0, is_nullable => 0, size => 11 },
>  "synopsis",
>  {
>    data_type => "TEXT",
>    default_value => undef,
>    is_nullable => 1,
>    size => 65535,
> },
> );
> __ PACKAGE__->belongs_to("variant" => "JAK::Schema::Variant");
> __ PACKAGE__->set_primary_key("meeting_id");
>
> 1;
>
> Code that just won't work:
>        my $rs = $JAK::schema->resultset('Meeting')->search(
>            { 'meeting_id' => "1" },
>            { join => 'variant' },
>       ) ;
>
> When I try to access $rs->next, it keeps telling me:
> No such relationship variant
>
> What idiotic thing am I doing wrong?
>


Hi,

That's just.. strange.. it looks fine. How much did your simplifying 
remove? Did you try the simplified version? Can we also see the Schema 
class please? Or hop onto the #dbix-class channel on irc.perl.org for some 
interactive help..

Jess





More information about the Dbix-class mailing list