Hi, I'm having troubles with adding a record as a child in tests:
defmodule SomeApp.Api.Node do
use Ecto.Schema
use AsNestedSet, scope: [:emotion_id]
end
root_node = %Node{emotion_id: emotion.id, name: "root"} |> AsNestedSet.create(:root) |> AsNestedSet.execute(Repo)
child_node = %Node{emotion_id: emotion.id, name: "asd"} |> AsNestedSet.create(root_node, :child) |> AsNestedSet.execute(Repo)
IO.inspect root_node
IO.inspect child_node
# root node, works fine, lft and rgt are calculated
%SomeApp.Api.Node{
__meta__: #Ecto.Schema.Metadata<:loaded, "nodes">,
emotion_id: 65,
id: 96,
inserted_at: ~N[2022-03-31 09:10:34],
lft: 0,
name: "root",
parent_id: nil,
rgt: 1,
updated_at: ~N[2022-03-31 09:10:34]
}
# supposed to be a child of root node, but it's not
%SomeApp.Api.Node{
__meta__: #Ecto.Schema.Metadata<:loaded, "nodes">,
emotion_id: 65,
id: 97,
inserted_at: ~N[2022-03-31 09:10:34],
lft: nil,
parent_id: nil,
rgt: nil,
updated_at: ~N[2022-03-31 09:10:34]
}
Am I missing something? Seemingly two identical ways of creating an entity in the tree behave differently. If I create a child node as another root first and move it, it works, but creating it as a child right away does not seem to be working.
Elixir 1.13.2
as_nested_set 3.4.1
ecto 3.7.2
phoenix 1.6.6
Hi, I'm having troubles with adding a record as a child in tests:
Am I missing something? Seemingly two identical ways of creating an entity in the tree behave differently. If I create a child node as another root first and move it, it works, but creating it as a child right away does not seem to be working.
Elixir 1.13.2
as_nested_set 3.4.1
ecto 3.7.2
phoenix 1.6.6