The github sqlite3 grammar github.com/antlr/grammars-v4/blob/master/sqlite/SQLite.g4 has issue with left join.
For this sql
select * from t1 left join t2 on t1.owner = t2.email
the word 'left' is parsed as a table_alias. Things go rapidly downhill from there
I think I can fix it by somehow saying that table_alias
is any_name
except K_LEFT, K_RIGHT, K_INNER but I do not know how to express that in a grammar
Or maybe there is a better way to fix this
UPDATE. Just to clarify sqlite behavior. (Not talking about antlr , talking about what sqlite understands)
this
select username from user left join device on device.owner = user.id limit 2
works.
This
select username from user alias join device on device.owner = user.id limit 2
fails saying that the column user.id doesn't exist.
Clearly the word 'left' is being recognized as a keyword not a table alias.
select username from user alias join device on device.owner = alias.id limit 2
Works, and does an inner join
select username from user alias left join device on device.owner = user.id limit 2
works and does a left join
Further update for @Mike Lischke
select username from user left where device.owner = left.id limit 2
Fails. "Query has failed: near "where": syntax error".