Hi All
Hope it's good place to put some problem with CDBIL::Relationship
Help me please to understand rules of writing relationships. For
example: i've got two simple, testing DB (PostgreSQL):

                     test_fk
test_pk              test_fk_id (PK)
test_pk (PK) >-----> test_pk (FK)

and I wrote something like this:

use warnings;
use strict;

use Class::DBI::Loader;
use Class::DBI::Loader::Relationship;

my $loader=Class::DBI::Loader->new(
  dsn => "dbi:Pg:dbname=pit11;host=localhost;port=5432;",
  user => "some_user",
  namespace => "pit11",
  );
$loader->relationship("a test_pk has many test_fk");
my $class_test_pk=$loader->find_class('test_pk');
my $class_test_fk=$loader->find_class('test_fk');

So long, so good:) When I run that then everything is OK. But when I
change keys test_pk in DB to string other than table name (ex: id_pk)
I got following error:

Column test_pk does not exist in pit11::TestFk at /opt/perl/lib/
site_perl/5.10.0/Class/DBI/Relationship/HasA.pm line 11

Does it mean that PK/FKs have to be the same string as table name?
Sounds quite odd. Is there any way to have another table names and
keys names? I try to solve it for few days this rather trvial problem
and cannot move a step further.

With hope and regards:)
Gzegorz

Reply via email to