1
Fork 0

add support for odbc outer join syntax

This commit is contained in:
Jake Wheat 2016-02-21 23:48:55 +02:00
parent c8d745fd28
commit 83b16edb1f
4 changed files with 19 additions and 12 deletions

View file

@ -1356,7 +1356,11 @@ aliases.
> n <- names > n <- names
> choice [TRFunction n > choice [TRFunction n
> <$> parens (commaSep valueExpr) > <$> parens (commaSep valueExpr)
> ,pure $ TRSimple n]] <??> aliasSuffix > ,pure $ TRSimple n]
> -- todo: I think you can only have outer joins inside the oj,
> -- not sure.
> ,TROdbc <$> (symbol "{" *> keyword_ "oj" *> tref <* symbol "}")
> ] <??> aliasSuffix
> aliasSuffix = fromAlias <$$> TRAlias > aliasSuffix = fromAlias <$$> TRAlias
> joinTrefSuffix t = > joinTrefSuffix t =
> (TRJoin t <$> option False (True <$ keyword_ "natural") > (TRJoin t <$> option False (True <$ keyword_ "natural")

View file

@ -390,6 +390,7 @@ which have been changed to try to improve the layout of the output.
> ,if b then text "natural" else empty > ,if b then text "natural" else empty
> ,joinText jt <+> tr t1 > ,joinText jt <+> tr t1
> ,joinCond jc] > ,joinCond jc]
> tr (TROdbc t) = text "{oj" <+> tr t <+> text "}"
> joinText jt = > joinText jt =
> sep [case jt of > sep [case jt of
> JInner -> text "inner" > JInner -> text "inner"

View file

@ -430,6 +430,8 @@ I'm not sure if this is valid syntax or not.
> | TRFunction [Name] [ValueExpr] > | TRFunction [Name] [ValueExpr]
> -- | from lateral t > -- | from lateral t
> | TRLateral TableRef > | TRLateral TableRef
> -- | ODBC {oj t1 left outer join t2 on expr} syntax
> | TROdbc TableRef
> deriving (Eq,Show,Read,Data,Typeable) > deriving (Eq,Show,Read,Data,Typeable)
> -- | Represents an alias for a table valued expression, used in with > -- | Represents an alias for a table valued expression, used in with

View file

@ -28,21 +28,21 @@
> [OdbcFunc (ap "CURDATE" []) > [OdbcFunc (ap "CURDATE" [])
> ,iden "SQL_DATE"]) > ,iden "SQL_DATE"])
> ] > ]
> {-,Group "outer join" [ > ,Group "outer join" [
> ParseQueryExpr defaultParseFlags > TestQueryExpr ansi2011 {allowOdbc=True}
> "select * from {oj t1 left outer join t2 on true}" > "select * from {oj t1 left outer join t2 on expr}"
> $ makeSelect > $ makeSelect
> {selSelectList = sl [si $ Star ea] > {qeSelectList = [(Star,Nothing)]
> ,selTref = [OdbcTableRef ea (JoinTref ea (tref "t1") Unnatural LeftOuter Nothing > ,qeFrom = [TROdbc $ TRJoin (TRSimple [Name Nothing "t1"]) False JLeft (TRSimple [Name Nothing "t2"])
> (tref "t2") (Just $ JoinOn ea (BooleanLit ea True)))]}] > (Just $ JoinOn $ Iden [Name Nothing "expr"])]}]
> ,Group "check parsing bugs" [ > ,Group "check parsing bugs" [
> ParseQueryExpr defaultParseFlags > TestQueryExpr ansi2011 {allowOdbc=True}
> "select {fn CONVERT(cint,SQL_BIGINT)} from t;" > "select {fn CONVERT(cint,SQL_BIGINT)} from t;"
> $ makeSelect > $ makeSelect
> {selSelectList = sl [si $ OdbcFunc ea (App ea (name "CONVERT") > {qeSelectList = [(OdbcFunc (ap "CONVERT"
> [ei "cint" > [iden "cint"
> ,ei "SQL_BIGINT"])] > ,iden "SQL_BIGINT"]), Nothing)]
> ,selTref = [tref "t"]}]-} > ,qeFrom = [TRSimple [Name Nothing "t"]]}]
> ] > ]
> where > where
> e = TestValueExpr ansi2011 {allowOdbc = True} > e = TestValueExpr ansi2011 {allowOdbc = True}