Well,
params = [{
Sequel[:stacks][:organization_id] => *@user*.id,
Sequel[:stacks][:channel_id] => @channel.id, // or nil
}]
Solved my problem. Let me know if there is a better way...
On Wednesday, November 20, 2019 at 2:21:31 AM UTC+3, xura wrote:
>
> This is the full query: (I forgot to add second OR in first post):
>
> SELECT
> "stacks".*
> FROM "stacks"
> INNER JOIN "apps"
> ON ("apps"."id" = "stacks"."app_id")
> WHERE (((("user_id" = 1)
> AND ("channel_id" IS NULL))
> OR (("user_id" = 1)
> AND ("channel_id" = 5)))
> AND ("apps"."properties" IS NULL))
>
>
> On Wednesday, November 20, 2019 at 2:03:20 AM UTC+3, xura wrote:
>>
>> SELECT
>> "stacks".*
>> FROM "stacks"
>> INNER JOIN "apps"
>> ON ("apps"."id" = "stacks"."app_id")
>> WHERE (((("user_id" = 1)
>> AND ("channel_id" IS NULL)))
>> AND ("apps"."properties" IS NULL))
>>
>> Hi Jeremy,
>>
>>
>> In this query, *user_id* is ambiguous. It exists on both table. How can
>> i make sure its targeted for stacks but not apps?
>>
>> I use this method for multiple AND and ORs:
>>
>> params = [{
>> user_id: @user.id,
>> channel_id: @channel.id,
>> }]
>> params_or = [{
>> user_id: @user.id,
>> channel_id: nil,
>> }]
>>
>>
>> And my ruby code is like:
>>
>> Stacks.select { stacks.* }.join_table(:inner, :apps, id: :app_id)
>> .where { (Sequel.&(*params)) | (Sequel.&(*params_or)) }
>> .where { (apps[:properties] =~ nil) }
>>
>> On this case I tried to append double underscore with table name but it
>> didn't worked. (*stacks__user_id*)
>>
>> Thanks!
>>
>
--
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/20c78afc-9af5-4fb7-83cb-038c8622b137%40googlegroups.com.