3

我正在尝试在 phoenix 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}

对长生不老药还是新手,真的可以使用一些指导!谢谢!

整个堆栈跟踪:

[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
4

0 回答 0