mojolicious / sql-abstract-pg

:elephant: PostgreSQL features for SQL::Abstract
https://metacpan.org/pod/SQL::Abstract::Pg
Artistic License 2.0
5 stars 3 forks source link

allow aliases in arrayref table join syntax #6

Open akarelas opened 1 year ago

akarelas commented 1 year ago

Summary

In the arrayref syntax of table joins, I allow table names to appear with aliases, like so:

$db->select([
    \'people AS parents',
    [\'people AS children', 'children.parent_id' => 'parents.id'],
]);

Motivation

This change is necessary, in order to allow a table to join itself in a query. Without this change, one would have to write a long SCALARREF instead of the arrayref syntax, like so:

$db->select(\'people AS parents JOIN people AS children ON (children.parent_id = parents.id)');

References

3