On Thu, Oct 15, 2020 at 5:34 PM Rodrigo Dutra <[email protected]> wrote:
> I have a pretty complex query split using several dataset modules. I'm
> trying to go all sequel
>
> This section
>
> disabled_custom_product_id =
> Sequel[:disabled_custom_products_locations][:custom_product_id]
> calculated_available_column = Sequel.case(
> { { id: disabled_custom_product_id } => false }, true
> )
> select_append(calculated_available_column.as(:available))
>
> Generates the following SQL
>
> (CASE WHEN ("id" =
> "disabled_custom_products_locations"."custom_product_id") THEN false ELSE
> true END) AS "available"
>
> But I need to generate the following
>
> (CASE WHEN ("id" =
> "disabled_custom_products_locations"."custom_product_id" AND
> "disabled_custom_products_locations"."location_id" = 2) THEN false ELSE
> true END) AS "available"
>
> So far I've been unsucesful in trying to get the AND recognized with my
> syntax so I'd appreciate any insights
>
You need to add a separate hash entry for the additional condition:
disabled_custom_product_id =
Sequel[:disabled_custom_products_locations][:custom_product_id]
calculated_available_column = Sequel.case(
{ {id: disabled_custom_product_id,
Sequel[:disabled_custom_products_locations][:location_id]=>2} => false },
true
)
select_append(calculated_available_column.as(:available))
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/CADGZSSdRQpqZEjKXweBz7k889bUi%3DMr5JJbUXXgKAJ0QPd-jMQ%40mail.gmail.com.