Fey::Column(3)

NAME
Fey::Column - Represents a column

VERSION
version 0.44

SYNOPSIS
  my $column = Fey::Column->new( name              => 'user_id',
                                 type              => 'integer',
                                 is_auto_increment => 1,
                               );

DESCRIPTION
This class represents a column in a table.

METHODS
This class provides the following methods:

  Fey::Column->new()
This method constructs a new "Fey::Column" object. It takes the following parameters:

•   name - required

    The name of the column.

•   type - required

    The type of the column. This should be a string. Do not include modifiers like length or precision.

•   generic_type - optional

    This should be one of the following types:

    •   text

    •   blob

    •   integer

    •   float

    •   date

    •   datetime

    •   time

    •   boolean

    •   other

    This indicate a generic type for the column, which is intended to allow for a common description of column types across different DBMS platforms.

    If this parameter is not specified, then the constructor code will attempt to determine a reasonable value, defaulting to "other" if necessary.

•   length - optional

    The length of the column. This must be a positive integer.

•   precision - optional

    The precision of the column, for float-type columns. This must be an integer >= 0.

•   is_auto_increment - defaults to 0

    This indicates whether or not the column is auto-incremented.

•   is_nullable - defaults to 0

    A boolean indicating whether the column is nullable.

•   default - optional

    This must be either a scalar (including undef) or a "Fey::Literal" object. If a scalar is provided, it is turned into a "Fey::Literal" object via "Fey::Literal->new_from_scalar()".

  $column->name()

  $column->type()

  $column->generic_type()

  $column->length()

  $column->precision()

  $column->is_auto_increment()

  $column->is_nullable()

  $column->default()
Returns the specified attribute.

  $column->table()
Returns the "Fey::Table" object to which the column belongs, if any.

  $column->alias(%p)

  $column->alias($alias_name)
This method returns a new "Fey::Column::Alias" object based on the column. Any parameters passed to this method will be passed through to "Fey::Column::Alias->new()".

As a shortcut, if you pass a single argument to this method, it will be passed as the "alias_name" parameter to "Fey::Table::Column->new()".

  $column->is_alias()
Always returns false.

  $column->sql()

  $column->sql_with_alias()

  $column->sql_or_alias()
Returns the appropriate SQL snippet for the column.

  $column->id()
Returns a unique identifier for the column.

ROLES
This class does the Fey::Role::ColumnLike, Fey::Role::MakesAliasObjects, and Fey::Role::Named roles.

BUGS
See Fey for details on how to report bugs.

Bugs may be submitted at <https://github.com/ap/Fey/issues>.

SOURCE
The source code repository for Fey can be found at <https://github.com/ap/Fey>.

AUTHOR
Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE
This software is Copyright (c) 2011 - 2025 by Dave Rolsky.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)

The full text of the license can be found in the LICENSE file included with this distribution.