The order in which table aliases are references in the where clause must match the order in which the aliases are declared. For example:
select a.id
from aaa as a, bbb as b
where b.id = 7 and a.name = b.name;
returns the error message Cannot read property 'alias' of undefined however the structurally equivalent form (with the match on a.id instead of b.id)
select a.id
from aaa as a, bbb as b
where a.id = 7 and a.name = b.name;
produces no error.