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
Built-in functions read an unqualified column from the first table in a JOIN #2615
In a query with more than one source, an unqualified column used as an argument of a built-in function such as UPPER, LENGTH, ROUND or IFNULL is always read from the first source. If the column belongs to another source, the function gets undefined. No error is raised.
Reproduced on develop:
alasql("CREATE TABLE one (a INT, b INT); INSERT INTO one VALUES (1,10)");alasql("CREATE TABLE two (a INT, w STRING); INSERT INTO two VALUES (1,'x')");alasql('SELECT UPPER(w) AS u FROM one t0 JOIN two t1 ON t0.a = t1.a');// [{}] expected [{u: 'X'}]alasql('SELECT LENGTH(w) AS n FROM one t0 JOIN (SELECT a, w FROM two) t1 ON t0.a = t1.a');// [{}] expected [{n: 1}]alasql('SELECT UPPER(t1.w) AS u FROM one t0 JOIN two t1 ON t0.a = t1.a');// [{u: 'X'}] works when qualified
Cause
yy.FuncValue.prototype.toJS (src/55functions.js) compiles the arguments of alasql.stdlib functions with arg.toJS(context, tableid), without defcols. Without defcols, an unqualified column is looked up in the default (first) source. The other two branches of the same function (alasql.stdfn and user functions from alasql.fn) already pass defcols.
Activity
Pass defcols as argument to built-in functions to close #2615 (#2619)
Resolve a bare column inside a built-in function through the default …