Skip to content

Commit 2acdf48

Browse files
authored
Merge pull request #24 from sasha-alias/master
Adding Postgres specific operators
2 parents 74d0459 + 1bbce98 commit 2acdf48

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/core/Tokenizer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class Tokenizer {
1919
this.LINE_COMMENT_REGEX = /^((?:#|--).*?(?:\n|$))/;
2020
this.BLOCK_COMMENT_REGEX = /^(\/\*[^]*?(?:\*\/|$))/;
2121
this.NUMBER_REGEX = /^((-\s*)?[0-9]+(\.[0-9]+)?|0x[0-9a-fA-F]+|0b[01]+)\b/;
22-
this.OPERATOR_REGEX = /^(!=|<>|==|<=|>=|!<|!>|\|\||.)/;
22+
this.OPERATOR_REGEX = /^(!=|<>|==|<=|>=|!<|!>|\|\||::|->>|->|.)/;
2323

2424
this.RESERVED_TOPLEVEL_REGEX = this.createReservedWordRegex(cfg.reservedToplevelWords);
2525
this.RESERVED_NEWLINE_REGEX = this.createReservedWordRegex(cfg.reservedNewlineWords);

test/behavesLikeSqlFormatter.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,10 @@ export default function behavesLikeSqlFormatter(language) {
432432
expect(format("'foo \\' JOIN bar'")).toBe("'foo \\' JOIN bar'\n");
433433
expect(format("`foo `` JOIN bar`")).toBe("`foo `` JOIN bar`\n");
434434
});
435+
436+
it("formats postgres specific operators", function() {
437+
expect(format("column::int")).toBe("column :: int\n");
438+
expect(format("v->2")).toBe("v -> 2\n");
439+
expect(format("v->>2")).toBe( "v ->> 2\n");
440+
});
435441
}

0 commit comments

Comments
 (0)