Skip to content

Commit 47488b1

Browse files
Add fatArrow => in Tokenizer
Currently the formatter adds a space between `=` and `>` whenever it formats a fatArrow. This PR fixes it.
1 parent 8ca53c1 commit 47488b1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/main/java/com/github/vertical_blank/sqlformatter/core/Tokenizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class Tokenizer {
4949
public Tokenizer(DialectConfig cfg) {
5050
this.WHITESPACE_REGEX = "^(\\s+)";
5151
this.NUMBER_REGEX = "^((-\\s*)?[0-9]+(\\.[0-9]+)?|0x[0-9a-fA-F]+|0b[01]+)\\b";
52-
this.OPERATOR_REGEX = "^(!=|<>|==|<=|>=|!<|!>|\\|\\||::|->>|->|~~\\*|~~|!~~\\*|!~~|~\\*|!~\\*|!~|.)";
52+
this.OPERATOR_REGEX = "^(!=|<>|==|<=|>=|!<|!>|\\|\\||::|->>|=>|->|~~\\*|~~|!~~\\*|!~~|~\\*|!~\\*|!~|.)";
5353

5454
// this.BLOCK_COMMENT_REGEX = /^(\/\*[^]*?(?:\*\/|$))/;
5555
this.BLOCK_COMMENT_REGEX = "^(/\\*(?s).*?(?:\\*/|$))";

src/test/java/com/github/vertical_blank/sqlformatter/SqlFormatterTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ public void withNamedParams() {
5858
" foo = 'bar'");
5959
}
6060

61+
@Test
62+
public void withFatArrow() {
63+
String format = SqlFormatter.format("SELECT * FROM tbl WHERE foo => '123'");
64+
assertEquals(format, "SELECT\n" +
65+
" *\n" +
66+
"FROM\n" +
67+
" tbl\n" +
68+
"WHERE\n" +
69+
" foo => '123'");
70+
}
71+
6172
@Test
6273
public void withIndexedParams() {
6374
String format = SqlFormatter.format("SELECT * FROM tbl WHERE foo = ?", Arrays.asList("'bar'"));

0 commit comments

Comments
 (0)