SQL::Abstract::Plugin::TableAlias - automagical table aliasing
Version 0.04
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/] } ], });
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.
This module is an extension of the SQL::Abstract::Plugin::ExtraClauses plugin, it's objective is to assist with the aliasing of tables.
LNATION, <email at lnation.org>
<email at lnation.org>
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.
bug-sql-abstract-plugin-tablealias at rt.cpan.org
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
https://metacpan.org/release/SQL-Abstract-Plugin-TableAlias
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)
To install SQL::Abstract::Plugin::TableAlias, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SQL::Abstract::Plugin::TableAlias
CPAN shell
perl -MCPAN -e shell install SQL::Abstract::Plugin::TableAlias
For more information on module installation, please visit the detailed CPAN module installation guide.