1
Fork 0

support character set literals, e.g. N'stuff'

support collate postfix operator
support escape and uescape as postfix operators
change the collate support in substring and trim which isn't a special
  case in the sql 2003 grammar anymore but just a normal collate postfix
  operator, the old code had the collation name as a string, but the
  new style is as an identifier
This commit is contained in:
Jake Wheat 2014-04-18 00:16:24 +03:00
parent 211174cfb4
commit 37dca6596b
5 changed files with 90 additions and 34 deletions
Language/SQL/SimpleSQL

View file

@ -34,9 +34,6 @@ which have been changed to try to improve the layout of the output.
> valueExpr :: ValueExpr -> Doc
> valueExpr (StringLit s) = quotes $ text $ doubleUpQuotes s
> where doubleUpQuotes [] = []
> doubleUpQuotes ('\'':cs) = '\'':'\'':doubleUpQuotes cs
> doubleUpQuotes (c:cs) = c:doubleUpQuotes cs
> valueExpr (NumLit s) = text s
> valueExpr (IntervalLit v u p) =
@ -177,6 +174,24 @@ which have been changed to try to improve the layout of the output.
> valueExpr (ArrayCtor q) =
> text "array" <> parens (queryExpr q)
> valueExpr (CSStringLit cs st) =
> text cs <> quotes (text $ doubleUpQuotes st)
> valueExpr (Escape v e) =
> valueExpr v <+> text "escape" <+> text [e]
> valueExpr (UEscape v e) =
> valueExpr v <+> text "uescape" <+> text [e]
> valueExpr (Collate v c) =
> valueExpr v <+> text "collate" <+> text c
> doubleUpQuotes :: String -> String
> doubleUpQuotes [] = []
> doubleUpQuotes ('\'':cs) = '\'':'\'':doubleUpQuotes cs
> doubleUpQuotes (c:cs) = c:doubleUpQuotes cs
> unname :: Name -> String
> unname (QName n) = "\"" ++ n ++ "\""