lemon-rs icon indicating copy to clipboard operation
lemon-rs copied to clipboard

support strange joins

Open MarinPostma opened this issue 1 year ago • 6 comments

Sqite has a rather flexible syntax for joins, and the parser should support them. This PR alleviate the restriction on joins, and make them more flexible.

see: https://www.sqlite.org/lang_select.html#strange_join_names

MarinPostma avatar Mar 07 '23 16:03 MarinPostma

@MarinPostma https://github.com/gwenn/lemon-rs/issues/23#issuecomment-1458636586 it looks like weird joins are fine on their own, looks like we hit another kind of issue

psarna avatar Mar 07 '23 18:03 psarna

No they aren't, for example, this is not supported by the parser, but should: SELECT * FROM foo LEFT NATURAL JOIN bar

MarinPostma avatar Mar 07 '23 19:03 MarinPostma

I am going to try fixing #23 first. https://www.sqlite.org/lang_select.html#strange_join_names

Remember: you can use these non-standard join types but you ought not. Stick to using standard JOIN syntax for portability with other SQL database engines.

And I am not sure we want to support these non-standard join types (like Double-Quoted String).

gwenn avatar Mar 08 '23 16:03 gwenn

It seems that the actual rules are here: https://github.com/sqlite/sqlite/blob/80511f32f7e71062026edd471913ef0455563964/src/select.c#L197-L257

The only restrictions on the join type name are:

  • "INNER" cannot appear together with "OUTER", "LEFT", "RIGHT", or "FULL".

  • "CROSS" cannot appear together with "OUTER", "LEFT", "RIGHT, or "FULL".

  • If "OUTER" is present then there must also be one of "LEFT", "RIGHT", or "FULL"

gwenn avatar Mar 12 '23 07:03 gwenn

I'll implement that 👍

MarinPostma avatar Mar 12 '23 12:03 MarinPostma

See #37

gwenn avatar Dec 03 '23 14:12 gwenn