create table(:comments) do
add(:body, :text)
add(:parent_id, references(:comments), on_delete: :delete_all)
end
create index(:comments, [:parent_id])
and a schema
defmodule Test.Comment do
use Ecto.Schema
use Arbor.Tree,
foreign_key: :parent_id,
foreign_key_type: :integer
import Ecto.Query
schema "comments" do
field(:body, :string)
belongs_to(:parent, Test.Comment)
end
end
And I am getting this error
== Compilation error in file lib/test/comment.ex ==
** (MatchError) no match of right hand side value: "comments"
expanding macro: Arbor.Tree.__before_compile__/1
lib/test/comment.ex:1: Testpu.Comment (module)
(elixir) lib/kernel/parallel_compiler.ex:198: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
I am using {:arbor, "~> 1.0.6"} with table
and a schema
And I am getting this error
It turns out this line https://github.com/coryodaniel/arbor/blob/1c63aaef2d194742ff834941aa00a376b698e398/lib/arbor/tree.ex#L40 causing problem.
It is expecting a prefix in the tuple {prefix, source} while
struct_fields[:__meta__].source
only returns {source} which resulted in a MatchError.It looks like it has been fixed for Ecto3, is support for Ecto2 still maintained?