You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GROUP BY with a column selected twice adds keys c0:1, c0:2 to the result rows #2770
With GROUP BY, a column selected twice under the same name adds internal keys to the result row: c0:1, c0:2 and so on. They show in rows as objects and in the columns of RECORDSET. When one of the copies has an alias, MATRIX gets one value too many. Without GROUP BY, the same select list gives one key, as expected for rows as objects. Seen in the sqllogictest run (test/random/groupby/, for example SELECT col1 AS col0, col1 FROM tab0 GROUP BY col1), reproduced on develop (06211a0) and npm 4.20.1, compared with SQLite 3.43.2:
alasql('CREATE TABLE t (c0 INT)');alasql('INSERT INTO t VALUES (15), (91)');
Query
AlaSQL
SQLite (.values())
SELECT c0, c0 FROM t
[{c0: 15}, {c0: 91}]
[[15, 15], [91, 91]]
SELECT c0, c0 FROM t GROUP BY c0
[{c0: 15, 'c0:1': 15}, ...]
[[15, 15], [91, 91]]
SELECT c0, c0, c0 FROM t GROUP BY c0
keys c0, c0:1, c0:2
three values
SELECT c0, COUNT(*), c0 FROM t GROUP BY c0
keys c0, COUNT(*), c0:2
three values
SELECT c0 AS a, c0 FROM t GROUP BY c0
keys a, c0, c0:1
two values
MATRIX OF SELECT c0 AS a, c0 FROM t GROUP BY c0
[[15, 15, 15], ...]
[[15, 15], ...]
MATRIX OF SELECT c0, c0 FROM t GROUP BY c0
[[15, 15], ...]
[[15, 15], ...]
RECORDSET OF SELECT c0, c0 FROM t GROUP BY c0
columns c0, c0:1
SELECT c0 AS a, c0 AS b FROM t GROUP BY c0
[{a: 15, b: 15}, ...]
Not breaking: the extra keys are internal names that leak into the result; with distinct aliases (the way #1262 was answered) the row is right. Related: #2726 (internal keys in result rows), #2765 (two result columns with the same name).
Activity