happy-sql 1.1.0 → 1.1.1

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,8 @@
1
+ 2026.07.27, v1.1.1
2
+
3
+ feature:
4
+ - e88833c happy-sql: count: 1
5
+
1
6
  2026.07.27, v1.1.0
2
7
 
3
8
  feature:
package/README.md CHANGED
@@ -24,8 +24,7 @@ const source = `select(count('*'), from(users))`;
24
24
 
25
25
  convertJsToSql(source);
26
26
  // returns
27
- 'SELECT COUNT(*)\nFROM users\n');
28
-
27
+ 'SELECT COUNT(*)\nFROM users\n';
29
28
  ```
30
29
 
31
30
  ## License
@@ -4,8 +4,12 @@ const {
4
4
  stringLiteral,
5
5
  callExpression,
6
6
  identifier,
7
+ numericLiteral,
7
8
  } = types;
8
9
 
10
+ const isAllColumns = ({type}) => type === 'all_columns';
11
+ const isNumericLiteral = ({type}) => type === 'number_literal';
12
+
9
13
  export const isCount = (column) => {
10
14
  return column.type === 'func_call' && /count/i.test(column.name.name);
11
15
  };
@@ -15,8 +19,15 @@ export const convertCount = (column) => {
15
19
  const args = [];
16
20
 
17
21
  for (const item of items) {
18
- if (item.type === 'all_columns')
22
+ if (isAllColumns(item)) {
19
23
  args.push(stringLiteral('*'));
24
+ continue;
25
+ }
26
+
27
+ if (isNumericLiteral(item)) {
28
+ const {value} = item;
29
+ args.push(numericLiteral(value));
30
+ }
20
31
  }
21
32
 
22
33
  return callExpression(identifier('count'), args);
@@ -0,0 +1,3 @@
1
+ [
2
+ select(count(1), from(users)),
3
+ ];
@@ -0,0 +1 @@
1
+ SELECT COUNT(1) FROM users
@@ -0,0 +1,2 @@
1
+ SELECT COUNT(1)
2
+ FROM users
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "happy-sql",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "description": "sql to js ast parser and printer",
6
6
  "exports": {