-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
In Dialect.PostgreSql, when using the string concatenation operator (||), extra whitespace is inserted.
val res = SqlFormatter
.of(Dialect.PostgreSql)
.format("select aa || bb from zzz")
println(res)
// select
// aa | | bb
// ^
// from
// zzzIf you run dialectConfig.plusOperators("||"), no extra whitespace will be inserted.
val res = SqlFormatter
.of(Dialect.PostgreSql)
.extend { dialectConfig -> dialectConfig.plusOperators("||") }
.format("select aa || bb from zzz")
println(res)
// select
// aa || bb
// from
// zzzSimilar whitespace will be inserted in Dialect.N1ql and Dialect.TSql.
I can't judge whether the response is appropriate, but after applying the following patch, plusOperators("||") is no longer needed.
diff --git a/src/main/java/com/github/vertical_blank/sqlformatter/languages/PostgreSqlFormatter.java b/src/main/java/com/github/vertical_blank/sqlformatter/languages/PostgreSqlFormatter.java
index e8c4f0a..15e76ae 100644
--- a/src/main/java/com/github/vertical_blank/sqlformatter/languages/PostgreSqlFormatter.java
+++ b/src/main/java/com/github/vertical_blank/sqlformatter/languages/PostgreSqlFormatter.java
@@ -531,7 +531,7 @@ public class PostgreSqlFormatter extends AbstractFormatter {
.operators(
Arrays.asList(
"!=", "<<", ">>", "||/", "|/", "::", "->>", "->", "~~*", "~~", "!~~*", "!~~", "~*",
- "!~*", "!~", "!!", "@@", "@@@"))
+ "!~*", "!~", "!!", "@@", "@@@", "||"))
.build();
}vertical-blank
Metadata
Metadata
Assignees
Labels
No labels