[jifty-devel] jifty::dbi::schema and reference names

Matt Zagrabelny mzagrabe at d.umn.edu
Mon Feb 21 12:56:23 EST 2011


Greetings,

I'm having an issue using the references schema directive.

I've successfully used references in the following schema and code:

package NA::Model::StagedInfrastructure;
use Jifty::DBI::Schema;

use NA::Record schema {
  column id =>
    type is 'INTEGER';
...
  column staged_interfaces =>
    references NA::Model::StagedInterfaceCollection by
'staged_infrastructure_id';
};


package NA::Model::StagedInterface;

use NA::Record schema {
  column id =>
    type is 'INTEGER';
....
  column staged_infrastructure_id =>
    references NA::Model::StagedInfrastructure by 'id',
    type is 'INTEGER';
  column staged_interface_links =>
    references NA::Model::StagedInterfaceLinkCollection by 'local_interface_id';
};

package NA::Model::StagedInterfaceLink;

use NA::Record schema {
  column id =>
    type is 'INTEGER';
  column local_interface_id =>
    references NA::Model::StagedInterface by 'id',
    type is 'INTEGER';
  column remote_interface_id =>
    references NA::Model::StagedInterface by 'id',
    type is 'INTEGER';
};

#pseudocode examples...

$staged_infrastructure->staged_interfaces  #works
$staged_interface->staged_infrastructure  #works
$staged_interface->staged_interface_links #works

$staged_interface_link->staged_interface # FAILS

Obviously there is an inability to determine what reference to use, as
both references point back to the 'StagedInterface' model/table. How
do I give the references a handle (name) to go by?

I would need something like:

$staged_interface_link->staged_interface_local
$staged_interface_link->staged_interface_remote

but I don't know how to make the names work.

Any advice?

-matt zagrabelny


More information about the jifty-devel mailing list