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.
- links
-
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. The other table provides the ORM column names; columns in this table (typically introspected and keyed by database name) are re-keyed onto those ORM names when they refer to the same database column, and the primary key is translated to ORM names, so the merged table is uniformly ORM-keyed.
- $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. Accepts either the column's ORM name or its database name.
- $db_name = $table->field_db_name($name)
-
The database column name for a field. Accepts either the ORM name or the database name and always returns the database name; an unknown name is returned unchanged.
- $orm_name = $table->field_orm_name($name)
-
The ORM column name for a field. Accepts either the ORM name or the database name and always returns the ORM name; an unknown name is returned unchanged.
- $bool = $table->field_is_generated($name)
-
True if the named field is a database-generated column (
GENERATED ALWAYS, stored or virtual). Accepts either the ORM or database name. Unknown names return false. - $bool = $table->source_has_aliases()
-
True when any column's ORM name differs from its database name. Cached. Lets callers skip name translation entirely when there is nothing to translate.
- $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
- $links = $table->_links()
-
Internal accessor that fetches and clears the pending raw link definitions.
- $col_or_undef = $table->_column($name)
-
Resolve a column object by either its ORM name or its database name.
- $map = $table->_db_to_orm()
-
Lazily-built hashref mapping each column's database name to its ORM name.
- $hashref = $table->_rekey_columns(\%columns, \%db_to_orm)
-
Return a copy of a columns hashref re-keyed so each column lands under the ORM name its database name maps to, falling back to the original key when there is no mapping.
- $hashref = $table->_retranslate_unique(\%unique, \%db_to_orm)
-
Return a copy of a unique-constraint hashref with each constraint's column list (and its
column_keykey) translated from database names to ORM names. - $arrayref = $table->_retranslate_indexes(\@indexes, \%db_to_orm)
-
Return a copy of an index list with each index's column list translated from database names to ORM names. Index entries may be arrayrefs of column names or hashrefs with a
columnsarrayref; other shapes pass through. - $bool = $table->_has_alias(\%db_to_orm)
-
True when any database name in the map differs from its ORM name, i.e. real aliasing is present.
SOURCE
The source code repository for DBIx::QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.
MAINTAINERS
AUTHORS
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.