It was in a phoenix server using ecto. If I ran iex -S mix
from one of the apps in the umbrella there was no problem inserting to the database. If I ran phx.server
and didn’t call the ecto code there was still no problem. But then from the phoenix server if I tried to make an insert to the database (which was the first thing I tried implementing with ecto) it would give the following error:
[error] #PID<0.456.0> running WebApi.Endpoint terminated
Server: 0.0.0.0:4000 (http)
Request: POST /graphiql
** (exit) an exception was raised:
** (Protocol.UndefinedError) protocol String.Chars not implemented for %Postgrex.Query{columns: ["id"], name: "", param_formats: [:binary, :binary, :binary, :binary, :binary], param_oids: [16, 1043, 1043, 1043, 1043], param_types: [Postgrex.Extensions.Bool, Postgrex.Extensions.Raw, Postgrex.Extensions.Raw, Postgrex.Extensions.Raw, Postgrex.Extensions.Raw], ref: #Reference<0.0.2.979>, result_formats: [:binary], result_oids: [20], result_types: [Postgrex.Extensions.Int8], statement: ["INSERT INTO ", [34, "users", 34], [], [32, 40, [[[[[[], [34, "confirmed", 34], 44], [34, "email", 34], 44], [34, "password", 34], 44], [34, "salt", 34], 44], 34, "username", 34], ") VALUES ", [], 40, [[[[[[], [36 | "1"], 44], [36 | "2"], 44], [36 | "3"], 44], [36 | "4"], 44], 36 | "5"], 41], [], " RETURNING ", [], 34, "id", 34], types: {Ecto.Adapters.Postgres.TypeModule, 626738}}. This protocol is implemented for: Atom, BitString, Date, DateTime, Float, Integer, List, NaiveDateTime, Time, URI, Version, Version.Requirement
(elixir) lib/string/chars.ex:3: String.Chars.impl_for!/1
(elixir) lib/string/chars.ex:22: String.Chars.to_string/1
(ecto) lib/ecto/adapters/sql.ex:613: Ecto.Adapters.SQL.log/4
(db_connection) lib/db_connection.ex:1186: DBConnection.log/6
(ecto) lib/ecto/adapters/postgres/connection.ex:86: Ecto.Adapters.Postgres.Connection.execute/4
(ecto) lib/ecto/adapters/sql.ex:256: Ecto.Adapters.SQL.sql_call/6
(ecto) lib/ecto/adapters/sql.ex:542: Ecto.Adapters.SQL.struct/8
(ecto) lib/ecto/repo/schema.ex:547: Ecto.Repo.Schema.apply/4
(ecto) lib/ecto/repo/schema.ex:213: anonymous fn/14 in Ecto.Repo.Schema.do_insert/4
(login) lib/login.ex:54: Login.register_user/1
(web_api) lib/web_api/resolvers/users.ex:10: WebApi.Resolver.Users.registration/2
(absinthe) lib/absinthe/resolution.ex:187: Absinthe.Resolution.call/2
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:187: Absinthe.Phase.Document.Execution.Resolution.reduce_resolution/1
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:149: Absinthe.Phase.Document.Execution.Resolution.do_resolve_field/4
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:135: Absinthe.Phase.Document.Execution.Resolution.do_resolve_fields/6
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:71: Absinthe.Phase.Document.Execution.Resolution.walk_result/5
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:53: Absinthe.Phase.Document.Execution.Resolution.perform_resolution/3
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:25: Absinthe.Phase.Document.Execution.Resolution.resolve_current/3
(absinthe) lib/absinthe/pipeline.ex:253: Absinthe.Pipeline.run_phase/3
(absinthe_plug) lib/absinthe/plug.ex:414: Absinthe.Plug.run_query/4
I’m not sure the answer to that. As shown above I had a project that gave me an error that looked the same to me. I followed the solution given here of deleting _build
and recompiling, and that fixed it for me. So now I have a project that formerly seemed to reproduce this error, but I’m not sure how I would get it to reproduce it again.