Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: base-query with join generates improper sql #96

Open
chevinbrown opened this issue Jul 6, 2021 · 0 comments
Open

Bug: base-query with join generates improper sql #96

chevinbrown opened this issue Jul 6, 2021 · 0 comments

Comments

@chevinbrown
Copy link

chevinbrown commented Jul 6, 2021

I need to layer the turbo-ecto query with a base-query:

def list_paginated_reviews(params, user) do
    Review
    |> with_friends(user)
    |> preload(...)
    |> Turbo.Ecto.turbo(params)
end
  
def with_friends(review, user) do
  review
  |> join(:inner, [r], uf in UserFriend, on: uf.user_id == ^user.id)
  ...

Trying to filter by category-name:

from r0 in Review,
 join: u1 in UserFriend,
 on: u1.user_id == ^2,
 join: c2 in Category,
 on: c2.id == r0.category_id,
 where: u1.name == ^"Cool stuff",
 order_by: [desc: r0.inserted_at],
 ...

Am I doing something wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant