1
Fork 0

parse a join b without inner

This commit is contained in:
Jake Wheat 2013-12-17 12:27:00 +02:00
parent 9461a11c97
commit adfeac8d16
3 changed files with 16 additions and 11 deletions

View file

@ -518,14 +518,16 @@ tref
> <*> nonJoinTref
> <*> optionMaybe (joinCondition nat))
> >>= optionSuffix joinTrefSuffix
> joinType = choice
> [JCross <$ try (keyword_ "cross")
> ,JInner <$ try (keyword_ "inner")
> ,choice [JLeft <$ try (keyword_ "left")
> ,JRight <$ try (keyword_ "right")
> ,JFull <$ try (keyword_ "full")]
> <* optional (try $ keyword_ "outer")]
> <* keyword "join"
> joinType =
> choice [choice
> [JCross <$ try (keyword_ "cross")
> ,JInner <$ try (keyword_ "inner")
> ,choice [JLeft <$ try (keyword_ "left")
> ,JRight <$ try (keyword_ "right")
> ,JFull <$ try (keyword_ "full")]
> <* optional (try $ keyword_ "outer")]
> <* keyword "join"
> ,JInner <$ keyword_ "join"]
> joinCondition nat =
> choice [guard nat >> return JoinNatural
> ,try (keyword_ "on") >>

View file

@ -47,9 +47,8 @@ queries section
> ,"SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num AND t2.value = 'xxx';"
> ,"SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num WHERE t2.value = 'xxx';"
> --,"SELECT * FROM some_very_long_table_name s JOIN another_fairly_long_name a ON s.id = a.num;"
> -- issue with join keyword on its own?
> --,"SELECT * FROM people AS mother JOIN people AS child ON mother.id = child.mother_id;"
> ,"SELECT * FROM some_very_long_table_name s JOIN another_fairly_long_name a ON s.id = a.num;"
> ,"SELECT * FROM people AS mother JOIN people AS child ON mother.id = child.mother_id;"
> ,"SELECT * FROM my_table AS a CROSS JOIN my_table AS b;"
> ,"SELECT * FROM (my_table AS a CROSS JOIN my_table) AS b;"
> --,"SELECT * FROM getfoo(1) AS t1;" -- function tableref

View file

@ -20,6 +20,10 @@ expression
> ,ms [TRJoin (TRSimple "t") JInner (TRSimple "u")
> (Just $ JoinOn $ Iden "expr")])
> ,("select a from t join u on expr"
> ,ms [TRJoin (TRSimple "t") JInner (TRSimple "u")
> (Just $ JoinOn $ Iden "expr")])
> ,("select a from t left join u on expr"
> ,ms [TRJoin (TRSimple "t") JLeft (TRSimple "u")
> (Just $ JoinOn $ Iden "expr")])