NAME

DBIx::QuickORM::Schema::Table - Object representing a single table in a schema.

DESCRIPTION

Represents a single table (or view) in a schema, including its columns, unique constraints, indexes, primary key, and links to other tables. Also serves as a query source via DBIx::QuickORM::Role::Source.

SYNOPSIS

my $table = $schema->table('users');

my @columns = $table->columns;
my $col     = $table->column('email');

ATTRIBUTES

name

The schema (ORM) name for the table. Defaults to db_name.

db_name

The name of the table in the database. Defaults to name.

columns

Hashref of column name to DBIx::QuickORM::Schema::Table::Column instance.

unique

Hashref of unique constraints keyed by column key.

row_class

The row class used when fetching rows from this table.

row_class_autofill

Autofill object used to generate row class accessors, if any.

created

Trace string for where the table was initially defined.

compiled

Trace string for where the table was compiled.

is_temp

True if the table is temporary.

Arrayref of DBIx::QuickORM::Link objects connecting this table to others.

indexes

Arrayref of index definitions.

primary_key

Arrayref of column names making up the primary key.

PUBLIC METHODS

$bool = $table->is_view()

True if this source is a view. Always false for a plain table.

$name = $table->name()

The schema (ORM) name for the table.

$name = $table->db_name()

The name of the table in the database.

@columns = $table->columns()

Get all column objects.

@names = $table->column_names()

Get all column names, sorted.

$col_or_undef = $table->column($name)

Get the column with the given name, or undef if it does not exist.

$new_table = $table->merge($other, %params)

Merge two table objects into a third.

$new_table = $table->clone(%params)

Create a copy of the table, with any attributes you wish to have changed in the copy.

QUERY SOURCE METHODS

These satisfy the DBIx::QuickORM::Role::Source interface.

$name = $table->source_db_moniker()

The table's database name, as used in SQL.

$name = $table->source_orm_name()

The table's schema (ORM) name.

$bool = $table->has_field($name)

True if the table has a column with the given name.

$list = $table->fields_to_fetch()

Arrayref of column names to fetch (omitting columns flagged omit).

$list = $table->fields_to_omit()

Arrayref of column names flagged to be omitted.

$list = $table->fields_list_all()

Arrayref of all column names.

$type_or_undef = $table->field_type($field)

The DBIx::QuickORM::Role::Type object for a field, or undef if the field has no type object.

$affinity = $table->field_affinity($field, $dialect)

The affinity for a field, optionally for a specific dialect.

PRIVATE METHODS

Internal accessor that fetches and clears the pending raw link definitions.

SOURCE

The source code repository for DBIx::QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See https://dev.perl.org/licenses/