NAME

DBIx::QuickORM::Dialect::PostgreSQL - PostgreSQL dialect for DBIx::QuickORM.

DESCRIPTION

The PostgreSQL-specific DBIx::QuickORM::Dialect. Introspects schema metadata from information_schema and the pg_* catalogs, drives transactions and savepoints via the DBD::Pg driver, supports async queries, and maps logical types (such as uuid) to native ones.

SYNOPSIS

my $dialect = DBIx::QuickORM::Dialect::PostgreSQL->new(dbh => $dbh, db_name => $name);

PUBLIC METHODS

$driver = $dialect->dbi_driver
$name = $dialect->dialect_name
$value = $dialect->quote_binary_data
$bool = $dialect->supports_returning_update
$bool = $dialect->supports_returning_insert
$bool = $dialect->supports_returning_delete
$bool = $dialect->async_supported
$bool = $dialect->async_cancel_supported

Feature flags and constants describing the PostgreSQL dialect.

$dialect->async_prepare_args

Bind args to issue a statement asynchronously.

$result = $dialect->async_result(%params)
$bool = $dialect->async_ready(%params)
$dialect->async_cancel(%params)

Async query lifecycle: collect a result, check readiness, or cancel.

$dialect->create_savepoint(%params)
$dialect->commit_savepoint(%params)
$dialect->rollback_savepoint(%params)

Savepoint control via DBD::Pg's native savepoint API. Each accepts an optional dbh parameter, defaulting to the dialect's own handle, and a savepoint name. Transaction control uses the inherited driver-level defaults.

$stype = $dialect->supports_type($type)

Returns the native type name for a supported logical type (e.g. uuid, jsonb), or nothing. Note: json requires PostgreSQL 9.2+ and jsonb 9.4+.

$version = $dialect->db_version

The PostgreSQL server version.

PUBLIC METHODS

$tables = $dialect->build_tables_from_db(%params)

Introspects all tables and views visible through the connection's search_path and returns a hashref of name to schema-table object. When the same table name exists in more than one schema on the path, the first match in search_path order wins, mirroring how PostgreSQL itself resolves unqualified names.

($pk, $unique, $links) = $dialect->build_table_keys_from_db($table, %params)

Introspects a table's primary key, unique keys, and foreign-key links from the pg_constraint catalog, scoped to the table's schema (the table_schema param, or the first search_path schema containing the table).

$columns = $dialect->build_columns_from_db($table, %params)

Introspects a table's columns from information_schema.columns, scoped to the table's schema (the table_schema param, or the first search_path schema containing the table), and returns a hashref of column name to column object.

PUBLIC METHODS

$indexes = $dialect->build_indexes_from_db($table, %params)

Introspects a table's indexes from the pg_index/pg_attribute catalogs, scoped to the table's schema (the table_schema param, or the first search_path schema containing the table), and returns an arrayref of index specs.

@triggers = $dialect->triggers_for_table($table)

Returns the insert/update/delete triggers on a table (across the search-path schemas), each as a { event => ..., body => $function_source } hashref, for volatile-column and has-triggers detection.

PRIVATE METHODS (schema introspection)

$by_table = $dialect->_all_triggers

All non-internal triggers keyed by table name, fetched once per dialect from the pg_catalog trigger/function catalogs (scoped to the search-path schemas and cached), so trigger detection adds a single query rather than one per table.

$by_schema = $dialect->_fetch_all_columns($schemas)
$by_schema = $dialect->_fetch_all_keys($schemas)
$by_schema = $dialect->_fetch_all_indexes($schemas)

Sweep all column, constraint, and index metadata for the given search-path schemas in one query each, returning a hashref of schema name to table name to the rows for that table (in the same shape the matching single-table _query_* helper returns).

$rows = $dialect->_query_columns($table, $tschema)
$specs = $dialect->_query_keys($table, $tschema)
$rows = $dialect->_query_indexes($table, $tschema)

Single-table fallbacks used when the per-table builders are called without pre-fetched rows. Each issues one query scoped to $table in $tschema.

PRIVATE METHODS

$schemas = $dialect->_search_path_schemas

Arrayref of schema names visible to the connection, in search_path priority order (the session's temp schema first when one exists), excluding the system catalogs.

$affinity_or_undef = $dialect->_affinity_from_native_type($type)

Resolve an affinity for a PostgreSQL type the generic driver catalog does not list. An enum stores and compares as its label string, so it maps to string; a domain inherits the affinity of the base type it wraps; otherwise the type's pg_type category decides. Only categories whose values DBD::Pg returns as a plain scalar are resolved -- numeric, boolean, string, date/time, range (and multirange), network, and geometric -- so string affinity's eq comparison is valid. Array, composite, and unknown/extension types are deliberately left unresolved (an array comes back as an arrayref, which no scalar affinity can compare), so they fall through to the warning that prompts a proper Type. Returns undef when the name is not a resolvable type, letting the caller warn and default. This keeps enum, range, inet, and geometric columns from tripping the "unrecognized type" warning during introspection.

($typtype, $typcategory, $base_name) = $dialect->_pg_type_info($type)

Look a type name up in pg_type, scoped to the connection's search-path schemas plus pg_catalog (where the built-in range/network/geometric types live). First match in search-path order wins, with pg_catalog last, so a user-defined type shadows a built-in of the same name, mirroring PostgreSQL's own unqualified-name resolution. Returns the type's typtype and typcategory plus, for a domain, the name of the base type it wraps. Returns an empty list when the name is not found.

$schema_or_undef = $dialect->_table_schema($table)

The first schema in search_path order that contains the named table, or undef when none does.

@idents = $dialect->_split_identifiers($list)

Split a comma-separated identifier list from pg_get_constraintdef output, stripping double quotes from each identifier.

$ident = $dialect->_unquote_identifier($ident)

Strip surrounding double quotes (and unescape doubled inner quotes) from an identifier captured out of pg_get_constraintdef output.

$table = $dialect->_referenced_table($target)

The (unquoted) table name from a REFERENCES target, dropping any schema qualification.

SOURCE

The source code repository for DBIx::QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.

MAINTAINERS

Chad Granum <exodist7@gmail.com>

AUTHORS

Chad Granum <exodist7@gmail.com>

COPYRIGHT

Copyright Chad Granum <exodist7@gmail.com>.

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

See https://dev.perl.org/licenses/