How about this version with lambda instead of virtual_row ? 

DB[:linksource_visits].join(:geo_locations, lambda {(linksource_visits__ip 
>= geo_locations__ip_from) & (linksource_visits__ip <= 
geo_locations__ip_to)}).sql

both generate identical SQL

irb(main):007:0> DB[:linksource_visits].join(:geo_locations, lambda 
{(linksource_visits__ip >= geo_locations__ip_from) & (linksource_visits__ip 
<= geo_locations__ip_to)}).sql
=> "SELECT * FROM linksource_visits INNER JOIN geo_locations ON 
((linksource_visits.ip >= geo_locations.ip_from) AND (linksource_visits.ip 
<= geo_locations.ip_to))"

irb(main):008:0> DB[:linksource_visits].join(:geo_locations, 
Sequel.virtual_row{(linksource_visits__ip >= geo_locations__ip_from) & 
(linksource_visits__ip <= geo_locations__ip_to)}).sql
=> "SELECT * FROM linksource_visits INNER JOIN geo_locations ON 
((linksource_visits.ip >= geo_locations.ip_from) AND (linksource_visits.ip 
<= geo_locations.ip_to))"

It is just shorter and more readable. Do you see any issues with using 
lambda?
-Alex

On Wednesday, January 9, 2013 10:22:54 AM UTC-6, Jeremy Evans wrote:
>
> On Wednesday, January 9, 2013 8:16:11 AM UTC-8, Alex Vinnik wrote:
>>
>> Hi Jeremy, is there a technical reason for not being able to use virtual 
>> row on join conditions? It looks like virtual row should be a good fit for 
>> join conditions. If we could solve this problem it would save us tons of 
>> time porting 1.8 to 1.9. 
>>
>
> The technical reason is that join already accepts a block which is treats 
> differently from a virtual row.  Note that if you want, you can still use a 
> virtual row manually:
>
>   join(:geo_locations, Sequel.virtual_row{(linksource_visits__ip >= 
> :geo_locations__ip_from) & (linksource_visits__ip <= 
> :geo_locations__ip_to)})
>  
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/PkcCKQ3lNQcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to