I have a Phoenix app which has schema's setup and is utilising a pre-existing database with data.
I came across quite an unhelpful error message while attempting to create tests for the Phoenix application.
When running mix test
** (ArgumentError) cannot load `"2"` as type :integer
(ecto) lib/ecto/repo/queryable.ex:132: Ecto.Repo.Queryable.load!/3
(ecto) lib/ecto/adapters/sql.ex:515: anonymous fn/3 in Ecto.Adapters.SQL.process_row/3
(elixir) lib/enum.ex:1151: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(ecto) lib/ecto/adapters/sql.ex:513: Ecto.Adapters.SQL.process_row/3
(elixir) lib/enum.ex:1088: Enum."-map/2-lists^map/1-0-"/2
(ecto) lib/ecto/adapters/sql.ex:283: Ecto.Adapters.SQL.decode/2
(ecto) lib/ecto/adapters/sql.ex:272: Ecto.Adapters.SQL.decode/3
(ecto) lib/ecto/adapters/sql.ex:225: Ecto.Adapters.SQL.query/5
At first I had no idea what was going on and assumed I'd some something wrong in my Elixir code.
I eventually had a look at test_helper.exs and noticed this line:
Mix.Task.run "ecto.migrate", ~w(-r AdminPhoenix.Repo --quiet)
When I run mix ecto.migrate outside of mix test, I obviously receive the same message.
This is potentially quite an odd edge case as most I'd assume are building brand new applications. Though I'd imagine I won't be the only one who wants to build a Phoenix application for an existing database :)
I'm not sure whether it would warrant a change in Ecto for ecto.migrate to tell the user that there are no migrations present, as even that would have helped significantly.
I have a Phoenix app which has schema's setup and is utilising a pre-existing database with data.
I came across quite an unhelpful error message while attempting to create tests for the Phoenix application.
When running
mix testAt first I had no idea what was going on and assumed I'd some something wrong in my Elixir code.
I eventually had a look at
test_helper.exsand noticed this line:Mix.Task.run "ecto.migrate", ~w(-r AdminPhoenix.Repo --quiet)When I run mix ecto.migrate outside of mix test, I obviously receive the same message.
This is potentially quite an odd edge case as most I'd assume are building brand new applications. Though I'd imagine I won't be the only one who wants to build a Phoenix application for an existing database :)
I'm not sure whether it would warrant a change in Ecto for
ecto.migrateto tell the user that there are no migrations present, as even that would have helped significantly.