Skip to content

Commit d60d204

Browse files
authored
Merge pull request #27 from rahelest/master
Remove addition of newline to end of output.
2 parents 4a265a4 + af41eca commit d60d204

File tree

5 files changed

+96
-96
lines changed

5 files changed

+96
-96
lines changed

src/core/Formatter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class Formatter {
3030
const tokens = this.tokenizer.tokenize(query);
3131
const formattedQuery = this.getFormattedQueryFromTokens(tokens);
3232

33-
return formattedQuery.trim() + "\n";
33+
return formattedQuery.trim();
3434
}
3535

3636
getFormattedQueryFromTokens(tokens) {

test/Db2FormatterTest.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe("Db2Formatter", function() {
1616
"ORDER BY\n" +
1717
" col2 DESC\n" +
1818
"FETCH FIRST\n" +
19-
" 20 ROWS ONLY;\n"
19+
" 20 ROWS ONLY;"
2020
);
2121
});
2222

@@ -32,7 +32,7 @@ describe("Db2Formatter", function() {
3232
" col\n" +
3333
"FROM\n" +
3434
" -- This is a comment\n" +
35-
" MyTable;\n"
35+
" MyTable;"
3636
);
3737
});
3838

@@ -46,14 +46,14 @@ describe("Db2Formatter", function() {
4646
" col#1,\n" +
4747
" @col2\n" +
4848
"FROM\n" +
49-
" tbl\n"
49+
" tbl"
5050
);
5151
});
5252

5353
it("recognizes :variables", function() {
5454
expect(sqlFormatter.format("SELECT :variable;", {language: "db2"})).toBe(
5555
"SELECT\n" +
56-
" :variable;\n"
56+
" :variable;"
5757
);
5858
});
5959

@@ -64,7 +64,7 @@ describe("Db2Formatter", function() {
6464
);
6565
expect(result).toBe(
6666
"SELECT\n" +
67-
" \"variable value\"\n"
67+
" \"variable value\""
6868
);
6969
});
7070
});

test/N1qlFormatterTest.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe("N1qlFormatter", function() {
1010
"SELECT\n" +
1111
" orderlines[0].productId\n" +
1212
"FROM\n" +
13-
" orders;\n"
13+
" orders;"
1414
);
1515
});
1616

@@ -26,7 +26,7 @@ describe("N1qlFormatter", function() {
2626
"FROM\n" +
2727
" tutorial\n" +
2828
"USE KEYS\n" +
29-
" ['dave', 'ian'];\n"
29+
" ['dave', 'ian'];"
3030
);
3131
});
3232

@@ -39,7 +39,7 @@ describe("N1qlFormatter", function() {
3939
"INSERT INTO\n" +
4040
" heroes (KEY, VALUE)\n" +
4141
"VALUES\n" +
42-
" ('123', {'id': 1, 'type': 'Tarzan'});\n"
42+
" ('123', {'id': 1, 'type': 'Tarzan'});"
4343
);
4444
});
4545

@@ -67,7 +67,7 @@ describe("N1qlFormatter", function() {
6767
" ],\n" +
6868
" 'hello': 'world'\n" +
6969
" }\n" +
70-
" );\n"
70+
" );"
7171
);
7272
});
7373

@@ -82,7 +82,7 @@ describe("N1qlFormatter", function() {
8282
"FROM\n" +
8383
" tutorial\n" +
8484
"UNNEST\n" +
85-
" tutorial.children c;\n"
85+
" tutorial.children c;"
8686
);
8787
});
8888

@@ -101,7 +101,7 @@ describe("N1qlFormatter", function() {
101101
"USE KEYS\n" +
102102
" 'Elinor_33313792'\n" +
103103
"NEST\n" +
104-
" orders_with_users orders ON KEYS ARRAY s.order_id FOR s IN usr.shipped_order_history END;\n"
104+
" orders_with_users orders ON KEYS ARRAY s.order_id FOR s IN usr.shipped_order_history END;"
105105
);
106106
});
107107

@@ -114,7 +114,7 @@ describe("N1qlFormatter", function() {
114114
"EXPLAIN DELETE FROM\n" +
115115
" tutorial t\n" +
116116
"USE KEYS\n" +
117-
" 'baldwin' RETURNING t\n"
117+
" 'baldwin' RETURNING t"
118118
);
119119
});
120120

@@ -129,7 +129,7 @@ describe("N1qlFormatter", function() {
129129
"USE KEYS\n" +
130130
" 'baldwin'\n" +
131131
"SET\n" +
132-
" type = 'actor' RETURNING tutorial.type\n"
132+
" type = 'actor' RETURNING tutorial.type"
133133
);
134134
});
135135

@@ -143,7 +143,7 @@ describe("N1qlFormatter", function() {
143143
" $variable,\n" +
144144
" $'var name',\n" +
145145
" $\"var name\",\n" +
146-
" $`var name`;\n"
146+
" $`var name`;"
147147
);
148148
});
149149

@@ -162,7 +162,7 @@ describe("N1qlFormatter", function() {
162162
" \"variable value\",\n" +
163163
" 'var value',\n" +
164164
" 'var value',\n" +
165-
" 'var value';\n"
165+
" 'var value';"
166166
);
167167
});
168168

@@ -179,7 +179,7 @@ describe("N1qlFormatter", function() {
179179
"SELECT\n" +
180180
" second,\n" +
181181
" third,\n" +
182-
" first;\n"
182+
" first;"
183183
);
184184
});
185185
});

