The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DBIx::DataModel::Meta::Path - meta-information about a path

SYNOPSIS

  # create the path; best called through $assoc->_install_path(...)
  my $path = new (
    name         => $role_name,
    from         => $source_meta_table,
    to           => $destination_meta_table,
    on           => \%condition,         # in SQL::Abstract::More format
    multiplicity => [$min, $max],
    association  => $association,
    direction    => $direction,          # either 'AB' or 'BA'
  );

DESCRIPTION

This class is closely related to DBIx::DataModel::Meta::Association. A path corresponds to one possible database join between two tables.

PUBLIC METHODS

new

Constructor method. Normally this will be called indirectly through

  $association->_install_path(%args)

because the "_install_path" in DBIx::DataModel::Meta::Association method automatically adds its own invocant (the $association) into %args.

Named arguments to new() are :

name

The name of this path (must be unique within the source table). That name is used for defining a Perl method in the class associated to the source table, and for interpreting multi-steps joins in calls like

  $schema->join(qw/FirstTable role1 role2 .../)
from

The DBIx::DataModel::Meta::Source::Table instance which is the source for this path.

to

The DBIx::DataModel::Meta::Source::Table instance which is the target for this path.

on

A hashref that describes the database join condition : the keys are names of columns for the left-hand side, and values are names of columns for the right-hand side. For example

  on => {foreign_1 => 'primary_1', foreign_2 => 'primary_2'}

will generate SQL clauses of shape

  .. JOIN ON <left>.foreign_1 = <right>.primary_1
         AND <left>.foreign_2 = <right>.primary_2
multiplicity

An arrayref [$min, $max]; see explanations in DBIx::DataModel::Meta::Association.

association

The association to which this path belongs.

direction

A string that describes the direction of this path within the association : must be either 'AB' or 'BA'.

name

Name of this path

from

Source of this path (an instance of DBIx::DataModel::Meta::Source::Table).

to

Target of this path (an instance of DBIx::DataModel::Meta::Source::Table).

on

Copy of the hash for the join condition

multiplicity

Array ($min, $max) describing the multiplicity.

association

Instance of DBIx::DataModel::Meta::Association to which this path belongs.

direction

Direction of the path within the association; a string containing either 'AB' or 'BA'.

opposite

Returns the path object representing the opposite direction.