add support for '' in string literals
This commit is contained in:
parent
72b67166d9
commit
8adc169b38
|
@ -724,7 +724,13 @@ String literals: limited at the moment, no escaping \' or other
|
||||||
variations.
|
variations.
|
||||||
|
|
||||||
> stringLiteral :: P String
|
> stringLiteral :: P String
|
||||||
> stringLiteral = char '\'' *> manyTill anyChar (symbol_ "'")
|
> stringLiteral = (char '\'' *> manyTill anyChar (char '\'')
|
||||||
|
> >>= optionSuffix moreString) <* whiteSpace
|
||||||
|
> where
|
||||||
|
> moreString s0 = try $ do
|
||||||
|
> void $ char '\''
|
||||||
|
> s <- manyTill anyChar (char '\'')
|
||||||
|
> optionSuffix moreString (s0 ++ "'" ++ s)
|
||||||
|
|
||||||
number literals
|
number literals
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,11 @@
|
||||||
= scalar expressions
|
= scalar expressions
|
||||||
|
|
||||||
> scalarExpr :: ScalarExpr -> Doc
|
> scalarExpr :: ScalarExpr -> Doc
|
||||||
> scalarExpr (StringLit s) = quotes $ text s
|
> scalarExpr (StringLit s) = quotes $ text $ doubleUpQuotes s
|
||||||
|
> where doubleUpQuotes [] = []
|
||||||
|
> doubleUpQuotes ('\'':cs) = '\'':'\'':doubleUpQuotes cs
|
||||||
|
> doubleUpQuotes (c:cs) = c:doubleUpQuotes cs
|
||||||
|
|
||||||
> scalarExpr (NumLit s) = text s
|
> scalarExpr (NumLit s) = text s
|
||||||
> scalarExpr (IntervalLit v u p) =
|
> scalarExpr (IntervalLit v u p) =
|
||||||
> text "interval" <+> quotes (text v)
|
> text "interval" <+> quotes (text v)
|
||||||
|
|
4
TODO
4
TODO
|
@ -12,6 +12,10 @@ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY
|
||||||
in the postgresql docs, the start and count must be in parens unless
|
in the postgresql docs, the start and count must be in parens unless
|
||||||
they are a single integer
|
they are a single integer
|
||||||
|
|
||||||
|
select * from generate_series(0,99) offset 5 fetch next 5 row only;
|
||||||
|
select * from generate_series(0,99) offset 5;
|
||||||
|
select * from generate_series(0,99) fetch next 5 row only;
|
||||||
|
|
||||||
+ sql server top syntax
|
+ sql server top syntax
|
||||||
|
|
||||||
more dots: implement as dot operator
|
more dots: implement as dot operator
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: simple-sql-parser
|
name: simple-sql-parser
|
||||||
version: 0.2.0.0
|
version: 0.2.0
|
||||||
synopsis: A parser for SQL queries
|
synopsis: A parser for SQL queries
|
||||||
description: A parser for SQL queries. Please see the homepage for more information <http://jakewheat.github.io/simple_sql_parser/>.
|
description: A parser for SQL queries. Please see the homepage for more information <http://jakewheat.github.io/simple_sql_parser/>.
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ Tests for parsing scalar expressions
|
||||||
> ,("3e+3", NumLit "3e+3")
|
> ,("3e+3", NumLit "3e+3")
|
||||||
> ,("3e-3", NumLit "3e-3")
|
> ,("3e-3", NumLit "3e-3")
|
||||||
> ,("'string'", StringLit "string")
|
> ,("'string'", StringLit "string")
|
||||||
|
> ,("'string with a '' quote'", StringLit "string with a ' quote")
|
||||||
> ,("'1'", StringLit "1")
|
> ,("'1'", StringLit "1")
|
||||||
> ,("interval '3' day", IntervalLit "3" "day" Nothing)
|
> ,("interval '3' day", IntervalLit "3" "day" Nothing)
|
||||||
> ,("interval '3' day (3)", IntervalLit "3" "day" $ Just 3)
|
> ,("interval '3' day (3)", IntervalLit "3" "day" $ Just 3)
|
||||||
|
|
Loading…
Reference in a new issue