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

NAME

Class::ReluctantORM::SQL::Table - Represent a Table in a SQL statement

SYNOPSIS

  use Class::ReluctantORM::SQL::Aliases;

  # TODO DOCS - synopsis is way out of date

  my $table = Class::ReluctantORM::SQL::Table->new(table => $table, schema => $schema);
  my $table = Class::ReluctantORM::SQL::Table->new($cro_class);

  # Now use $table in other Class::ReluctantORM::SQL operations

  $string = $driver->render_aliased_table($table);
  $string = $driver->render_table_alias_definition($table);

DESCRIPTION

Represents a database table in a SQL statement. Inherits from Class::ReluctantORM::SQL::From::Relation .

CONSTRUCTORS

$table = Table->new($cro_class);

$table = Table->new(table => 'table_name');

$table = Table->new(table => 'table_name', schema => 'schema_name');

Creates a new Table reference. In the first form, the Table will learn its identity from the given Class::ReluctantORM class. This is the preferred approach, as it allows the table to know what columns it has, etc.

In the second and third forms, the table is identified by an explicit table name.

ACCESSORS AND MUTATORS

$table->alias(...);

$table->has_column(...);

$table->columns(...);

$table->tables(...);

$table->knows_any_columns(...);

$table->knows_all_columns(...);

$table->pretty_print(...);

These methods are inherited from Relation.

@empty = $table->child_relations();

Always returns an empty list. Required by the Relation interface.

$table->class($cro_class);

$class = $table->class();

Reads or sets the Class::ReluctantORM class that this Table represents. If setting, the table name and scheme name will be overwritten.

$bool = $table->is_leaf_relation();

Always returns true for this class. Required by the Relation interface.

$bool = $rel->is_table();

All objects of this class return true. The class add this method to its parent class, making all other subclasses of return false.

$table->schema('schema_name');

$name = $table->schema();

Reads or sets the schema name.

$table->table('table_name');

$name = $table->table();

Reads or sets the table name.

@cols = $t->primary_key_columns()

Returns a list of SQL Column objects that represent the columns that make up the primary key on the table. You can only call this if $t->knows_all_columns is true; otherwise, you'll get an exception.

$str = $t->display_name()

Returns a string suitable for display to the user. Used in exception messages.

$bool = $table1->is_the_same_table($table2, <$check_aliases>);

Returns true if $table1 and $table2 refer to the same schema name and table name.

If $check_aliases is provided and true, the two Tables must be using the same table alias.

$clone = $t->clone();

Makes a new Table object, copying over the name, alias, schema, and class of the original.

AUTHOR

Clinton Wolfe