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

Thomas Sibley trs at bestpractical.com
Mon Feb 21 13:50:35 EST 2011


On 21 Feb 2011 12:56, Matt Zagrabelny wrote:
> #pseudocode examples...
> 
> $staged_infrastructure->staged_interfaces  #works
> $staged_interface->staged_infrastructure  #works
> $staged_interface->staged_interface_links #works
> 
> $staged_interface_link->staged_interface # FAILS

The methods that work are either column names, or column names with the
_id stripped off the end (Jifty magic).  The method that fails is never
defined as a column for a StagedInterfaceLink.

> 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.

The correct methods are the respective column names without the _id:

$staged_interface_link->local_interface
$staged_interface_link->remote_interface

>   column id =>
>     type is 'INTEGER';

As a side note, you don't need to declare the id column for every model
since Jifty automatically adds it.  You can also drop your "type is
'INTEGER'" declarations since integers are the default.  Similarly, the
references keyword doesn't need an explicit "by 'id'".

Thomas


More information about the jifty-devel mailing list