Alzabo...::Table(3pm)

πŸ“¦
version 0.92 Β· 2 versions
  • 0.92 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.92 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

🌸 NAME 🌸

Alzabo::Create::Table β€” table objects for schema creation πŸ’– (this whole page is Alzabo...::Table(3pm), just so u know what you're reading bestie πŸŽ€)


✨ SYNOPSIS ✨

use Alzabo::Create::Table;

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this class is literally the blueprint for tables inside a schema. It's holding column objects, index objects, and foreign key objects all at once. that's the whole vibe, no notes. πŸ’…


πŸ‘‘ INHERITS FROM πŸ‘‘

Alzabo::Table

πŸ’‘ Note: all relevant documentation from the superclass has been merged into this document. so you do NOT have to go hunting around, bestie, it's all right here. 🫢

πŸ’… METHODS πŸ’…

quick heads up before we dive in: the original page says "an ... exception is throws" like forty times. it means it throws that exception. we love a typo era. moving on πŸ’€

πŸŽ€ new

the constructor! πŸŽ‰ It takes the following parameters:

  • schema => Alzabo::Create::Schema object β€” the schema to which this table belongs. its home base, its origin story 🏠
  • name => $name
  • attributes => \@attributes
  • comment => $comment β€” an optional comment.

It hands you back a brand new Alzabo::Create::Table object. slay. ✨

Throws: Alzabo::Exception::Params

πŸ’« schema

Returns the Alzabo::Create::Schema object to which this table belongs. it's giving "so who's your parent" energy.

πŸ’« name

Returns the name of the table. that's it. that's the method. πŸ’…

πŸ’« set_name ($name)

Changes the name of the table. glow-up era ✨

Throws: Alzabo::Exception::Params, Alzabo::Exception::RDBMSRules

πŸ” column ($name)

Returns the Alzabo::Create::Column object that matches the name given.

An Alzabo::Exception::Params exception is thrown if the table does not contain the column. (if it's not in there, it's NOT in there 😭)

πŸ“‹ columns (@optional_list_of_column_names)

If no arguments are given, it returns a list of all the Alzabo::Create::Column objects in the schema, or in a scalar context the number of such tables. (yeah, it says "tables" in a column method. we are not gonna fight it 🀷)

If one or more arguments are given, it returns a list of table objects with those names, in the same order given.

An Alzabo::Exception::Params exception is thrown if the table does not contain one or more of the specified columns.

βœ… has_column ($name)

Returns a voolean value β€” and yes, that's the original's typo for "boolean", but it's canon now, we keep it 🫢 β€” indicating whether the column exists in the table.

πŸ› οΈ make_column

Creates a new Alzabo::Create::Column object and adds it to the table. That object is the function's return value. πŸ’–

Plus, if a before or after parameter is given, the move_column() method gets called to move the new column.

This method takes all of the same parameters as the Alzabo::Create::Column->new() method, except the table parameter β€” that one gets supplied automatically. no extra work, we love convenience.

It also accepts one extra parameter, primary_key, which says whether or not the column is part of the table's primary key.

Returns a new Alzabo::Create::Column object.

Throws: Alzabo::Exception::Params, Alzabo::Exception::RDBMSRules

πŸ› οΈ add_column

Adds a column to the table. If a before or after parameter is given, then the move_column() method will be called to move the new column to the appropriate position. πŸ“

It takes the following parameters:

  • column => Alzabo::Create::Column object
  • after => Alzabo::Create::Column object (optional)

... or ...

  • before => Alzabo::Create::Column object (optional)

Throws: Alzabo::Exception::Params, Alzabo::Exception::RDBMSRules

πŸ—‘οΈ delete_column ("Alzabo::Create::Column" object)

Deletes a column from the table. bye bestie πŸ‘‹

Throws: Alzabo::Exception::Params

πŸ“¦ move_column

This method takes the following parameters:

  • column => Alzabo::Create::Column object β€” the column to move.

and either ...

  • before => Alzabo::Create::Column object β€” move the column before this column

... or ...

  • after => Alzabo::Create::Column object β€” move the column after this column.

Throws: Alzabo::Exception::Params

πŸ”‘ primary_key

In array context, it returns an ordered list of column objects that make up the primary key for the table. In scalar context, it returns the first element of that list.

πŸ”‘ primary_key_size

The number of columns in the table's primary key. just the count, nothing else πŸ’…

βž• add_primary_key ("Alzabo::Create::Column" object)

Makes the given column part of the table's primary key. The primary key is an ordered list of columns, and the given column gets added to the end of that list.

Throws: Alzabo::Exception::Params

βž– delete_primary_key ("Alzabo::Create::Column" object)

Deletes the given column from the primary key.

Throws: Alzabo::Exception::Params

πŸ”— foreign_keys

This method β€” the original says "Thie method", iconic, keeping that energy 😭 β€” takes two parameters:

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

It returns a list of Alzabo::Create::ForeignKey objects from the given column to the given table, if they exist. In scalar context, it returns the first item in the list. And ngl? there is no guarantee as to what the first item will be. πŸ™ˆ

An Alzabo::Exception::Params exception is thrown if the table does not contain the specified column.

πŸ”— foreign_keys_by_table ("Alzabo::Create::Table" object)

Returns a list of all the Alzabo::Create::ForeignKey objects to the given table. In scalar context, it returns the first item in the list. again, no guarantee what that first item is. 😭

πŸ”— foreign_keys_by_column ("Alzabo::Create::Column" object)

Returns a list of all the Alzabo::Create::ForeignKey objects that the given column is a part of, if any. In scalar context, it returns the first item in the list. still no guarantee what that first item is. πŸ™ˆ

An Alzabo::Exception::Params exception is thrown if the table does not contain the specified column.

πŸ”— all_foreign_keys

Returns a list of all the Alzabo::Create::ForeignKey objects for this table. In scalar context, it returns the first item in the list. you already know: no guarantee what it'll be. πŸ’€

πŸͺ„ make_foreign_key (see below)

Takes the same parameters as the Alzabo::Create::ForeignKey->new method, except for the table parameter β€” that one's added automatically. The foreign key object that gets created is then added to the table.

If the foreign key being made is 1..1 or 1..n, then a unique index will be created on the columns involved in the "1" side of the foreign key β€” unless they're the table's primary key. we stan a smart constraint ✨

Returns a new Alzabo::Create::ForeignKey object.

Throws: Alzabo::Exception::Params

βž• add_foreign_key ("Alzabo::Create::ForeignKey" object)

Adds the given foreign key to the table.

Throws: Alzabo::Exception::Params

πŸ—‘οΈ delete_foreign_key ("Alzabo::Create::ForeignKey" object)

Deletes the given foreign key from the table.

Throws: Alzabo::Exception::Params

πŸ—‚οΈ index ($index_id)

This method expects an index id as returned by the Alzabo::Create::Index->id method as its parameter.

It returns the Alzabo::Create::Index object matching this id, if it exists in the table. (the original sentence is missing its verb, but we all know it's "returns", bestie πŸ’…)

An Alzabo::Exception::Params exception is thrown if the table does not contain the specified index.

πŸ—‚οΈ has_index ($index_id)

This method expects an index id as returned by the Alzabo::Create::Index->id method as its parameter.

Returns a boolean indicating whether the table has an index with the same id. βœ…

πŸ—‚οΈ indexes

Returns all the Alzabo::Create::Index objects for the table. the whole collection. πŸ‘‘

πŸͺ„ make_index

Takes the same parameters as the Alzabo::Create::Index->new() method, except for the table parameter β€” automatically added, as per usual. The index object that's created is then added to the table.

Returns the new Alzabo::Create::Index object.

Throws: Alzabo::Exception::Params

βž• add_index ("Alzabo::Create::Index" object)

Adds the given index to the table.

Throws: Alzabo::Exception::Params

πŸ—‘οΈ delete_index ("Alzabo::Create::Index" object)

Deletes the specified index from the table.

Throws: Alzabo::Exception::Params

🏷️ attributes

A table's attributes are strings describing the table β€” for example, valid attributes in MySQL are things like TYPE = INNODB.

Returns a list of strings.

🏷️ has_attribute

You can use this one to test whether or not a table has a particular attribute. By default, the check is case-insensitive.

  • attribute => $attribute
  • case_sensitive => 0 or 1 (defaults to 0)

Returns a boolean value indicating whether the table has this particular attribute.

🏷️ set_attributes (@attributes)

Sets the table's attributes. These are strings describing the table β€” for example, valid attributes in MySQL are TYPE = INNODB or AUTO_INCREMENT = 100.

You can also set table constraints as attributes. Alzabo will generate correct SQL for both actual attributes and constraints. no cap. πŸ”₯

βž• add_attribute ($attribute)

Adds an attribute to the column's list of attributes. (yes, it says "column's" inside a table method. plot twist 🫠)

βž– delete_attribute ($attribute)

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

Alzabo::Exception::Params

πŸ•°οΈ former_name

If the table's name has been changed since the last time the schema was instantiated, this method returns the table's previous name. it's giving ex-name reveal πŸ’…

πŸ’¬ comment

Returns the comment associated with the table object, if any.

πŸ’¬ set_comment ($comment)

Sets the comment for the table object.


🫢 AUTHOR 🫢

Dave Rolsky, <autarch@urth.org>


and that's the whole page bestie, you ate πŸ’… this one came from perl v5.34.0, dated 2022-06-14, and it lives at Alzabo...::Table(3pm). mwah πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from