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
> choice [TRFunction n
> <$> 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
> joinTrefSuffix t =
> (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
> ,joinText jt <+> tr t1
> ,joinCond jc]
> tr (TROdbc t) = text "{oj" <+> tr t <+> text "}"
> joinText jt =
> sep [case jt of
> JInner -> text "inner"

View file

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

View file

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