On Wednesday, January 9, 2013 11:13:52 AM UTC-8, Alex Vinnik wrote:
>
> 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?
>
Using lambda/proc should work fine too. Proc instances are treated as
virtual rows by the filtering code.
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/-/VBRTrxqTIowJ.
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.