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


Alzabo documentation  | view source Contained in the Alzabo distribution.

Index


NAME

Top

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

SYNOPSIS

Top

  use Alzabo::Create::Column;

DESCRIPTION

Top

This object represents a column. It holds data specific to a column. Additional data is held in a Alzabo::Create::ColumnDefinition|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

Top

Alzabo::Column

METHODS

Top

new

The constructor accepts the following 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)
* default_is_raw => $boolean (optional)

If "default_is_raw" is true, then it will not be quoted when passed to the DBMS in SQL statements. This should be used to allow a default which is a function, like NOW().

* attributes => \@attributes (optional)
* length => $length (optional)
* precision => $precision (optional)

One of either ...

* type => $type

... or ...

* definition => Alzabo::Create::ColumnDefinition object
* comment => $comment

An optional comment.

It returns a new Alzabo::Create::Column object.

Throws: Alzabo::Exception::Params|Alzabo::Exceptions

alter

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

It takes the following parameters:

* type => $type
* length => $length (optional)
* precision => $precision (optional)

Throws: Alzabo::Exception::Params|Alzabo::Exceptions, Alzabo::Exception::RDBMSRules|Alzabo::Exceptions

set_type ($type)

Sets the column's type.

Throws: Alzabo::Exception::Params|Alzabo::Exceptions, Alzabo::Exception::RDBMSRules|Alzabo::Exceptions

set_table (Alzabo::Create::Table object)

Sets the Alzabo::Create::Table|Alzabo::Create::Table object in which this column is located.

Throws: Alzabo::Exception::Params|Alzabo::Exceptions

set_name ($name)

Sets the column's name (a string).

Throws: Alzabo::Exception::Params|Alzabo::Exceptions, Alzabo::Exception::RDBMSRules|Alzabo::Exceptions

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|Alzabo::Exceptions

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").

Throws: Alzabo::Exception::RDBMSRules|Alzabo::Exceptions

add_attribute ($attribute)

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

Throws: Alzabo::Exception::RDBMSRules|Alzabo::Exceptions

delete_attribute ($attribute)

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

Throws: Throws: Alzabo::Exception::Params|Alzabo::Exceptions, Alzabo::Exception::RDBMSRules|Alzabo::Exceptions

set_default ($default)

Sets the column's default value.

set_length

This method takes the following parameters:

* length => $length
* precision => $precision (optional)

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

Throws: Alzabo::Exception::RDBMSRules|Alzabo::Exceptions

set_sequenced (0 or 1)

Sets the value of the column's sequenced attribute.

Throws: Alzabo::Exception::Params|Alzabo::Exceptions, Alzabo::Exception::RDBMSRules|Alzabo::Exceptions

set_definition (Alzabo::Create::ColumnDefinition object)

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

former_name

If the column's name has been changed since the last time the schema was instantiated, this method returns the column's previous name.

set_comment ($comment)

Set the comment for the column object.


Alzabo documentation  | view source Contained in the Alzabo distribution.