NAME
SQL::Abstract::Plugin::TableAlias - automagical table aliasing
VERSION
Version 0.05
SYNOPSIS
use
SQL::Abstract;
my
$sql
= SQL::Abstract->new->plugin(
'+TableAlias'
);
my
(
$stmt
,
@bind
) =
$sql
->
select
({
select
=> [
qw/one two three/
, [
qw/four five/
], [
qw/six seven eight/
] ],
from
=> [
"already"
,
-join
=> [
aware
=>
on
=> {
one
=>
"one"
}
],
-join
=> {
on
=> {
two
=> {
">"
=>
"other"
} },
to
=>
"first"
,
type
=>
"left"
}
],
where
=> {
five
=>
"A"
,
six
=>
"B"
,
nine
=>
"C"
},
order_by
=> [
qw/one/
,
{
-asc
=>
'four'
},
{
-desc
=> [
qw/three seven/
] }
],
});
produces:
SELECT
already.one,
already.two,
already.three,
aware.four,
aware.five,
first.six,
first.seven,
first.eight
FROM already AS already
JOIN aware AS aware ON already.one = aware.one
LEFT JOIN first AS first ON aware.two > first.other
WHERE ( first.six = ? AND aware.five = ? AND already.nine = ? )
ORDER BY already.one, aware.four ASC, already.three DESC, first.seven DESC
setting talias:
my
(
$stmt
,
@bind
) =
$sql
->
select
({
talias
=> [
qw/n i f/
],
select
=> [
qw/one two three/
, [
qw/four five/
], [
qw/six seven eight/
] ],
from
=> [
"already"
,
-join
=> [
aware
=>
on
=> {
one
=>
"one"
}
],
-join
=> {
on
=> {
two
=> {
">"
=>
"other"
} },
to
=>
"first"
,
type
=>
"left"
}
],
where
=> {
five
=>
"A"
,
six
=>
"B"
,
nine
=>
"C"
},
order_by
=> [
qw/one/
,
{
-asc
=>
'four'
},
{
-desc
=> [
qw/three seven/
] }
],
});
produces:
SELECT
n.one,
n.two,
n.three,
i.four,
i.five,
f.six,
f.seven,
f.eight
FROM already AS n
JOIN aware AS i ON n.one = i.one
LEFT JOIN first AS f ON i.two > f.other
WHERE ( f.six = ? AND i.five = ? AND n.nine = ? )
ORDER BY n.one, i.four ASC, n.three DESC, f.seven DESC
you know who you are.
DESCRIPTION
This module is an extension of the SQL::Abstract::Plugin::ExtraClauses plugin, it's objective is to assist with the aliasing of tables.
AUTHOR
LNATION, <email at lnation.org>
BUGS
Please report any bugs or feature requests to bug-sql-abstract-plugin-tablealias at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=SQL-Abstract-Plugin-TableAlias. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc SQL::Abstract::Plugin::TableAlias
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Abstract-Plugin-TableAlias
CPAN Ratings
https://cpanratings.perl.org/d/SQL-Abstract-Plugin-TableAlias
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
I've not forgotten.
This software is Copyright (c) 2022 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)