DBIx::SQLEngine::Driver::Trait::NoUnions - For databases without select unions
# Classes can import this behavior if they don't have native unions use DBIx::SQLEngine::Driver::Trait::NoUnions ':all'; # Implements a workaround for unavailable sql_union capability $rows = $sqldb->fetch_select_rows( union => [ { table => 'foo', columns => '*' }, { table => 'bar', columns => '*' }, ] );
This package supports SQL database servers which do natively provide a SQL select with unions. Instead, queries with unions are executed separately and their results combined.
You do not need to use this package directly; it is used internally by those driver subclasses which need it.
Note: this feature has been added recently, and the interface is subject to change.
Note: Because of the way DBIx::AnyDBD munges the inheritance tree, DBIx::SQLEngine subclasses can not reliably inherit from this package. To work around this, we export all of the methods into their namespace using Exporter and @EXPORT.
In addition we go through some effort to re-dispatch methods because we can't rely on SUPER and we don't want to require NEXT. This isn't too complicated, as we know the munged inheritance tree only uses single inheritance. See the source code for the _super_dispatch function that handles this.
The following methods are provided:
$sqldb->dbms_union_unsupported() : 1
Capability Limitation: This driver does not support native select unions.
$sqldb->fetch_select( %sql_clauses ) : $row_hashes $sqldb->fetch_select( %sql_clauses ) : ($row_hashes,$column_hashes)
Unless passed a "union" argument pair, simply calls the superclass method. Runs each of the provided queries separately and concatenates their results. Munges the keys used to turn rows into hashes, so that all results use the column names produced by the first of the queries.
$sqldb->fetch_select_rows( %sql_clauses ) : $row_arrays $sqldb->fetch_select_rows( %sql_clauses ) : ($row_arrays,$column_hashes)
Unless passed a "union" argument pair, simply calls the superclass method. Runs each of the provided queries separately and concatenates their results.
$sqldb->visit_select( $code_ref, %sql_clauses ) : @results $sqldb->visit_select( %sql_clauses, $code_ref ) : @results
To Do: This method doesn't yet munge the column names retrived by the later queries to match the first.
$sqldb->visit_select_rows( $code_ref, %sql_clauses ) : @results $sqldb->visit_select_rows( %sql_clauses, $code_ref ) : @results
Calls Carp::confess().
See DBIx::SQLEngine for the overall interface and developer documentation.
See DBIx::SQLEngine::Docs::ReadMe for general information about this distribution, including installation and license information.
To install DBIx::SQLEngine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::SQLEngine
CPAN shell
perl -MCPAN -e shell install DBIx::SQLEngine
For more information on module installation, please visit the detailed CPAN module installation guide.