forked from florajs/sql-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroupby.spec.js
More file actions
25 lines (21 loc) · 859 Bytes
/
Copy pathgroupby.spec.js
File metadata and controls
25 lines (21 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict';
const { describe, it } = require('node:test');
const assert = require('node:assert/strict');
const { Parser, util } = require('../../');
const { getParsedSql } = require('./util');
describe('group clause', () => {
it('should support single expressions', () => {
assert.equal(getParsedSql('SELECT a FROM t group by t.b'), 'SELECT "a" FROM "t" GROUP BY "t"."b"');
});
it('should support multiple expressions', () => {
assert.equal(
getParsedSql('SELECT a FROM t GROUP BY t.b, t.c'),
'SELECT "a" FROM "t" GROUP BY "t"."b", "t"."c"'
);
});
it('should not generate an empty GROUP BY clause on empty arrays', () => {
const ast = new Parser().parse('SELECT a FROM t');
ast.groupby = [];
assert.equal(util.astToSQL(ast), 'SELECT "a" FROM "t"');
});
});