[prev] [thread] [next] [Date index for 2005/04/28]

From: Jonathan Steinert
Subject:
Date: 09:21 on 28 Apr 2005
I'm trying to build a relatively simple object relationship, two tables
containing the following (to start)

Table Name: treasures
id	url
----------------------------------
15	http://hachi.kuiki.net
17	http://search.cpan.org
16	http://www.perl.com
18	http://www.google.com
14	http://www.postfix.org

Table Name: treasure_edges
child 	parent
-----------------------------------
16	15
17	15
18	17
18	16
15	14

use Treasure::Node;
my $node = Treasure::Node->retrieve(15);
foreach my $child ($node->children) {
        print "Child: $child\n";
}
foreach my $parent ($node->parents) {
        print "Parent: $parent\n";
}

prints out:

Child: 15
Parent: 15
Parent: 15

Does anyone know what is going on here? I've read this short code a good
30 or 40 times over, and I assume that this must be an error on my part,
but I just don't see it.

The modules called follow.

Thanks in advance for any information that may lead to the capture of the
bug causing me this grief :)


Treasure.pm:

Contains only a use base 'Class::DBI'; and ->connection() line.

Treasure/Node.pm:

use base 'Treasure';
__PACKAGE__->table( 'treasures' );
__PACKAGE__->columns( All => qw/id url/);
__PACKAGE__->sequence( 'treasures_id_seq' );
__PACKAGE__->has_many( children => [ 'Treasure::ChildVector' => 'child' ] );
__PACKAGE__->has_many( parents => [ 'Treasure::ParentVector' => 'parent' ] );

Treasure/ChildVector.pm:

use base 'Treasure';
__PACKAGE__->table( 'treasure_edges' );
__PACKAGE__->columns( All => qw/parent child/);
__PACKAGE__->has_a( child => 'Treasure::Node' );

Treasure/ParentVector.pm:

use base 'Treasure';
__PACKAGE__->table( 'treasure_edges' );
__PACKAGE__->columns( All => qw/child parent/);
__PACKAGE__->has_a( parent => 'Treasure::Node' );


Jonathan Steinert 09:21 on 28 Apr 2005

Re:
Jay Strauss 13:26 on 28 Apr 2005

Re:
Tony Bowden 13:53 on 28 Apr 2005

Re:
Perrin Harkins 17:28 on 28 Apr 2005

Re:
Tony Bowden 19:52 on 28 Apr 2005

Re: Multi Multi problems (was a null subject)
Jonathan Steinert 17:06 on 28 Apr 2005

Re: Multi Multi problems (was a null subject)
Matt S Trout 17:26 on 28 Apr 2005

Re: Multi Multi problems (was a null subject)
Perrin Harkins 17:37 on 28 Apr 2005

Re: Multi Multi problems (was a null subject)
Jonathan Steinert 19:06 on 28 Apr 2005

Re: Multi Multi problems (was a null subject)
Tony Bowden 19:53 on 28 Apr 2005

Generated at 10:24 on 04 May 2005 by mariachi v0.52