Skip to content

Conversation

thefatphil
Copy link
Contributor

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 thefatphil force-pushed the simple-join branch 2 times, most recently from 6ac9ccb to b67d3f5 Compare October 14, 2018 17:43
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
Copy link
Contributor Author

Version 2 is better, closing this one.

@thefatphil thefatphil closed this Oct 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant