happy-sql 2.0.5 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +10 -0
- package/lib/parser/parser.js +9 -3
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/lib/parser/parser.js
CHANGED
|
@@ -26,21 +26,26 @@ const parseCstDialect = (source, dialect) => parseCst(source, {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
export const parseSql = (source) => {
|
|
29
|
+
let cst;
|
|
30
|
+
let error;
|
|
31
|
+
|
|
29
32
|
for (const dialect of DIALECTS) {
|
|
30
|
-
|
|
33
|
+
[error, cst] = tryCatch(parseCstDialect, source, dialect);
|
|
31
34
|
|
|
32
35
|
if (cst)
|
|
33
36
|
return convertSource(cst);
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
throw
|
|
39
|
+
throw error;
|
|
37
40
|
};
|
|
38
41
|
|
|
42
|
+
const isComment = ({text}) => text.startsWith('-- @');
|
|
43
|
+
|
|
39
44
|
const getSectionName = (leading) => {
|
|
40
45
|
if (!leading)
|
|
41
46
|
return null;
|
|
42
47
|
|
|
43
|
-
const comment = leading.find(
|
|
48
|
+
const comment = leading.find(isComment);
|
|
44
49
|
|
|
45
50
|
return comment ? comment.text
|
|
46
51
|
.slice(2)
|
|
@@ -86,3 +91,4 @@ const convertSource = (cst) => {
|
|
|
86
91
|
expressionStatement(arrayExpression(elements)),
|
|
87
92
|
]));
|
|
88
93
|
};
|
|
94
|
+
|