【问题标题】:ecto query missing from clause from entry table条目表中的子句中缺少 ecto 查询
【发布时间】:2021-10-12 18:24:54
【问题描述】:

有谁知道我为什么会收到这个错误 ** (Postgrex.Error) ERROR 12345 (undefined_table) missing FROM-clause entry for table "ph"

    my_query =
      from(p in M,
        join: rt in R,
        on: rt.id == p.id,
        where: rt.name == "Some String" and p.name == "Another String",
        select: %{
          id: p.id,
          name: p.name,
          number: p.number
        }
      )

    another_query =
      from(e in E,
        ...
        left_join: ph in subquery(my_query),
        on: fragment("ph.id::text = e.id::text"),

我正在尝试将my_query 用作更大查询中的子查询,但我不断收到此错误。

【问题讨论】:

    标签: elixir ecto


    【解决方案1】:

    如果重写another_query中的on部分是否有效:

    on: fragment("?::text", ph.id) == fragment("?::text", e.id)
    

    (免责声明:未经测试)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多