On Monday, October 1, 2012 3:05:05 PM UTC-7, Christian MICHON wrote:
> Hi,
>
> as I'm currently refactoring some of my complex jdbc prepared
> statements to a more generic ORM approach, using pure Sequel, I found
> it very difficult to translate such SQL query:
>
> SELECT NAME, COUNT(REV)=0 AS LEAF FROM PROD
>
> I cannot pass the stage beyond count. So far, I'm stuck now with:
>
> DB[:prod].select{[:name,count(:rev).as(:leaf)]}.sql
> => "SELECT NAME, count(REV) AS LEAF FROM PROD"
>
> I could not find how to code the boolean test (equal to 0). Can
> someone with experience on using count+test+aliasing help me?
>
Equality expressions in Sequel are always expressed as hashes:
DB[:prod].select{[:name, Sequel.as({count(:rev)=>0}, :leaf)]}
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/-/Xuiru1RV4hEJ.
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.