【问题标题】:map inside macro injected in Ecto from在 Ecto 中注入的宏中的映射来自
【发布时间】:2017-01-31 09:57:16
【问题描述】:

从这两个在模块中正确定义的宏

 defmacro binary(key) do
    quote do
        [
             fragment("some fragment", unquote(key)),
             fragment("some fragment", unquote(key))
        ]
    end
  end



defmacro mapbin(key) do
        quote do
            %{
               "1" =>   fragment("some fragment same as above", unquote(key)),
                "2" =>  fragment("some fragment same as above", unquote(key))
            }
        end
      end

这行得通

 from u in Table, select: binary("key")

但不是这个

from u in Table, select: mapbin("key")

宏中的地图有什么问题?

消息是编译错误 %{"1" => fragment("", ""),...} 不是有效的查询表达式。

【问题讨论】:

    标签: macros ecto


    【解决方案1】:

    这是ecto中的一个错误

    已经修复

    https://github.com/elixir-ecto/ecto/issues/1936

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-02
      • 1970-01-01
      • 2019-03-11
      • 2021-09-15
      • 1970-01-01
      • 2012-09-07
      • 2011-02-08
      • 2013-11-21
      相关资源
      最近更新 更多