Code Monkey home page Code Monkey logo

ecto_materialized_path's Issues

`build_child/1` fails to build a valid struct

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)

Post.parent() gives wrong query.

post |> Post.parent() |> Repo.one()

results in

** (Ecto.Query.CastError) deps/ecto_materialized_path/lib/ecto_materialized_path.ex:73: value 4 in where cannot be cast to type {:in, :id} in query:

from a in Post
where: a.id in ^4,
limit: 1,
select: a

(elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
(elixir) lib/enum.ex:1397: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
(ecto) lib/ecto/repo/queryable.ex:124: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:37: Ecto.Repo.Queryable.all/4
(ecto) lib/ecto/repo/queryable.ex:70: Ecto.Repo.Queryable.one/4
(stdlib) erl_eval.erl:677: :erl_eval.do_apply/6
(iex) lib/iex/evaluator.ex:250: IEx.Evaluator.handle_eval/5
(iex) lib/iex/evaluator.ex:230: IEx.Evaluator.do_eval/3
(iex) lib/iex/evaluator.ex:208: IEx.Evaluator.eval/3

Running post |> Post.parent() returns

#Ecto.Query<from a in Post, where: a.id in ^4, limit: 1>

The use of the in operator seems weird to me, but it has been there for over a year, and noone has complained yet. This makes me wonder if I am doing something wrong.

xx

๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.