NAME
DBIO::Oracle::Type - Oracle type mapping utilities
VERSION
version 0.900007
DESCRIPTION
Consolidated Oracle type mapping logic used by DBIO::Oracle::Storage, DBIO::Oracle::DDL, DBIO::Oracle::Introspect::Columns, and DBIO::Oracle::Diff::Column.
METHODS
is_lob_type
$self->is_lob_type($data_type)
Returns true if the given data-type string names a LOB type. Operates on the plain data_type string carried by a bind's sqlt_datatype (e.g. 'clob', 'blob', 'text'), matching the semantics of the upstream "_is_lob_type" in DBIx::Class::Storage::DBI. The leading $self is ignored; it exists so the function can be called as a method via the storage wrapper.
is_text_lob_type
$self->is_text_lob_type($data_type)
Returns true if the data-type string names a text LOB (CLOB/NCLOB), false for a binary LOB. Mirrors "_is_text_lob_type" in DBIx::Class::Storage::DBI.
oracle_lob_bind_attrs
DBIO::Oracle::Type::oracle_lob_bind_attrs($is_text)
Returns the bind attributes for a LOB bind (ora_type => ORA_BLOB or ORA_CLOB).
render_default_value
DBIO::Oracle::Type::render_default_value($default_value)
Renders a column's default_value as the SQL that follows DEFAULT, the one place that decides it. Used by DBIO::Oracle::DDL, DBIO::Oracle::Diff::Table and DBIO::Oracle::Diff::Column, and by the comparison key of the latter, so that what is compared is what is emitted.
undef--undef, there is no default.a scalar reference -- the text it points to, verbatim: an expression such as
SYSDATEor1 + 1.a plain value that is a canonical decimal number (
0,-3,0.5,12) -- unquoted, the way DBIO::Oracle::Introspect::Columns reads a numeric default back. Only the canonical spelling qualifies, so that rendering never changes the value:'007'and'1.50'stay strings, since a bare007or1.50would reach a character column as7and1.5.any other plain value -- a SQL string literal with the apostrophe doubled:
it'sbecomes'it''s'.
normalize_type
DBIO::Oracle::Type::normalize_type($type)
Normalizes an Oracle data type string for comparison (uppercase, collapse whitespace).
map_dbd_type_to_dbio
DBIO::Oracle::Type::map_dbd_type_to_dbio($data_type, %args)
Maps an Oracle data type string (from ALL_TAB_COLUMNS) to a DBIO canonical type name. %args may include data_length, char_length, char_used, data_precision, data_scale and nchar_size_factor for UTF-16 correction.
Returns a hashref with data_type and, where applicable, size.
An Oracle DATE is date, BINARY_FLOAT and BINARY_DOUBLE are binary_float and binary_double (size dropped): they are not mapped to datetime, real and double precision, since a DATE read as datetime would be written as TIMESTAMP and modified on every run. FLOAT is float with its binary precision (data_precision) as the size, FLOAT(126) and a FLOAT without precision, which the dictionary cannot tell apart, being float without a size. The sizes of VARCHAR2, NVARCHAR2, NCHAR and TIMESTAMP(n) are kept (TIMESTAMP(6), the default, carries none); TIMESTAMP(n) WITH LOCAL TIME ZONE is its own type, timestamp with local time zone, with the same size rule, and is written back as such; NUMBER without precision is numeric. A VARCHAR2 or CHAR declared with character semantics (char_used 'C') has the size "20 CHAR", a string that "map_dbio_type_to_oracle" writes as VARCHAR2(20 CHAR); a byte one keeps the plain number. INTEGER/SMALLINT (the dictionary holds a scale of 0 and no precision) are integer, and only those: NUMBER(38) and NUMBER(38,0) are numeric with the size [38, 0].
map_dbio_type_to_oracle
DBIO::Oracle::Type::map_dbio_type_to_oracle($dbio_type, %args)
Maps a DBIO canonical type name to an Oracle DDL type string. %args may include size for VARCHAR2(n), NVARCHAR2(n), NCHAR(n), TIMESTAMP(n) and NUMBER(p,s). A size is written as given, so '20 CHAR' gives VARCHAR2(20 CHAR). float is FLOAT or FLOAT(n) (FLOAT being FLOAT(126)); real is BINARY_FLOAT, double precision and double (the portable base type, which Oracle has not under that name) are BINARY_DOUBLE. A float size is a whole number from 1 to 126; anything else throws. NCHAR and NVARCHAR2 are of character semantics always, so '5 CHAR' is written as NCHAR(5). A size of another type is written as given, RAW(16) included. nvarchar is NVARCHAR2. An interval year to month takes its year precision as the size (INTERVAL YEAR(3) TO MONTH), an interval day to second [day, second] (INTERVAL DAY(3) TO SECOND(4)). A scale of undef in a numeric size is left out (NUMBER(10)).
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.