happy-sql 1.1.0 → 1.2.0
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/README.md +1 -2
- package/lib/parser/visitors/clause/count/count.js +12 -1
- package/lib/parser/visitors/clause/count/fixture/count-one-fix.js +3 -0
- package/lib/parser/visitors/clause/count/fixture/count-one.sql +1 -0
- package/lib/printer/visitors/call-expression/clauses/count/fixture/count-one.sql +2 -0
- package/lib/printer/visitors/call-expression/clauses/section/fixture/section-fix.sql +1 -1
- package/lib/printer/visitors/call-expression/clauses/section/section.js +1 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -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
|
|
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 @@
|
|
|
1
|
+
SELECT COUNT(1) FROM users
|