Ecto: ** (Protocol.UndefinedError) protocol Enumerable not implemented for nil.

Created on 14 Dec 2018  Â·  7Comments  Â·  Source: elixir-ecto/ecto

Environment

  • Elixir version (elixir -v):
Erlang/OTP 21 [erts-10.0.7] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Elixir 1.7.3 (compiled with Erlang/OTP 21)
  • Database and version (PostgreSQL 9.4, MongoDB 3.2, etc.):

Postgres 9.6.11

  • Ecto version (mix deps):
* ecto (Hex package) (mix)
  locked at 3.0.5 (ecto) bf9329b5
* ecto_sql (Hex package) (mix)
  locked at 3.0.3 (ecto_sql) dd17f240
  • Database adapter and version (mix deps):
* postgrex (Hex package) (mix)
  locked at 0.14.1 (postgrex) 63247d4a
  • Operating system:

Mac OS X

Current behavior

Upgrading from ecto 3.0.4 to 3.0.5 causes some of our tests to start consistently failing. One example:

** (Protocol.UndefinedError) protocol Enumerable not implemented for nil. This protocol is implemented for: DBConnection.PrepareStream, DBConnection.Stream, Date.Range, Ecto.Adapters.SQL.Stream, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, List, Map, MapSet, Postgrex.Stream, Range, Stream, StreamData, Timex.Interval
     code: final_bpi_ids = reload_buyer(buyer2).buyer_property_interests |> Enum.map(&get_id/1)
     stacktrace:
       (elixir) /home/ubuntu/bob/tmp/412672862f47582cfc8e244ce57c682a/elixir/lib/elixir/lib/enum.ex:1: Enumerable.impl_for!/1
       (elixir) /home/ubuntu/bob/tmp/412672862f47582cfc8e244ce57c682a/elixir/lib/elixir/lib/enum.ex:141: Enumerable.reduce/3
       (elixir) lib/enum.ex:2979: Enum.reduce/3
       (ecto) lib/ecto/association.ex:287: Ecto.Association.expand_where/5
       (ecto) lib/ecto/association.ex:281: Ecto.Association.combine_assoc_where/2
       (elixir) lib/enum.ex:1314: Enum."-map/2-lists^map/1-0-"/2
       (ecto) lib/ecto/repo/queryable.ex:153: Ecto.Repo.Queryable.execute/4
       (ecto) lib/ecto/repo/queryable.ex:18: Ecto.Repo.Queryable.all/3
       (ecto) lib/ecto/repo/queryable.ex:74: Ecto.Repo.Queryable.one!/3
       test/commands/buyer_merge_test.exs:41: (test)

The respective code seems fairly innocuous:

      NestDB.Repo.get!(
        from(NestDB.Buyer, preload: [:buyer_property_interests]),
        buyer2.id
      )

Most helpful comment

Thanks, I was able to reproduce it! :D

All 7 comments

@samphilipd if you remove _build, does the problem persist?

To be clear, according to the code, :where is never meant to be nil. So I am wondering if some associations failed to recompile once you bumped the ecto dependency. Is it an umbrella project by any chance?

The other chance is if you have custom associations and they are out of date... but that's highly unlikely.

Removing the _build folder fixed it! Nice one.

That’s not supposed to happen through. Is that an umbrella application by
any chance?

Are you running the tests for one app or all apps? Is the Buyer scheme
defined in the same app as the one you are running the tests from?

On Fri, Dec 14, 2018 at 14:49 Sam Davies notifications@github.com wrote:

Closed #2863 https://github.com/elixir-ecto/ecto/issues/2863.

—
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/elixir-ecto/ecto/issues/2863#event-2026875606, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAAlbj6AXSVe0f6CDIdec0bOppQ507O3ks5u46yCgaJpZM4ZTSY6
.

>

José Valimwww.plataformatec.com.br
http://www.plataformatec.com.br/Founder and Director of R&D

I ran into this same problem on our application, and running mix clean fixed it.

Is that an umbrella application by any chance?

Yes

Are you running the tests for one app or all apps?

All apps, and also while running iex -S mix phx.server from the root of the project

Is the Buyer scheme defined in the same app as the one you are running the tests from?

Our schemas are defined in a different app than our Repo, and we're running tests from the root of the project.

Thanks, I was able to reproduce it! :D

Yes, it's an umbrella app. Glad you could repro!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jbence picture jbence  Â·  3Comments

yordis picture yordis  Â·  4Comments

fuelen picture fuelen  Â·  3Comments

jordi-chacon picture jordi-chacon  Â·  4Comments

stavro picture stavro  Â·  4Comments