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
tools/Language/SQL/SimpleSQL

View file

@ -17,9 +17,9 @@ large amount of the SQL.
> sql2003Tests :: TestItem
> sql2003Tests = Group "sql2003Tests"
> [stringLiterals
> --,nationalCharacterStringLiterals
> --,unicodeStringLiterals
> --,binaryStringLiterals
> ,nationalCharacterStringLiterals
> ,unicodeStringLiterals
> ,binaryStringLiterals
> ,numericLiterals
> ,dateAndTimeLiterals
> ,booleanLiterals
@ -43,6 +43,7 @@ large amount of the SQL.
> ,quantifiedComparisonPredicate
> ,uniquePredicate
> ,matchPredicate
> ,collateClause
> --,sortSpecificationList
> ]
@ -479,10 +480,16 @@ The <quote symbol> rule consists of two immediately adjacent <quote> marks with
> ,StringLit "something some moreand more")
> ,("'a quote: '', stuff'"
> ,StringLit "a quote: ', stuff")
> ,("''"
> ,StringLit "")
> ,("_francais 'français'"
> ,TypedLit (TypeName "_francais") "français")
> ]
TODO: all the stuff with character set representations.
== other string literals
<national character string literal> ::=
@ -491,8 +498,8 @@ TODO: all the stuff with character set representations.
> nationalCharacterStringLiterals :: TestItem
> nationalCharacterStringLiterals = Group "national character string literals" $ map (uncurry TestValueExpr)
> [("N'something'", undefined)
> ,("n'something'", undefined)
> [("N'something'", CSStringLit "N" "something")
> ,("n'something'", CSStringLit "n" "something")
> ]
<Unicode character string literal> ::=
@ -505,14 +512,13 @@ TODO: all the stuff with character set representations.
> unicodeStringLiterals :: TestItem
> unicodeStringLiterals = Group "national character string literals" $ map (uncurry TestValueExpr)
> [("U&'something'", undefined)
> ,("u&'something'", undefined)
> [("U&'something'", CSStringLit "U&" "something")
> ,("u&'something' escape ="
> ,Escape (CSStringLit "u&" "something") '=')
> ,("u&'something' uescape ="
> ,UEscape (CSStringLit "u&" "something") '=')
> ]
TODO: put in some unicode and some unicode escape values plus work out
the ESCAPE thing. I think this is to change the unicode escape value
starting character.
== other string literals
<binary string literal> ::=
@ -529,8 +535,9 @@ TODO: how to escapes work here?
> binaryStringLiterals :: TestItem
> binaryStringLiterals = Group "bit and hex string literals" $ map (uncurry TestValueExpr)
> [("B'101010'", undefined)
> ,("X'7f7f7f'", undefined)
> [("B'101010'", CSStringLit "B" "101010")
> ,("X'7f7f7f'", CSStringLit "X" "7f7f7f")
> ,("X'7f7f7f' escape z", Escape (CSStringLit "X" "7f7f7f") 'z')
> ]
TODO: separator stuff for all the string literals?
@ -2802,7 +2809,10 @@ Specify a default collating sequence.
<collate clause> ::= COLLATE <collation name>
covered elsewhere
> collateClause :: TestItem
> collateClause = Group "collate clause" $ map (uncurry TestValueExpr)
> [("a collate my_collation"
> ,Collate (Iden "a") "my_collation")]
10.8 <constraint name definition> and <constraint characteristics> (p501)

View file

@ -243,10 +243,10 @@ keyword special operators
> ,("substring(x for 2)"
> ,SpecialOpK "substring" (Just $ Iden "x") [("for", NumLit "2")])
> ,("substring(x from 1 for 2 collate 'C')"
> ,SpecialOpK "substring" (Just $ Iden "x") [("from", NumLit "1")
> ,("for", NumLit "2")
> ,("collate", StringLit "C")])
> ,("substring(x from 1 for 2 collate C)"
> ,SpecialOpK "substring" (Just $ Iden "x")
> [("from", NumLit "1")
> ,("for", Collate (NumLit "2") "C")])
this doesn't work because of a overlap in the 'in' parser
@ -312,11 +312,10 @@ target_string
> [("trailing", StringLit "y")
> ,("from", Iden "target_string")])
> ,("trim(both 'z' from target_string collate 'C')"
> ,("trim(both 'z' from target_string collate C)"
> ,SpecialOpK "trim" Nothing
> [("both", StringLit "z")
> ,("from", Iden "target_string")
> ,("collate", StringLit "C")])
> ,("from", Collate (Iden "target_string") "C")])
> ,("trim(leading from target_string)"
> ,SpecialOpK "trim" Nothing