happy-sql 2.0.3 → 2.0.5

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.5
2
+
3
+ fix:
4
+ - b1cf2b1 happy-sql: parser: where
5
+
6
+ 2026.08.20, v2.0.4
7
+
8
+ fix:
9
+ - 743d5c6 happy-sql: ";"
10
+
1
11
  2026.08.20, v2.0.3
2
12
 
3
13
  feature:
@@ -0,0 +1,3 @@
1
+ [
2
+ select(u.id, u.name, from(users as 'u', where(u.active === true))),
3
+ ];
@@ -0,0 +1,3 @@
1
+ SELECT u.id, u.name
2
+ FROM users AS u
3
+ WHERE u.active = true;
@@ -134,6 +134,13 @@ const flattenJoins = (node, joins = []) => {
134
134
  };
135
135
 
136
136
  export const convertFrom = ({expr, whereClause}) => {
137
+ const fromArgs = [];
138
+
139
+ if (whereClause)
140
+ fromArgs.push(callExpression(identifier('where'), [
141
+ convertCondition(whereClause.expr),
142
+ ]));
143
+
137
144
  if (expr.type === 'join_expr') {
138
145
  const parts = flattenJoins(expr);
139
146
  return callExpression(identifier('from'), parts);
@@ -142,16 +149,11 @@ export const convertFrom = ({expr, whereClause}) => {
142
149
  if (expr.type === 'alias')
143
150
  return callExpression(identifier('from'), [
144
151
  convertAlias(expr),
152
+ ...fromArgs,
145
153
  ]);
146
154
 
147
- const fromArgs = [
155
+ return callExpression(identifier('from'), [
148
156
  identifier(expr.name),
149
- ];
150
-
151
- if (whereClause)
152
- fromArgs.push(callExpression(identifier('where'), [
153
- convertCondition(whereClause.expr),
154
- ]));
155
-
156
- return callExpression(identifier('from'), fromArgs);
157
+ ...fromArgs,
158
+ ]);
157
159
  };
@@ -0,0 +1,3 @@
1
+ SELECT id
2
+ FROM Users
3
+ JOIN Orders ON Orders.user_id = Users.id
@@ -0,0 +1 @@
1
+ [select(id, from(Users, join(Orders, on(Orders.user_id === Users.id))))];
@@ -1,3 +1,3 @@
1
1
  -- @select
2
2
  SELECT *
3
- FROM users
3
+ FROM users;
@@ -1,8 +1,8 @@
1
1
  -- @fix
2
2
  UPDATE Identifier
3
3
  SET name = 'isNaN'
4
- WHERE id = :nan_id
4
+ WHERE id = :nan_id;
5
5
 
6
6
  UPDATE BinaryExpression
7
7
  SET operator = '==='
8
- WHERE id = :id
8
+ WHERE id = :id;
@@ -8,13 +8,12 @@ export const section = (path, {write, traverse}) => {
8
8
 
9
9
  for (const [i, element] of elements.entries()) {
10
10
  traverse(element);
11
-
12
- if (i < lastIndex)
13
- write('\n\n');
11
+ write(i < lastIndex ? ';\n\n' : ';');
14
12
  }
15
13
 
16
14
  return;
17
15
  }
18
16
 
19
17
  traverse(stmt);
18
+ write(';');
20
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "happy-sql",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "type": "module",
5
5
  "description": "sql to js ast parser and printer",
6
6
  "exports": {