gpt4 book ai didi

postgresql - 类型模块无法处理类型 `_geometry`

转载 作者:行者123 更新时间:2023-12-05 06:56:36 25 4
gpt4 key购买 nike

我正在尝试使用 Ecto 设置 Postgis,我一直在关注 https://github.com/bryanjos/geo_postgis 的文档密切。但是当试图检索具有以下字段的资源时

field :coords, {:array, Geo.PostGIS.Geometry}, default: []

出现以下错误

[error] #PID<0.1405.0> running GIWeb.Endpoint (connection #PID<0.1404.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /c/applications/power/community_map
** (exit) an exception was raised:
** (Postgrex.QueryError) type `_geometry` can not be handled by the types module GI.PostgresTypes
(ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:593: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:526: Ecto.Adapters.SQL.execute/5
(ecto 3.4.6) lib/ecto/repo/queryable.ex:192: Ecto.Repo.Queryable.execute/4
(ecto 3.4.6) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
(elixir 1.11.1) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
(app 0.1.0) lib/app/plugs/auth.ex:30: GIWeb.Plugs.Auth.put_context/2
(app 0.1.0) GIWeb.Router.browser/2
(app 0.1.0) lib/app/router.ex:1: GIWeb.Router.__pipe_through3__/1
(phoenix 1.5.4) lib/phoenix/router.ex:347: Phoenix.Router.__call__/2
(app 0.1.0) lib/app/endpoint.ex:1: GIWeb.Endpoint.plug_builder_call/2
(app 0.1.0) lib/plug/debugger.ex:132: GIWeb.Endpoint."call (overridable 3)"/2
(app 0.1.0) lib/app/endpoint.ex:1: GIWeb.Endpoint.call/2
(phoenix 1.5.4) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4
(cowboy 2.8.0) /home/elvar/Projects/elixir/platform/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2

我已经定义了我的类型。

Postgrex.Types.define(
GI.PostgresTypes,
[Geo.PostGIS.Extension] ++ Ecto.Adapters.Postgres.extensions(),
json: Jason
)

在迁移中添加了我的字段

add :coords, {:array, :geometry}, default: []

我做错了什么?

最佳答案

在你的配置文件中,例如 config/dev.ex,确保你的 Repo 配置中有这个:

  types: GI.PostgresTypes

所以它看起来像这样:

config :gi, GI.Repo,
# ...
types: GI.PostgresTypes

关于postgresql - 类型模块无法处理类型 `_geometry`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65088656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com