Closed thefatphil closed 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
Version 2 is better, closing this one.
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