Right.  I'm trying to be specific with those filters.  Good to know about 
the hash or =~.  

a = DL[:yachts].
  where{cdate > Time.now - (24*60*60)}.
  exclude{(lat == 0.0) & (lon == 0.0)}.
  select(:vessel, :lat, :lon, Sequel.function(:age, :cdate, 
Time.now).extract(:hour).as(:age))
  
puts a.sql
puts
puts a.to_a

=> SELECT "vessel", "lat", "lon", extract(hour FROM age("cdate", 
'2021-01-05 18:41:32.372858-0500')) AS "age" FROM "yachts" WHERE (("cdate" 
> '2021-01-04 18:41:32.372643-0500') AND NOT false)

a = DL[:yachts].
  where{cdate > Time.now - (24*60*60)}.
  exclude{(lat =~ 0.0) & (lon =~ 0.0)}.
  select(:lat, :lon, Sequel.function(:age, :cdate, 
Time.now).extract(:hour).as(:age), :vessel)
  
puts a.sql
puts
puts a.to_a

=> SELECT "lat", "lon", extract(hour FROM age("cdate", '2021-01-05 
18:50:44.566644-0500')) AS "age", "vessel" FROM "yachts" WHERE (("cdate" > 
'2021-01-04 18:50:44.566494-0500') AND (("lat" != 0.0) OR ("lon" != 0.0)))

Perfect.  Thank you.  

On Tuesday, January 5, 2021 at 11:07:46 AM UTC-5 Jeremy Evans wrote:

> On Tue, Jan 5, 2021 at 4:06 AM [email protected] <[email protected]> wrote:
>
>> Hi there.  Thanks for the reply.
>>
>> That isn't explained at all on that page.  "You can also use the =~ 
>> operator:" has little explanation. I tried "==" and it worked as well.  
>> Because it was a negation, I thought using "=" would/should have worked.  
>> So this is working:
>>
>>     exclude{(lat == 0.0) & (lon == 0.0)}.
>>
>
> That probably isn't doing what you think it is doing, because Sequel does 
> not override the == operator.  Look at the SQL generated.
>
> Equality conditions in Sequel either use a hash or the =~ operator. You 
> probably want:
>
> exclude(:lat=>0.0, :lon=>0.0)
> # or
> exclude{(lat =~ 0.0) & (lon =~ 0.0)}
>  
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/f217b963-98d5-4957-a7a5-b2d1fef1eee6n%40googlegroups.com.

Reply via email to