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 CHANGED
@@ -1,3 +1,13 @@
1
+ 2026.08.20, v2.0.7
2
+
3
+ fix:
4
+ - 0ddbb26 happy-sql: parser: improve error message
5
+
6
+ 2026.08.20, v2.0.6
7
+
8
+ feature:
9
+ - eea70b5 @putout/parser: add source of incorrect sql
10
+
1
11
  2026.08.20, v2.0.5
2
12
 
3
13
  fix:
@@ -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
- const [, cst] = tryCatch(parseCstDialect, source, dialect);
33
+ [error, cst] = tryCatch(parseCstDialect, source, dialect);
31
34
 
32
35
  if (cst)
33
36
  return convertSource(cst);
34
37
  }
35
38
 
36
- throw Error('Cannot parse SQL');
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((c) => c.text.startsWith('-- @'));
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
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "happy-sql",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "type": "module",
5
5
  "description": "sql to js ast parser and printer",
6
6
  "exports": {