Skip to content

Trans.QueryBuilder does not support join #83

@Domeee

Description

@Domeee

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions