Benka Christopher
Benka Christopher

Reputation: 31

Unable to create array of Geo.Point in Phoenix Elixir Postgres

I am attempting to create an array of Geo Point objects in postgres in phoenix elixir. I get the error type _geometry can not be handled by the types module Terror.PostgrexType.

In Terror.Postgrextype:

Postgrex.Types.define(Terror.PostgrexTypes,
[Geo.PostGIS.Extension] ++ Ecto.Adapters.Postgres.extensions(),
json: Poison)

I have successfully modified the table in question to ->

alter table(:terrorgrouplocations) do
 modify :geo_locs, {:array,:geometry}
end

The corresponding model contains:

field :geo_locs, {:array, Geo.Point}

Still new to elixir, and could really use some guidance! Thanks!

Entire stack trace:

[error] Postgrex.Protocol (#PID<0.264.0>) disconnected: ** 
(RuntimeError) type `_geometry` can not be handled by the types module 
Terror.PostgrexTypes
** (RuntimeError) type `_geometry` can not be handled by the types 
module Terror.PostgrexTypes
         (ecto) lib/ecto/adapters/postgres/connection.ex:99: Ecto.Adapters.Postgres.Connection.execute/4
         (ecto) lib/ecto/adapters/sql.ex:243: Ecto.Adapters.SQL.sql_call/6
         (ecto) lib/ecto/adapters/sql.ex:562: Ecto.Adapters.SQL.struct/7
         (ecto) lib/ecto/repo/schema.ex:469: Ecto.Repo.Schema.apply/4
         (ecto) lib/ecto/repo/schema.ex:205: anonymous fn/13 in Ecto.Repo.Schema.do_insert/4
         (ecto) lib/ecto/association.ex:534: Ecto.Association.Has.on_repo_change/4
         (ecto) lib/ecto/association.ex:330: anonymous fn/7 in Ecto.Association.on_repo_change/6
       (elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
         (ecto) lib/ecto/association.ex:327: Ecto.Association.on_repo_change/6
       (elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
         (ecto) lib/ecto/association.ex:293: Ecto.Association.on_repo_change/3
         (ecto) lib/ecto/repo/schema.ex:624: Ecto.Repo.Schema.process_children/4
         (ecto) lib/ecto/repo/schema.ex:691: anonymous fn/3 in Ecto.Repo.Schema.wrap_in_transaction/6
         (ecto) lib/ecto/adapters/sql.ex:620: anonymous fn/3 in Ecto.Adapters.SQL.do_transaction/3
(db_connection) lib/db_connection.ex:1275: DBConnection.transaction_run/4
(db_connection) lib/db_connection.ex:1199: DBConnection.run_begin/3
(db_connection) lib/db_connection.ex:790: DBConnection.transaction/3
         (ecto) lib/ecto/repo/schema.ex:131: Ecto.Repo.Schema.insert!/4

Upvotes: 3

Views: 333

Answers (0)

Related Questions