add support for full table aliases
This commit is contained in:
parent
d005dc1706
commit
15c83555ff
4 changed files with 11 additions and 6 deletions
Language/SQL/SimpleSQL
|
@ -507,7 +507,8 @@ attempt to fix the precedence and associativity. Doesn't work
|
|||
> ,return Nothing
|
||||
> ]
|
||||
> alias j = let a1 = optional (try (keyword_ "as")) *> identifierString
|
||||
> in option j (JoinAlias j <$> try a1)
|
||||
> a2 = optionMaybe (try $ parens (commaSep1 identifierString))
|
||||
> in option j (JoinAlias j <$> try a1 <*> try a2)
|
||||
|
||||
> optionalScalarExpr :: String -> P (Maybe ScalarExpr)
|
||||
> optionalScalarExpr k = optionMaybe (try (keyword_ k) *> scalarExpr)
|
||||
|
|
|
@ -157,7 +157,9 @@ back into SQL source text. It attempts to format the output nicely.
|
|||
> ,nest 4 $ commaSep $ map tr ts]
|
||||
> where
|
||||
> tr (SimpleTableRef t) = text t
|
||||
> tr (JoinAlias t a) = tr t <+> text "as" <+> text a
|
||||
> tr (JoinAlias t a cs) =
|
||||
> tr t <+> text "as" <+> text a
|
||||
> <+> maybe empty (\cs' -> parens $ commaSep $ map text cs') cs
|
||||
> tr (JoinParens t) = parens $ tr t
|
||||
> tr (JoinQueryExpr q) = parens $ queryExpr q
|
||||
> tr (JoinTableRef jt t0 t1 jc) =
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
> data TableRef = SimpleTableRef String
|
||||
> | JoinTableRef JoinType TableRef TableRef (Maybe JoinCondition)
|
||||
> | JoinParens TableRef
|
||||
> | JoinAlias TableRef String
|
||||
> | JoinAlias TableRef String (Maybe [String])
|
||||
> | JoinQueryExpr QueryExpr
|
||||
> deriving (Eq,Show)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue