NAME

DBIO::Schema::Type - portable base-type vocabulary for multi-engine schemas

VERSION

version 0.900004

METHODS

base_types

my @types = DBIO::Schema::Type::base_types;

Returns the list of portable base-type names (integer, text, char, boolean, numeric, double, blob, timestamp) that every engine alias in %ALIAS normalizes down to.

is_base_type

if (DBIO::Schema::Type::is_base_type($name)) { ... }

Returns true if $name is already one of "base_types" (not an alias that still needs "normalize").

normalize

my $base = DBIO::Schema::Type::normalize($data_type);

Normalizes an engine-specific data_type string (e.g. varchar(255), INT) down to its portable "base_types" name. Strips a trailing (...) parameter list and lower-cases before the alias lookup. croaks on an undef type or one not present in %ALIAS.

canonical_column

my $col = DBIO::Schema::Type::canonical_column($name, $info);

Builds a canonical column hashref from a column name and a table_columns_info-shaped $info hashref (see "table_columns_info" in DBIO::Introspect::Base): column_name, base_type (via "normalize"), not_null, default and auto_increment, plus the size of the three base types that carry one:

char       size               the width
numeric    precision, scale   scale undefined when the size names one value
timestamp  size               the fractional-seconds precision

A timestamp has its size key only when a precision was declared -- 0 is one -- and a numeric its two keys only when its size names a value. A char always has the key, undefined when no width was declared. The other five base types carry no size: one declared on a column that normalizes to integer, text, boolean, double or blob is not read and not passed on.

The form of size in $info is read once and is the same form every base type consumes: a scalar names the single value the base type means (width for char, precision for numeric, fractional seconds for timestamp); an arrayref names them in order and any element past the last meaningful one is dropped; an empty arrayref names nothing and counts as absent. The drivers already settled on this reading on their own alias-named paths; centralising the form here means every driver stops repeating the same three-branch `ref()` check, and a ref (a list passed where the form wants a scalar) becomes a clear caller bug rather than a silent mangling into CHAR(ARRAY(0x...)) on the SQL side.

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.