Created
December 21, 2016 18:49
-
-
Save tony-o/d19c6ab194370eb1872af5369d8e62ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $prof = $orm.search('nickl', { | |
'-join' => { | |
'-table' => 'profile', | |
'-type' => 'inner', | |
'-on' => { | |
'uid' => 'id', | |
}, | |
} | |
}); |
Tony-o,
Given your example in the docs, you have the following:
my @users = $orm.search('user', { #user table will be our main table
'-join' => {
'-table' => 'profile', #join the profile table to user
'-type' => 'inner', #user an inner join, the default is 'left outer'
'-on' => {
'-and' => {
'uid' => 'DBORMID', #these are autoquoted where the key from the pair is quoted for the joining table and the value is quoted for the main table
#you can also use things like a pair here, ie: ('-lt' => 'some other column in user table')
}
}
},
'"profile"."name"' => ('-ne' => ''), #normal 'where' parameters, notice that quoting the table and field name for the joined table *may* be necessary
}).all;
That looks a little confusing because the way I am resolving the on part is"
INNER JOIN profile ON uid='DBORMID' AND
Which doesn't make sense. Am I missing something?
@Xliff - yea so the way that the internals work on that is that it translates 'uid' => 'DBORMID'
to profile.uid
and user.DBORMID
, respectively. So, it always takes the .key
to be the table to be joined, and the .value
for the parent table.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks comprehensive enough. Although for your -on you might have more complex situations.
Consider: