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

Trans.QueryBuilder does not support join #83

Open
Domeee opened this issue Oct 10, 2023 · 0 comments
Open

Trans.QueryBuilder does not support join #83

Domeee opened this issue Oct 10, 2023 · 0 comments

Comments

@Domeee
Copy link

Domeee commented Oct 10, 2023

Hi @crbelaus

I'm currently evaluating different solutions to tackle I18n in our project. trans looks very promising. Thank you for it!

Using Trans.QueryBuilder in conjunction with join does not seem to work.

from(o in Organisation, join: p in assoc(o, :programs), select: %{title: translated_as(Program, p.title, user.locale)}) |> Repo.all()

results in the following error:

** (Postgrex.Error) ERROR 42703 (undefined_column) column "p0" does not exist
     
query: SELECT translate_field(p0, $1::varchar, $2::varchar, $3::varchar, $4::varchar[]) AS "title" FROM "organisations" AS o0 INNER JOIN "programs" AS p1 ON p1."organisation_id" = o0."id"

Renaming the intermediate veriable p to p1 seems to resolve this issue.

    from(o in Organisation,
      join: p1 in assoc(o, :programs),
      select: %{title: translated_as(Program, p1.title, user.locale)}
    )
    |> Repo.all()

This in turn does not seem to be a maintainable solution. Any thoughts on this?

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