ecto_materialized_path icon indicating copy to clipboard operation
ecto_materialized_path copied to clipboard

`build_child/1` fails to build a valid struct

Open ghost opened this issue 5 years ago • 1 comments

That is, the following test fails

  test "build_child/1" do
    comment = %Comment{id: 17, path: [89]}
    assert %Comment{id: nil, path: [89, 17]} = Comment.build_child(comment)
  end

with

  1) test build_child/1 (DemoTest)
     test/demo_test.exs:5
     match (=) failed
     code:  assert %Comment{id: nil, path: [89, 17]} = Comment.build_child(comment)
     right: %{__struct__: Demo.Comment, path: [89, 17]}
     stacktrace:
       test/demo_test.exs:7: (test)

ghost avatar May 07 '19 08:05 ghost

A possible is it to take the parent struct and nillify all fields except for column_name for path. Then the struct structure would be preserved.

ghost avatar May 07 '19 08:05 ghost