Substract 2 hstore, You might need to add explicit type casts

家住魔仙堡 提交于 2019-12-13 05:21:11

问题


Documentation for postgres has hstore - hstore which delete matching pairs from left operand. Installed postgres extensions.

When I try

select public.hstore('"x"=>"30", "y"=>"c"') - 
       public.hstore('"x"=>"30","y"=>"fred"')

is error-ing with following

ERROR:  operator does not exist: public.hstore - public.hstore
LINE 3:  select public.hstore('"x"=>"30", "y"=>"c"') - public.hstore...
                                                     ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

回答1:


You've installed the hstore extension into the public schema, which is not on your search_path. To find the types you're schema-qualifying them but you're not qualifying the - operator that works on those types.

This means that hstore's operator definitions will not be found. You must:

  • Schema-qualify the operator using OPERATOR(public.-);
  • Put public on the search_path; or
  • Uninstall hstore and then install it into its own dedicated schema that is on the search_path.

An example of schema-qualified operator syntax is:

SELECT 1 OPERATOR(pg_catalog.-) 2;



回答2:


I ran into this issue as well, nothing worked for me from my code (worked via pgadmin - query). Eventually after looking at the functions within public I found this which worked for me.

public.fetchval(hstore, key)


来源:https://stackoverflow.com/questions/18637669/substract-2-hstore-you-might-need-to-add-explicit-type-casts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!