无法在Phoenix Elixir Postgres中创建Geo.Point数组

时间:2017-09-05 17:39:41

标签: postgresql phoenix-framework postgrex

我试图在凤凰elixir的postgres中创建一个Geo Point对象数组。我得到错误类型_geometry无法由类型模块Terror.PostgrexType处理。

在Terror.Postgrextype中:

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

我已成功将相关表格修改为 - >

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

相应的模型包含:

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

仍然是elixir的新手,并且可以真正使用一些指导!谢谢!

整个堆栈跟踪:

[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

0 个答案:

没有答案