bigpresh / Dancer-Plugin-Database

Dancer::Plugin::Database - easy database support for Dancer applications
http://search.cpan.org/dist/Dancer-Plugin-Database
37 stars 36 forks source link

RFC: Core::Handle - make simple_query a little less simple #95

Closed thefatphil closed 6 years ago

thefatphil commented 6 years ago

The simplest of joins is to take two tables, and join on a single field from each table. If we're agreed that's simple, then it is worth supporting.

So, rather than: $urow = database->quick_select('users', { login => $uname }); $crow = database->quick_select('countries', { id => $urow->{'country'} });

One can now do: $row = database->quick_select({ users=>'country', countries=>'id' }, { login=>$uname });

(defaulting to inner join), or: $row = database->quick_select({ users=>'country', countries=>'id' }, { login=>$uname }, { join_type=>'left', join_order=>['users','countries'] });

The order field is only needed because of the non-ordered nature of hashes, neither of the tables has precedence, so it's not clear which is 'left' and which is 'right'.

Signed-off-by: Phil Carmody pc+github@asdf.org

thefatphil commented 6 years ago

Version 2 is better, closing this one.