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

NAME

Alzabo::Create::Column - Column objects for use in schema creation

SYNOPSIS

  use Alzabo::Create::Column;

DESCRIPTION

This object represents a column. It holds data specific to a column. Additional data is held in a Alzabo::Create::ColumnDefinition object, which is used to allow two columns to share a type (which is good when two columns in different tables are related as it means that if the type of one is changed, the other is also.)

INHERITS FROM

Alzabo::Column

METHODS

new

Parameters

  • table => Alzabo::Create::Table object

  • name => $name

  • nullable => 0 or 1 (optional)

    Defaults to false.

  • sequenced => 0 or 1 (optional)

    Defaults to false.

  • default => $default (optional)

  • attributes => \@attributes (optional)

  • length => $length (optional)

  • precision => $precision (optional)

    One of either ...

  • type => $type

    ... or ...

  • definition => Alzabo::Create::ColumnDefinition object

Returns

A new Alzabo::Create::Column object.

Throws

Alzabo::Exception::Params

alter

This method allows you to change a column's type, length, and precision as a single operation and should be instead of calling set_type followed by set_length.

Parameters

  • type => $type

  • length => $length (optional)

  • precision => $precision (optional)

set_type ($type)

Sets the column's type.

set_table (Alzabo::Create::Table object)

Returns/sets the Alzabo::Create::Table object in which this column is located.

set_name ($name)

Returns/sets the column's name (a string).

set_nullable (0 or 1)

Sets the nullability of the column (this determines whether nulls are allowed in the column or not). Must be 0 or 1.

Throws

Alzabo::Exception::Params

set_attributes (@attributes)

Sets the column's attributes. These are strings describing the column (for example, valid attributes in MySQL are 'PRIMARY KEY' or 'AUTO_INCREMENT').

add_attribute ($attribute)

Add an attribute to the column's list of attributes.

delete_attribute ($attribute)

Delete the given attribute from the column's list of attributes.

Throws

Alzabo::Exception::Params

set_default ($default)

Sets the column's default value.

set_length

Parameters

  • length => $length

  • precision => $precision (optional)

Sets the column's length and precision. The precision parameter is optional (though some column types may require it if the length is set).

set_sequenced (0 or 1)

Sets the value of the column's sequenced attribute.

Throws

Alzabo::Exception::Params

set_definition (Alzabo::Create::ColumnDefinition object)

Sets the Alzabo::Create::ColumnDefinition object which holds this column's type information.