add support for [] quoted identifiers and for #var, @var
This commit is contained in:
parent
b22cde4100
commit
9adce162e5
|
@ -203,7 +203,12 @@ u&"unicode quoted identifier"
|
||||||
> ,Identifier (Just ("U&\"","\"")) <$> (try (string "U&") *> qiden)
|
> ,Identifier (Just ("U&\"","\"")) <$> (try (string "U&") *> qiden)
|
||||||
> ,Identifier Nothing <$> identifierString
|
> ,Identifier Nothing <$> identifierString
|
||||||
> -- todo: dialect protection
|
> -- todo: dialect protection
|
||||||
> ,Identifier (Just ("`","`")) <$> mySqlQIden
|
> ,guard (diSyntaxFlavour d == MySQL) >>
|
||||||
|
> Identifier (Just ("`","`"))
|
||||||
|
> <$> (char '`' *> takeWhile1 (/='`') <* char '`')
|
||||||
|
> ,guard (diSyntaxFlavour d == SQLServer) >>
|
||||||
|
> Identifier (Just ("[","]"))
|
||||||
|
> <$> (char '[' *> takeWhile1 (`notElem` "[]") <* char ']')
|
||||||
> ]
|
> ]
|
||||||
> where
|
> where
|
||||||
> qiden = char '"' *> qidenSuffix ""
|
> qiden = char '"' *> qidenSuffix ""
|
||||||
|
@ -215,10 +220,7 @@ u&"unicode quoted identifier"
|
||||||
> void $ char '"'
|
> void $ char '"'
|
||||||
> qidenSuffix $ concat [t,s,"\"\""]
|
> qidenSuffix $ concat [t,s,"\"\""]
|
||||||
> ,return $ concat [t,s]]
|
> ,return $ concat [t,s]]
|
||||||
> -- mysql can quote identifiers with `
|
|
||||||
> mySqlQIden = do
|
|
||||||
> guard (diSyntaxFlavour d == MySQL)
|
|
||||||
> char '`' *> takeWhile1 (/='`') <* char '`'
|
|
||||||
|
|
||||||
This parses a valid identifier without quotes.
|
This parses a valid identifier without quotes.
|
||||||
|
|
||||||
|
@ -765,15 +767,12 @@ TODO:
|
||||||
|
|
||||||
refactor the tokenswillprintlex to be based on pretty printing the
|
refactor the tokenswillprintlex to be based on pretty printing the
|
||||||
individual tokens
|
individual tokens
|
||||||
|
make the tokenswill print more dialect accurate. Maybe add symbol
|
||||||
|
chars and identifier chars to the dialect definition and use them from
|
||||||
|
here
|
||||||
|
|
||||||
start adding negative / different parse dialect tests
|
start adding negative / different parse dialect tests
|
||||||
|
|
||||||
lex @variable in sql server
|
|
||||||
lex [quoted identifier] in sql server
|
|
||||||
lex #variable in oracle
|
|
||||||
|
|
||||||
make a new ctor for @var, #var
|
|
||||||
|
|
||||||
add token tables and tests for oracle, sql server
|
add token tables and tests for oracle, sql server
|
||||||
review existing tables
|
review existing tables
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ Test for the lexer
|
||||||
> ,postgresLexerTests
|
> ,postgresLexerTests
|
||||||
> ,sqlServerLexerTests
|
> ,sqlServerLexerTests
|
||||||
> ,oracleLexerTests
|
> ,oracleLexerTests
|
||||||
|
> ,mySqlLexerTests
|
||||||
> ,odbcLexerTests]]
|
> ,odbcLexerTests]]
|
||||||
|
|
||||||
> ansiLexerTable :: [(String,[Token])]
|
> ansiLexerTable :: [(String,[Token])]
|
||||||
|
@ -283,7 +284,7 @@ the + or -.
|
||||||
> sqlServerLexerTests = Group "sqlServerLexTests" $
|
> sqlServerLexerTests = Group "sqlServerLexTests" $
|
||||||
> [ LexTest sqlserver s t | (s,t) <-
|
> [ LexTest sqlserver s t | (s,t) <-
|
||||||
> [("@variable", [(PrefixedVariable '@' "variable")])
|
> [("@variable", [(PrefixedVariable '@' "variable")])
|
||||||
> --,("[quoted identifier]", [(Identifier (Just ("[", "]")) "variable")])
|
> ,("[quoted identifier]", [(Identifier (Just ("[", "]")) "quoted identifier")])
|
||||||
> ]]
|
> ]]
|
||||||
|
|
||||||
> oracleLexerTests :: TestItem
|
> oracleLexerTests :: TestItem
|
||||||
|
@ -293,6 +294,13 @@ the + or -.
|
||||||
> ]
|
> ]
|
||||||
> ]
|
> ]
|
||||||
|
|
||||||
|
> mySqlLexerTests :: TestItem
|
||||||
|
> mySqlLexerTests = Group "mySqlLexerTests" $
|
||||||
|
> [ LexTest mysql s t | (s,t) <-
|
||||||
|
> [("`quoted identifier`", [(Identifier (Just ("`", "`")) "quoted identifier")])
|
||||||
|
> ]
|
||||||
|
> ]
|
||||||
|
|
||||||
> odbcLexerTests :: TestItem
|
> odbcLexerTests :: TestItem
|
||||||
> odbcLexerTests = Group "odbcLexTests" $
|
> odbcLexerTests = Group "odbcLexTests" $
|
||||||
> [ LexTest sqlserver {- {odbc = True} -} s t | (s,t) <-
|
> [ LexTest sqlserver {- {odbc = True} -} s t | (s,t) <-
|
||||||
|
|
Loading…
Reference in a new issue