Closed onyxrev closed 7 years ago
I created a new Phoenix app and followed the install instructions but still see the issue.
https://github.com/onyxrev/rethinkdb_ecto_2_insert_fail
git clone https://github.com/onyxrev/rethinkdb_ecto_2_insert_fail
mix deps.get
iex -S mix phoenix.server
iex(2)> Balls.Repo.insert %User{name: "balls"}
** (UndefinedFunctionError) function RethinkDB.Ecto.insert/6 is undefined or private. Did you mean one of:
* insert/5
(rethinkdb_ecto) RethinkDB.Ecto.insert(Balls.Repo, %{autogenerate_id: nil, context: nil, schema: User, source: {nil, "users"}}, [name: "balls", inserted_at: {{2016, 12, 26}, {0, 40, 42, 62664}}, updated_at: {{2016, 12, 26}, {0, 40, 42, 72211}}], {:raise, [], []}, [], [skip_transaction: true])
(ecto) lib/ecto/repo/schema.ex:459: Ecto.Repo.Schema.apply/4
(ecto) lib/ecto/repo/schema.ex:198: anonymous fn/11 in Ecto.Repo.Schema.do_insert/4
Version 0.6.1 uses Ecto 2.0.x and not Ecto 2.1.x. The insert
and insert_all
callback signature changed between those two version.
I do not really understand how Hex is managing dependency versions. Currently, my mix.exs
file has following deps:
defp deps do
[{:ecto, "~> 2.0"},
{:rethinkdb, "~> 0.4"}]
end
I thought that ~>
would state that Hex is allowed to use Ecto 2.0.x but not automatically update to the next minor (2.1.x) version (which, in our case, breaks the API). Will have to investigate on this.
@onyxrev, I will update to Ecto 2.1.x soon, in the mean-time, you can modify you mix.exs
like this:
defp deps do
[{:ecto, "~> 2.0.6"}, # add specific ecto version
{:phoenix, "~> 1.2.0"},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_ecto, "~> 3.0.1"}, # specify exact version
{:rethinkdb_ecto, "~> 0.6.1"},
{:gettext, "~> 0.11"},
{:cowboy, "~> 1.0"}]
end
This is fixed in version 0.6.2.
I've just upgraded from
v0.4.0
tov0.6.1
in an effort to get to Ecto 2. It appears that the function signature of RethinkDB.Ecto.insert has changed; presumably for some Ecto 2 reason. But, I'm encountering issues migrating (inserting the version fails) and issues with insertion, in general.I was looking at some of the other adapters and it appears that they offer a variety of insert methods instead of just the one.
Here's a simplified example:
I'm gonna try setting up a fresh project to isolate the problem but I'm at a bit of a loss.