Thank you

On Tuesday, November 15, 2022 at 3:17:39 PM UTC-5 Jeremy Evans wrote:

> On Tue, Nov 15, 2022 at 9:36 AM [email protected] <[email protected]> wrote:
>
>> I need to find records where two fields are the same (strings).  I've 
>> tried a handful of things, but they call come back as 'WHERE false'.  
>> Here's the two that I thought would work:
>>
>> puts d.where(Sequel(:field1 == :field2)).to_a.size
>> puts d.where(:field1 == :field2).to_a.size
>>
>> Using a single equals sign throws an error.  I can't seem to find any 
>> reference to testing two columns, but I looked at Inequality methods, which 
>> is where I got the first trial above.
>>
>> Any insights?  Cheers
>>
>
>   d.where(:field1 => :field2)
>
> This stems from the fact that symbols represent identifiers, and hashes 
> are used for equality:
>
> * 
> http://sequel.jeremyevans.net/rdoc/files/doc/cheat_sheet_rdoc.html#label-Equality
> * 
> http://sequel.jeremyevans.net/rdoc/files/doc/sql_rdoc.html#label-Equality+Operator+-28-3D-29
> * 
> http://sequel.jeremyevans.net/rdoc/files/README_rdoc.html#label-Filtering+Records
> * 
> http://sequel.jeremyevans.net/rdoc/files/doc/sql_rdoc.html#label-Identifiers
>
> Symbol#== doesn't work.  That's defined by Ruby itself to check if two 
> symbols are equal.  :a == :b should always be false in Ruby code, so the 
> code you used is the same as .where(false), which explains why you see 
> WHERE false in the SQL.
>
> 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/2fa7c6e1-0075-4119-bcac-70a8818de3bdn%40googlegroups.com.

Reply via email to