Skip to content

Commit

Permalink
fix; do not add double quotes to identifiers already double quoted fi…
Browse files Browse the repository at this point in the history
…xes Issue pgjdbc#2223
  • Loading branch information
davecramer committed Aug 9, 2021
1 parent 151b287 commit a40f1b2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pgjdbc/src/main/java/org/postgresql/core/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ public static StringBuilder escapeIdentifier(@Nullable StringBuilder sbuf, Strin
* @param value value to append
*/
private static void doAppendEscapedIdentifier(Appendable sbuf, String value) throws SQLException {

boolean alreadyQuoted = value.startsWith("\"") && value.endsWith("\"");

try {
sbuf.append('"');
if ( !alreadyQuoted ) {
sbuf.append('"');
}

for (int i = 0; i < value.length(); ++i) {
char ch = value.charAt(i);
Expand All @@ -146,7 +151,9 @@ private static void doAppendEscapedIdentifier(Appendable sbuf, String value) thr
sbuf.append(ch);
}

sbuf.append('"');
if ( !alreadyQuoted ) {
sbuf.append('"');
}
} catch (IOException e) {
throw new PSQLException(GT.tr("No IOException expected from StringBuffer or StringBuilder"),
PSQLState.UNEXPECTED_ERROR, e);
Expand Down

0 comments on commit a40f1b2

Please sign in to comment.