test/StandardSqlFormatterTest.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe("StandardSqlFormatter", function() {
1212
"ALTER TABLE\n" +
1313
" supplier\n" +
1414
"MODIFY\n" +
15-
" supplier_name char(100) NOT NULL;\n"
15+
" supplier_name char(100) NOT NULL;"
1616
);
1717
});
1818

@@ -24,13 +24,13 @@ describe("StandardSqlFormatter", function() {
2424
"ALTER TABLE\n" +
2525
" supplier\n" +
2626
"ALTER COLUMN\n" +
27-
" supplier_name VARCHAR(100) NOT NULL;\n"
27+
" supplier_name VARCHAR(100) NOT NULL;"
2828
);
2929
});
3030

3131
it("recognizes [] strings", function() {
32-
expect(sqlFormatter.format("[foo JOIN bar]")).toBe("[foo JOIN bar]\n");
33-
expect(sqlFormatter.format("[foo ]] JOIN bar]")).toBe("[foo ]] JOIN bar]\n");
32+
expect(sqlFormatter.format("[foo JOIN bar]")).toBe("[foo JOIN bar]");
33+
expect(sqlFormatter.format("[foo ]] JOIN bar]")).toBe("[foo ]] JOIN bar]");
3434
});
3535

3636
it("recognizes @variables", function() {
@@ -44,7 +44,7 @@ describe("StandardSqlFormatter", function() {
4444
" @'var name',\n" +
4545
" @\"var name\",\n" +
4646
" @`var name`,\n" +
47-
" @[var name];\n"
47+
" @[var name];"
4848
);
4949
});
5050

@@ -68,7 +68,7 @@ describe("StandardSqlFormatter", function() {
6868
" 'var value',\n" +
6969
" 'var value',\n" +
7070
" 'var value',\n" +
71-
" 'var\\ value';\n"
71+
" 'var\\ value';"
7272
);
7373
});
7474

@@ -83,7 +83,7 @@ describe("StandardSqlFormatter", function() {
8383
" :'var name',\n" +
8484
" :\"var name\",\n" +
8585
" :`var name`,\n" +
86-
" :[var name];\n"
86+
" :[var name];"
8787
);
8888
});
8989

@@ -110,7 +110,7 @@ describe("StandardSqlFormatter", function() {
110110
" 'var value',\n" +
111111
" 'var value',\n" +
112112
" 'weirder value',\n" +
113-
" 'super weird value';\n"
113+
" 'super weird value';"
114114
);
115115
});
116116

@@ -120,7 +120,7 @@ describe("StandardSqlFormatter", function() {
120120
"SELECT\n" +
121121
" ?1,\n" +
122122
" ?25,\n" +
123-
" ?;\n"
123+
" ?;"
124124
);
125125
});
126126

@@ -136,7 +136,7 @@ describe("StandardSqlFormatter", function() {
136136
"SELECT\n" +
137137
" second,\n" +
138138
" third,\n" +
139-
" first;\n"
139+
" first;"
140140
);
141141
});
142142

@@ -148,7 +148,7 @@ describe("StandardSqlFormatter", function() {
148148
"SELECT\n" +
149149
" first,\n" +
150150
" second,\n" +
151-
" third;\n"
151+
" third;"
152152
);
153153
});
154154

@@ -161,7 +161,7 @@ describe("StandardSqlFormatter", function() {
161161
" 1\n" +
162162
"GO\n" +
163163
"SELECT\n" +
164-
" 2\n"
164+
" 2"
165165
);
166166
});
167167

@@ -175,7 +175,7 @@ describe("StandardSqlFormatter", function() {
175175
" b\n" +
176176
"FROM\n" +
177177
" t\n" +
178-
" CROSS JOIN t2 on t.id = t2.id_t\n"
178+
" CROSS JOIN t2 on t.id = t2.id_t"
179179
);
180180
});
181181

@@ -189,7 +189,7 @@ describe("StandardSqlFormatter", function() {
189189
" b\n" +
190190
"FROM\n" +
191191
" t\n" +
192-
" CROSS APPLY fn(t.id)\n"
192+
" CROSS APPLY fn(t.id)"
193193
);
194194
});
195195

@@ -200,15 +200,15 @@ describe("StandardSqlFormatter", function() {
200200
" N,\n" +
201201
" M\n" +
202202
"FROM\n" +
203-
" t\n"
203+
" t"
204204
);
205205
});
206206

207207
it("formats simple SELECT with national characters (MSSQL)", function() {
208208
const result = sqlFormatter.format("SELECT N'value'");
209209
expect(result).toBe(
210210
"SELECT\n" +
211-
" N'value'\n"
211+
" N'value'"
212212
);
213213
});
214214

@@ -222,7 +222,7 @@ describe("StandardSqlFormatter", function() {
222222
" b\n" +
223223
"FROM\n" +
224224
" t\n" +
225-
" OUTER APPLY fn(t.id)\n"
225+
" OUTER APPLY fn(t.id)"
226226
);
227227
});
228228

@@ -231,7 +231,7 @@ describe("StandardSqlFormatter", function() {
231231
"SELECT\n" +
232232
" a #comment, here\n" +
233233
"FROM\n" +
234-
" b --comment\n"
234+
" b --comment"
235235
);
236236
});
237237
});

0 commit comments

Comments
 (0)