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

NAME

Class::ReluctantORM::SQL::From::Relation - Base class for SQL relations

DESCRIPTION

Abstract base class to represent a SQL relation.

Known subclasses:

Class::ReluctantORM::SQL::Table
Class::ReluctantORM::SQL::From::Join
Class::ReluctantORM::SQL::SubQuery

VIRTUAL METHODS

All of these methods are intended to be overridden in subclasses. Some methods provide a default implementation.

$rel->alias('my_alias');

$alias = $rel->alias();

Reads or sets the alias used for this relation in SQL.

@args = $arg->child_relations();

Returns any children of the object. Results only defined if is_leaf is false.

@cols = $rel->columns()

Returns a boolean indicating whether a column is present in this relation. Only valid if knows_columns() is true.

No default implementation provided.

$bool = $rel->has_column('col_name')

Returns a boolean indicating whether a column is present in this relation. Only valid if knows_columns() is true.

No default implementation provided.

$bool = $arg->is_leaf_relation();

Indicates if the object is a terminal point on the From tree. Default implementation returns true.

$bool = $rel->knows_all_columns()

Returns a boolean indicating whether all output columns are known in advance from this relation.

No default implementation provided.

$bool = $rel->knows_any_columns()

Returns a boolean indicating whether any output columns are known in advance from this relation.

No default implementation provided.

$rel = $rel->parent_relation();

Returns the parent node of the object. If undefined, this is the root node.

$str = $rel->pretty_print();

Renders a human-readable version of the relation to a string.

@tables = $rel->tables(%opts);

Returns a list of all tables referenced in the relation and its children.

Supported options:

exclude_subqueries

Optional boolean, default false. If true, tables mentioned only in subqueries will not be included.

$table = $rel->leftmost_table();

Finds the "base" table, the one added earliest. This will return either a Table or a SubQuery, but never a Join.