Skip to content

Commit 3d4569f

Browse files
committed
fmt
1 parent 3c4f57c commit 3d4569f

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

src/424select.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ yy.Select.prototype.compileSelect2 = function (query, params) {
481481

482482
yy.Select.prototype.compileSelectGroup0 = function (query) {
483483
var self = this;
484-
484+
485485
// Build a lookup map for GROUP BY columns that reference aliases (optimization to avoid O(n*m) complexity)
486486
var groupByAliasMap = {};
487487
if (self.group) {
@@ -491,7 +491,7 @@ yy.Select.prototype.compileSelectGroup0 = function (query) {
491491
}
492492
});
493493
}
494-
494+
495495
self.columns.forEach(function (col, idx) {
496496
if (!(col instanceof yy.Column && col.columnid === '*')) {
497497
var colas;
@@ -519,7 +519,7 @@ yy.Select.prototype.compileSelectGroup0 = function (query) {
519519
if (groupIdx > -1) {
520520
self.group[groupIdx].nick = colas;
521521
}
522-
522+
523523
// Also match GROUP BY columns that reference SELECT column aliases
524524
// This handles cases like: SELECT CASE ... END AS age_group ... GROUP BY age_group
525525
if (col.as && groupByAliasMap.hasOwnProperty(col.as)) {

test/test2361.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,7 @@ describe('Test 2361 - GROUP BY with CASE expression alias', function () {
1717

1818
it('A) GROUP BY with CASE WHEN aliased expression', function () {
1919
// Create test data with ages
20-
var data = [
21-
{age: 25},
22-
{age: 26},
23-
{age: 35},
24-
{age: 36},
25-
{age: 45},
26-
{age: 55},
27-
];
20+
var data = [{age: 25}, {age: 26}, {age: 35}, {age: 36}, {age: 45}, {age: 55}];
2821

2922
var result = alasql(
3023
`SELECT
@@ -69,22 +62,13 @@ describe('Test 2361 - GROUP BY with CASE expression alias', function () {
6962
);
7063

7164
// Should return three unique groups, not just '30+'
72-
var expected = [
73-
{age_group: '10-19'},
74-
{age_group: '20-29'},
75-
{age_group: '30+'},
76-
];
65+
var expected = [{age_group: '10-19'}, {age_group: '20-29'}, {age_group: '30+'}];
7766

7867
assert.deepEqual(result.sort(), expected.sort());
7968
});
8069

8170
it('C) GROUP BY with function expression alias', function () {
82-
var data = [
83-
{name: 'Alice'},
84-
{name: 'alice'},
85-
{name: 'Bob'},
86-
{name: 'bob'},
87-
];
71+
var data = [{name: 'Alice'}, {name: 'alice'}, {name: 'Bob'}, {name: 'bob'}];
8872

8973
var result = alasql(
9074
`SELECT

0 commit comments

Comments
 (0)