pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: cgm-aw (@cgm-aw) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #3605: PgConnection.setSchema() does not support multiple schemas
Date: Tue, 15 Apr 2025 07:36:19 +0000
Message-ID: <[email protected]> (raw)
**Describe the issue**
According to the [documentation](https://jdbc.postgresql.org/documentation/use/#connection-parameters), `currentSchema` can be a comma-separated list of schemas. While this works for the connection string, it does not work for `PgConnection.setSchema()`.
**Driver Version?**
Latest
**Java Version?**
Any
**OS Version?**
Any
**PostgreSQL Version?**
Any
**To Reproduce**
Call `PgConnection.setSchema("a, b")` - the search path will be set to the string "a, b" instead to the schemas "a" and "b".
**Expected behaviour**
The search path should be set to a list of schemas if a comma-separated list is provided.
**Comments**
This is because `PgConnection.setSchema()` puts single quotes around the passed schema:
```
StringBuilder sb = new StringBuilder();
sb.append("SET SESSION search_path TO '"); // See here
Utils.escapeLiteral(sb, schema, getStandardConformingStrings());
sb.append("'"); // and here
```
I'm happy to provide a reproducer if you need one, but I think the issue is pretty clear.
There is some escaping going on, a comma-separated list passed a a string ("a, b") should of course be escaped to: 'a', 'b'
I don't know if you have helpful utils to do this, so I didn't create a pull request. If you like, I can try :)
Best regards
Andreas
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: github://pgjdbc/pgjdbc
Cc: [email protected], [email protected]
Subject: Re: [pgjdbc/pgjdbc] issue #3605: PgConnection.setSchema() does not support multiple schemas
In-Reply-To: <<[email protected]>>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox