Alzabo...::Index(3pm)
β¨ NAME β¨
bestie, meet Alzabo::Create::Index β the little object that handles Index objects for schema creation. it's giving "i organize your columns so your database stops being chaotic" π
(also, fun fact: this page lives in the User Contributed Perl Documentation corner of the world, so if you see Alzabo...::Index(3pm) floating around, that's just the page title being shy about its full name.)
πΈ SYNOPSIS πΈ
use Alzabo::Create::Index;
that's it. that's the whole vibe check. load it and go π¦
π DESCRIPTION π
okay so this object? it represents an index on a table. and an index is literally just a list of columns plus, optionally, a prefix for each column.
what's a prefix, you ask? it says "hey, only index the first X characters of this column." some RDBMS's don't even have a concept of index prefixes β like, they simply don't do that. and not every column type is likely to allow prefixes either, though honestly that depends entirely on which RDBMS you're running. no cap.
also super important: the order of the columns is significant. do not come for the ordering. the ordering is the main character here. π
π INHERITS FROM π
Alzabo::Index
heads up bestie: all relevant documentation from the superclass has been merged into this document. so you don't gotta go hunting. everything's already here. π«Ά
π METHODS π
new
the constructor, aka the glow-up moment. it takes these parameters:
table=>Alzabo::Create::Tableobject β the table that this index is indexing. yes, the index needs to know what it's indexing. iconic behavior.columns=> [Alzabo::Create::Columnobject, .. ] β plain list of column objects.columns=> [ { column =>Alzabo::Create::Columnobject, prefix =>$prefix}, repeat as needed ... ] β the fancy version. this parameter tells you which columns are being indexed, and it can be either an array reference of column objects, or an array reference of hash references where each hash has a key calledcolumnand one calledprefix.
the prefix key is optional. she's not required, she's just extra. π
unique=>$booleanβ says whether this is a unique index or not.fulltext=>$booleanβ says whether this is a fulltext index or not.function=>$stringβ use this to create a function index, where supported. the value should be the full function, with column names and everything, like"LCASE( username )".
and bestie, listen: the columns parameter should include all the columns used in the function. don't skip that part. π
returns a shiny new Alzabo::Create::Index object β¨
Throws: Alzabo::Exception::Params, Alzabo::Exception::RDBMSRules
table
returns the Alzabo::Create::Table object that this index belongs to. it's giving "who's your parent" energy.
columns
returns an ordered list of the Alzabo::Create::Column objects that are being indexed. ordered!! the order MATTERS, remember?? π₯
add_column
adds a column to the index. welcome to the group chat, new column π
this method takes these parameters:
column=>Alzabo::Create::Columnobjectprefix=>$prefix(optional)
Throws: Alzabo::Exception::Params, Alzabo::Exception::RDBMSRules
delete_column (Alzabo::Create::Column object)
deletes the given column from the index. sorry bestie, you're out of the group chat π
Throws: Alzabo::Exception::Params, Alzabo::Exception::RDBMSRules
prefix (Alzabo::Create::Column object)
okay so real talk about column prefixes. to the best of my knowledge, this is a MySQL specific concept, which means you literally cannot set it when you're using an RDBMSRules module for a different RDBMS. it just won't go.
BUT. it's important enough for MySQL that the functionality has to be here, so here it is. a prefix lets you specify that the index should only look at a certain portion of a field β specifically, the first N characters. and this prefix is required to index any sort of BLOB column in MySQL. so like, not optional in that case. not even a little. π
this method returns the prefix for the column in the index. and if there's no prefix for this column in the index? it returns undef. that's it, that's the answer. π€·
set_prefix
sets the prefix. this method takes these parameters:
column=>Alzabo::Create::Columnobjectprefix=>$prefix
Throws: Alzabo::Exception::Params, Alzabo::Exception::RDBMSRules
unique
returns a boolean value telling you whether the index is a unique index. yes or no, slay or nay. π
set_unique ($boolean)
sets whether or not the index is a unique index. you're the one in charge now, bestie. π
fulltext
returns a boolean value telling you whether the index is a fulltext index.
set_fulltext ($boolean)
sets whether or not the index is a fulltext index.
Throws: Alzabo::Exception::Params, Alzabo::Exception::RDBMSRules
register_column_name_change
this method takes these parameters:
column=>Alzabo::Create::Columnobject β the column, with the new name already set. (key detail, don't miss it β¨)old_name=>$old_name
this method gets called by the table object that owns the index whenever a column name changes. so like, it's internal plumbing. you should never need to call this yourself. hands off, bestie. π
Throws: Alzabo::Exception::Params
id
the id is generated from the table, column and prefix information for the index. super useful as a canonical name for a hash key, for example. iykyk π
returns a string β that's the id which uniquely identifies the index in this schema. no duplicates, no confusion, periodt.
π AUTHOR π
Dave Rolsky, <autarch@urth.org> β king behavior, thank you for your service π«‘
and that's a wrap on Alzabo...::Index(3pm), brought to you by the User Contributed Perl Documentation, perl v5.34.0, dated 2022-06-14. go forth and index responsibly, bestie πβ¨π
π¦ where this page comes from
- debian bookworm: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms