postgresql - search_path doesn't work as expected with currentSchema in URL -
my sql commands have issues finding objects public schema (which in default db search_path) when specifying currentschema parameter in db connection url.
how fixed?
the long story:
- i have application schema
app1. - the db has postgis extension installed in
publicschema (and want keep there). the db
search_pathconfigured this:alter database tst set search_path = "$user", publicwhen connecting db without specifying current schema in url, default schema public , finds geo functions , objects. have specify
app1schema prefix when addressing objectsapp1, e.g.:select st_asgeojson(geometry,15,4) app1.shapes limit 5this not convenient. added "app1" current schema parameter connection url this:
jdbc:postgresql://localhost:5432/tst?currentschema=app1now, when connect db, don't have specify app1 prefix when addressing objects app1 schema. however, requests involve postgis objects don't work anymore , fail with:
error: function st_asgeojson(public.geometry, integer) not exist
my understanding should search objects in search_path , find them in public schema doesn't happen reason. i've tried specifying search path on user level still didn't work.
the parameter name currentschema bit misleading. takes whole search_path, not "current schema". the documentation:
currentschema = stringspecify schema set in search-path. schema used resolve unqualified object names used in statements on connection.
so try:
jdbc:postgresql://localhost:5432/tst?currentschema=app1,public or, if connect particular user, can set search_path user in db (or user in database). don't need in connection string.
or, if user name happens app1, search path setting "$user", public resolves app1, public automatically, , don't need anything extra.
Comments
Post a Comment