SQL::Tr...::Index(3)
π SQL::Translator::Schema::Index(3) β the index object, but make it make sense
okay bestie, welcome to the User Contributed Perl Documentation for SQL::Tr...::Index(3) β yes the header is abbreviated like that, no we're not gonna fight it. This is the manual page for SQL::Translator::Schema::Index, and by the end of this you'll know it intimately. π«Ά
β¨ NAME β¨
SQL::Translator::Schema::Index β the SQL::Translator index object, aka the little guy that tells your database "hey, look here first". π
πΈ SYNOPSIS πΈ
like, here's the whole vibe in one go:
use SQL::Translator::Schema::Index;
my $index = SQL::Translator::Schema::Index->new(
name => 'foo',
fields => [ id ],
type => 'unique',
);
that's it, that's the whole entrance. main character energy fr. β¨
π¦ DESCRIPTION π¦
SQL::Translator::Schema::Index is the index object. that's the description. it's giving concise. π
but ALSO, important lore: primary and unique keys are table constraints, not indices. so don't come for this class with your primary key drama, it's not that kind of party. π«
π METHODS π
π new
the object constructor. makes a brand new index out of thin air, iconic behaviour honestly.
my $schema = SQL::Translator::Schema::Index->new;
(yes the variable's called $schema, that's literally what the original says, we don't ask questions, we just copy it exactly π)
π fields
gets and sets the fields the index is on. it accepts a string, a list, or an arrayref; it returns an array or an array reference. and here's the slay part β it uniques the field names and keeps them in order by the first occurrence of a field name, so no dupes, no chaos, just tidy ordered field names. π§
look at all the ways you can feed it:
$index->fields('id');
$index->fields('id', 'name');
$index->fields( 'id, name' );
$index->fields( [ 'id', 'name' ] );
$index->fields( qw[ id name ] );
$index->fields(id => { name => 'name', order_by => 'ASC NULLS LAST' });
my @fields = $index->fields;
six whole flavours. choose your fighter. π₯
π is_valid
determines whether the index is valid or not. that's it. vibe check in method form.
my $ok = $index->is_valid;
returns your answer, no cap.
π name
get or set the index's name. yes it's a getter and a setter, it's versatile like that.
my $name = $index->name('foo');
π options
get or set the index's options β like using or where for PG, iykyk. returns an array or array reference. π
my @options = $index->options;
π table
get or set the index's table object. the index's emotional support table, if you will.
my $table = $index->table;
π type
get or set the index's type.
my $type = $index->type('unique');
get or set the index's type. (yes, the original says it twice, and honestly? it is worth repeating. π)
okay so the actual tea: currently there are only four acceptable types: UNIQUE, NORMAL, FULL_TEXT, and SPATIAL. the latter two might be MySQL-specific, just so you know. π
and here's the cute detail: both lowercase and uppercase types are acceptable input, BUT this method returns the type in uppercase. it normalises you. it fixes your posture. it says "we're doing UNIQUE today, not unique." periodt. π
π equals
determines if this index is the same as another. a true comparison girlie.
my $isIdentical = $index1->equals( $index2 );
π AUTHOR π
Ken Youens-Clark <kclark@cpan.org>. absolute legend, we stan. π«Ά
and that's the whole page, bestie! π this little masterpiece is perl v5.42.0, dated 2024-12-12, filed under SQL::Tr...::Index(3) β go forth and index responsibly, mwah ππΈ
π¦ where this page comes from
- opensuse-leap 16.0: perl-SQL-Translator 1.660.0-bp160.1.11 Β· (Artistic-1.0 OR GPL-1.0-or-later) AND GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms