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
Let count, total, sum, avg, first, last, end and other keywords be names where they cannot be the keyword #2628
Some of the most common field names in JSON data cannot be used as names in AlaSQL: count, total, sum. SQLite (our reference engine) accepts them. Unlike the words in #2627, adding them to the NonReserved list is not enough, because each one already starts something valid at the same place. After SELECT, count can be the start of COUNT(...), so the parser has committed to the keyword before it sees that no ( follows.
Each word as a name in five places: CREATE TABLE t (w INT), SELECT w FROM t, WHERE w = 1, t.w and data->w. SQLite 3.43 accepts every word below as a column name.
Most valuable first: count, total, sum, avg, first, last, end.
In the grammar, let these tokens also reduce to a name when what follows cannot continue the keyword's own construct, for example COUNT not followed by (. A single shared rule for this keeps it in one place, like the NonReserved rule does for the simple words.
t.count and data->count can be handled first and separately: after . and -> only a name can follow, so there is no ambiguity there at all.
Words used after an expression (desc, asc, like) also meet the alias without AS (SELECT a desc FROM t). Decide per word what that reads as; SQLite's answer is the reference.
The grammar warnings must stay at 282, and yarn jison must reproduce the committed parser. Measure parse speed before and after with test/performance/bench.js ("parse mid-size select").
This only accepts SQL that fails to parse today, so it is not breaking.
Tests: test/test<id>.js with one it per word, covering the five places and INSERT INTO t (w) VALUES (1), plus the keyword's own use unchanged (COUNT(*), SELECT TOP 2, CASE ... END, ORDER BY a DESC).
Activity