在Ecto注入的宏内部映射

时间:2017-01-31 09:57:17

标签: macros ecto

来自模块中正确定义的这两个宏

 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("", ""),...}不是有效的查询表达式。

1 个答案:

答案 0 :(得分:0)

这是ecto中的一个错误

已修复

请参阅https://github.com/elixir-ecto/ecto/issues/1936

相关问题