Skip to content

IBM DB2 support #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 7, 2017
Prev Previous commit
Next Next commit
Write a separate test with clear description, explaining the @ and # …
…are part of identifiers
  • Loading branch information
Uku Pattak committed Jul 4, 2017
commit 15eb73faaed91c0acc91fa219bc7f717d4165a3c
17 changes: 15 additions & 2 deletions test/Db2FormatterTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,33 @@ describe("Db2Formatter", function() {

it("formats only -- as a line comment", function() {
const result = sqlFormatter.format(
"SELECT col#1 FROM\n" +
"SELECT col FROM\n" +
"-- This is a comment\n" +
"MyTable;\n",
{language: "db2"}
);
expect(result).toBe(
"SELECT\n" +
" col#1\n" +
" col\n" +
"FROM\n" +
" -- This is a comment\n" +
" MyTable;\n"
);
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also test the formatting of @ and # inside identifiers. This test partially covers the latter, but it would be better to have a separate test with clear description, explaining the @ and # are part of identifiers (e.g. not treated as operators).


it("recognizes @ and # as identifiers", function() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more correct to say: "as part of identifiers"

const result = sqlFormatter.format(
"SELECT col#1, @col2 FROM tbl\n"
);
expect(result).toBe(
"SELECT\n" +
" col#1,\n" +
" @col2\n" +
"FROM\n" +
" tbl\n"
);
});

it("recognizes :variables", function() {
expect(sqlFormatter.format("SELECT :variable;", {language: "db2"})).toBe(
"SELECT\n" +
Expand Down