Skip to content

Commit 076761a

Browse files
committed
Some minor fixes
1 parent d6a294d commit 076761a

File tree

3 files changed

+7
-37
lines changed

3 files changed

+7
-37
lines changed

src/core/Tokenizer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default class Tokenizer {
5454
// 2. square bracket quoted string (SQL Server) using ]] to escape
5555
// 3. double quoted string using "" or \" to escape
5656
// 4. single quoted string using '' or \' to escape
57-
// 5. national character single quoted string using N'' or \' to escape
57+
// 5. national character quoted string using N'' or N\' to escape
5858
createStringPattern(stringTypes) {
5959
const patterns = {
6060
"\"\"": "((\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*(\"|$))+)",

test/StandardSqlFormatterTest.js

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -210,41 +210,10 @@ describe("StandardSqlFormatter", function() {
210210
);
211211
});
212212

213-
it("formats simple SELECT with national character (MSSQL)", function() {
214-
const result = sqlFormatter.format(
215-
"SELECT N'value';"
216-
);
217-
expect(result).toBe(
218-
"SELECT\n" +
219-
" N'value';\n"
220-
);
221-
});
222-
223213
it("formats SELECT with complex WHERE", function() {
224214
const result = sqlFormatter.format(
225-
"SELECT * FROM foo WHERE Column1 = 'testing' " +
226-
"AND ( (Column2 = Column3 OR Column4 >= NOW()) );"
227-
);
228-
expect(result).toBe(
229-
"SELECT\n" +
230-
" *\n" +
231-
"FROM\n" +
232-
" foo\n" +
233-
"WHERE\n" +
234-
" Column1 = 'testing'\n" +
235-
" AND (\n" +
236-
" (\n" +
237-
" Column2 = Column3\n" +
238-
" OR Column4 >= NOW()\n" +
239-
" )\n" +
240-
" );\n"
241-
);
242-
});
243-
244-
it("formats SELECT with complex WHERE with national characters (MSSQL)", function() {
245-
const result = sqlFormatter.format(
246-
"SELECT * FROM foo WHERE Column1 = N'testing' " +
247-
"AND ( (Column2 = Column3 OR Column4 >= NOW()) );"
215+
"SELECT * FROM foo WHERE Column1 = N'testing' AND Column2 = 'testing'" +
216+
"AND ( (Column3 = Column4 OR Column5 >= NOW()) );"
248217
);
249218
expect(result).toBe(
250219
"SELECT\n" +
@@ -253,10 +222,11 @@ describe("StandardSqlFormatter", function() {
253222
" foo\n" +
254223
"WHERE\n" +
255224
" Column1 = N'testing'\n" +
225+
" AND Column2 = 'testing'\n" +
256226
" AND (\n" +
257227
" (\n" +
258-
" Column2 = Column3\n" +
259-
" OR Column4 >= NOW()\n" +
228+
" Column3 = Column4\n" +
229+
" OR Column5 >= NOW()\n" +
260230
" )\n" +
261231
" );\n"
262232
);

test/behavesLikeSqlFormatter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function behavesLikeSqlFormatter(language) {
88
it("uses given indent config for indention", function() {
99
const result = sqlFormatter.format(
1010
"SELECT count(*),Column1 FROM Table1;",
11-
{ language, indent: " " }
11+
{language, indent: " "}
1212
);
1313

1414
expect(result).toBe(

0 commit comments

Comments
 (0)