NAME

DBIO::MySQL::Result - MySQL/MariaDB-specific Result component for DBIO

VERSION

version 0.900004

DESCRIPTION

DBIO::MySQL::Result is a DBIO Result component that adds MySQL/MariaDB-native metadata to a result class: the table engine, character set, collation, and custom indexes. It is the counterpart to DBIO::PostgreSQL::Result / DBIO::SQLite::Result and is read by DBIO::MySQL::DDL when generating install DDL.

Load it with:

package MyApp::DB::Result::User;
use base 'DBIO::Core';
__PACKAGE__->load_components('MySQL::Result');

__PACKAGE__->table('users');
__PACKAGE__->mysql_engine('InnoDB');
__PACKAGE__->mysql_charset('utf8mb4');
__PACKAGE__->mysql_collate('utf8mb4_unicode_ci');

# CREATE INDEX idx_users_name ON users (name);
__PACKAGE__->mysql_index('idx_users_name' => {
    columns => ['name'],
});

# CREATE FULLTEXT INDEX idx_users_fulltext ON users (bio);
__PACKAGE__->mysql_index('idx_users_fulltext' => {
    using   => 'FULLTEXT',
    columns => ['bio'],
});

METHODS

mysql_engine

__PACKAGE__->mysql_engine('InnoDB');
my $e = $class->mysql_engine;

Get or set the MySQL storage engine for this result class's table. Defaults to InnoDB in the generated DDL when unset.

mysql_charset

__PACKAGE__->mysql_charset('utf8mb4');
my $c = $class->mysql_charset;

Get or set the default character set for this table. Defaults to utf8mb4 in generated DDL when unset.

mysql_collate

__PACKAGE__->mysql_collate('utf8mb4_unicode_ci');
my $c = $class->mysql_collate;

Get or set the default collation for this table. Defaults to utf8mb4_unicode_ci in generated DDL when unset.

mysql_index

# CREATE INDEX idx_users_name ON users (name);
__PACKAGE__->mysql_index('idx_users_name' => {
    columns => ['name'],
});
# CREATE FULLTEXT INDEX idx_users_fulltext ON users (bio);
__PACKAGE__->mysql_index('idx_users_fulltext' => {
    using   => 'FULLTEXT',
    columns => ['bio'],
});

Get or set the definition for a named MySQL index. The definition hashref accepts:

columns - ArrayRef of column names
unique - set to true for a UNIQUE index
using - BTREE, HASH, FULLTEXT or SPATIAL, matched case-insensitively and always rendered uppercase. The four are not rendered alike, because MySQL does not treat them alike: BTREE and HASH are index types and render as a trailing USING clause (CREATE INDEX idx ON t (c) USING BTREE), while FULLTEXT and SPATIAL are index classes and render in front of INDEX (CREATE FULLTEXT INDEX idx ON t (c)) -- the server rejects an index type on those. Any other value, RTREE included, is refused with an exception naming the index when the DDL is generated, rather than passed through to fail at the server.

mysql_indexes

my $all = $class->mysql_indexes;

Returns a copy of all index definitions registered on this result class.

SEE ALSO

AUTHOR

DBIO & DBIx::Class Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.