【问题标题】:PostGIS: Could not choose the best candidate function between: public.st_geomfromgeojson( => json), public.st_geomfromgeojson( => jsonb)PostGIS:无法在以下之间选择最佳候选函数:public.st_geomfromgeojson(=> json),public.st_geomfromgeojson(=> jsonb)
【发布时间】:2022-02-02 17:28:46
【问题描述】:

我在 PostGIS 前面有 PostgREST,我想调用 st_geomfromgeojson 函数,如 https://postgrest.org/en/stable/api.html#stored-procedures 所述。

curl -X 'POST' \
  'http://postgrest-host:port/rpc/st_geomfromgeojson' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"type":"Point","coordinates":[-48.23456,20.12345]}'

得到错误:

{"hint":"Try renaming the parameters or the function itself in the database so function overloading can be resolved","message":"Could not choose the best candidate function between: public.st_geomfromgeojson( => json), public.st_geomfromgeojson( => jsonb)"}

有没有办法可以在 HTTP 请求中提供 PostGIS 函数参数,以便选择 public.st_geomfromgeojson( => json)

【问题讨论】:

    标签: postgresql postgis postgrest


    【解决方案1】:

    PostgREST 无法区分这两个重载函数,因为它们具有相同数量的同名参数但数据类型不同。

    一种解决方案是创建一个具有不同名称的包装函数,并在其中调用st_geomfromgeojson 函数。然后你会调用包装函数来避免冲突。

    【讨论】:

      猜你喜欢
      • 2013-03-20
      • 2017-04-25
      • 2017-08-31
      • 2014-01-20
      • 1970-01-01
      • 1970-01-01
      • 2020-12-26
      • 1970-01-01
      • 2017-05-08
      相关资源
      最近更新 更多