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 Nothing <$> identifierString
|
||||
> -- 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
|
||||
> qiden = char '"' *> qidenSuffix ""
|
||||
|
@ -215,10 +220,7 @@ u&"unicode quoted identifier"
|
|||
> void $ char '"'
|
||||
> qidenSuffix $ 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.
|
||||
|
||||
|
@ -764,16 +766,13 @@ is an unambiguous parse
|
|||
TODO:
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
review existing tables
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ Test for the lexer
|
|||
> ,postgresLexerTests
|
||||
> ,sqlServerLexerTests
|
||||
> ,oracleLexerTests
|
||||
> ,mySqlLexerTests
|
||||
> ,odbcLexerTests]]
|
||||
|
||||
> ansiLexerTable :: [(String,[Token])]
|
||||
|
@ -283,7 +284,7 @@ the + or -.
|
|||
> sqlServerLexerTests = Group "sqlServerLexTests" $
|
||||
> [ LexTest sqlserver s t | (s,t) <-
|
||||
> [("@variable", [(PrefixedVariable '@' "variable")])
|
||||
> --,("[quoted identifier]", [(Identifier (Just ("[", "]")) "variable")])
|
||||
> ,("[quoted identifier]", [(Identifier (Just ("[", "]")) "quoted identifier")])
|
||||
> ]]
|
||||
|
||||
> 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 = Group "odbcLexTests" $
|
||||
> [ LexTest sqlserver {- {odbc = True} -} s t | (s,t) <-
|
||||
|
|
Loading…
Reference in a new issue