NAME

DBIO::Firebird::Type - Firebird type-system mapping (introspection + DDL directions)

VERSION

version 0.900004

DESCRIPTION

Single home for the Firebird type system. Three mappings used to live in three modules pulling in different directions:

Centralizing them removes a class of bug: introspection used to fold the size into the type string ("decimal(18,6)") and set a separate size field, so Diff::Table emitted the size twice ("decimal(18,6)(18,6)"). The introspection mapping here returns the bare type; size is carried separately in the model and rendered via "render_size".

METHODS

sql_type_from_rdb

my $type = sql_type_from_rdb($field_type, $field_sub_type, $character_set_id);

Maps the rdb$fields triple rdb$field_type, rdb$field_sub_type and rdb$character_set_id to a bare SQL type name (e.g. 'integer', 'numeric', 'varbinary'). The sub type separates numeric (1) and decimal (2) from the integer type that stores them, and blob sub_type text (1) from binary blob; the character set OCTETS turns char/varchar into binary/varbinary. Unknown types fall back to 'varchar'.

ddl_type_from_info

my $ddl_type = ddl_type_from_info($column_info);

Maps a DBIO / SQL::Translator column_info hashref to a concrete Firebird DDL type string (e.g. 'INTEGER', 'VARCHAR(255)'). Size-parameterizable types (varchar/nvarchar, char/nchar, numeric/decimal) render $info->{size} via "render_size", falling back to a sane default only when size is undef.

The aliases of DBIO::Schema::Type arrive as Firebird has them: character and character varying keep their size (CHAR(n), VARCHAR(n); the bare keyword used to be written without it, and CHAR alone is CHAR(1)), binary/varbinary likewise, double is DOUBLE PRECISION (DOUBLE alone is a syntax error), real likewise, as the core canon has it (not Firebird's own REAL, a 4-byte FLOAT), tinyint is SMALLINT, bool BOOLEAN, string is VARCHAR(n) with a size and the text type BLOB SUB_TYPE TEXT without one (in the core canon a string is text), mediumtext/longtext BLOB SUB_TYPE TEXT, timestamptz TIMESTAMP WITH TIME ZONE (a column of that type is refused by "install_ddl" in DBIO::Firebird::DDL, which the DBD cannot read or write). A name that is none of these is written upper-cased and the server judges it. bit and enum are not mapped here: "install_ddl" in DBIO::Firebird::DDL refuses them.

boolean becomes BOOLEAN, the native type of Firebird 3 and later. Firebird 3 is the minimum version this driver supports; Firebird 2.5, which has no BOOLEAN, is not supported. The rules of the Diff against a live server are measured on Firebird 5.0.4 only.

is_boolean_type

is_boolean_type($data_type);

True when a column of this data_type is written as BOOLEAN (boolean and its alias bool, any case). The one question the guards of the driver ask (the default literal in DBIO::Firebird::DDL, the translation of 'true' / 'false' in DBIO::Firebird::Storage::InterBase): they ask about the mapped type, not about one spelling of it, so an alias cannot walk past them.

is_binary_type

is_binary_type($data_type);

True when a column of this data_type holds bytes, not text: blob, bytea, binary and varbinary (the types ddl_type_from_info writes as BLOB, BINARY(n) and VARBINARY(n)). The storage does not flag the values of such a column as UTF-8 text.

is_numeric_type

is_numeric_type($data_type);

True when a column of this data_type is written as an integer, a NUMERIC / DECIMAL or a floating point type (integer, int, smallint, bigint, tinyint, serial, numeric, decimal, float, double, real, ...). The storage refuses a bound value that is no number for such a column.

lob_kind

lob_kind($data_type, $size);   # 'text', 'binary' or undef

'text' for a column written as BLOB SUB_TYPE TEXT (text, clob, mediumtext, longtext, a string without a size), 'binary' for a BLOB (blob, bytea), undef for everything else. The comparison of a BLOB with a bound value is written for these two kinds.

render_size

my $suffix = render_size($size);   # "(255)", "(10,2)", or ""

Renders a model size field as a SQL size suffix. A scalar yields "(n)", an arrayref yields "(p,s)", and undef yields the empty string.

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.