NAME

DBIO::Oracle::Identifier - Shorten Oracle identifiers to the 30-character limit

VERSION

version 0.900007

DESCRIPTION

Oracle (pre-12.2) limits identifiers to 30 bytes. Both the SQL-generation side (DBIO::Oracle::SQLMaker, at query time) and the deploy side (DBIO::Oracle::DDL, when emitting generated sequence and index names) need to fit names into that limit using the same algorithm, so a name generated at deploy time matches the name referenced at query time.

This module owns that single algorithm. Names already within the limit are returned unchanged; longer names are CamelCase-compressed (vowels trimmed if needed) and suffixed with a base36-encoded MD5 hash so the result is stable and collision-resistant.

ATTRIBUTES

%SCHEMA_MAP

local %DBIO::Oracle::Identifier::SCHEMA_MAP = (OWNX => 'DBIO_TMP_1_2_1');

The schemas "quote_table" and "quote_in" write are looked up here first: a schema with an entry is written as its value. Empty by default. It is how DBIO::Oracle::Deploy writes the install DDL of a diff with the temporary user of each foreign schema in place of the real one; set it with local, for the one call.

METHODS

shorten

my $name = DBIO::Oracle::Identifier::shorten($identifier);
my $name = DBIO::Oracle::Identifier::shorten($identifier, \@keywords);

Returns $identifier unchanged when it is 30 characters or fewer. Otherwise returns a deterministic shortened form. The optional \@keywords arrayref controls the human-readable prefix (defaults to the identifier itself).

quote

my $sql_name = DBIO::Oracle::Identifier::quote($name);

Returns $name as a double-quoted identifier, exactly as spelled (a double quote inside is doubled). The statements of the diff operations (DBIO::Oracle::Diff::Table, DBIO::Oracle::Diff::Index, DBIO::Oracle::Diff::ForeignKey) write every name this way, as DBIO::Oracle::DDL does, so that a table the diff creates is the one the install creates and the storage, which quotes with sql_quote_char ", finds it.

split_table

my ($schema, $table) = DBIO::Oracle::Identifier::split_table('OWNX.item');
# ('OWNX', 'item');  a bare 'item' gives (undef, 'item')

A table name that holds a dot is schema.table: the text before the first dot is the schema (on Oracle a user), the rest the table. Both halves keep their spelling. A name with an empty half (.t, x.) has no schema and is returned whole; DBIO::Oracle::DDL refuses such a name.

quote_table

my $sql_name = DBIO::Oracle::Identifier::quote_table('OWNX.item');
# "OWNX"."item"

Like "quote", for a table key that may be schema.table: schema and table are quoted separately, each exactly as spelled. A bare name is quoted as "quote" does.

quote_in

my $sql_name = DBIO::Oracle::Identifier::quote_in($table_key, $name);
# "OWNX"."name" for 'OWNX.item'; "name" for a bare table key

An object that lives in the schema of its table (an index, a sequence, a trigger): $name quoted, behind the schema of $table_key when it has one.

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.