rename LobTypeName to PrecLengthTypeName
rename LobMultiplier and LobUnits to PrecMultiplier and PrecUnits remove support for limit syntax remove the unreserved keyword list since it isn't useful tests for row value constructors tests for table value constructors tests for query specifications tests for explicit table work on tests for setops,order by,offset,fetch and sort specification
This commit is contained in:
parent
0d1e345262
commit
dbd48baaa1
7 changed files with 122 additions and 279 deletions
Language/SQL/SimpleSQL
|
@ -459,7 +459,7 @@ TODO: this code needs heavy refactoring
|
|||
> lob tn = parens $ do
|
||||
> (x,y) <- lobPrecToken
|
||||
> z <- optionMaybe lobUnits
|
||||
> return $ LobTypeName tn x y z
|
||||
> return $ PrecLengthTypeName tn x y z
|
||||
> precscale tn = parens (commaSep unsignedInteger) >>= makeWrap
|
||||
> where
|
||||
> makeWrap [a] = return $ PrecTypeName tn a
|
||||
|
@ -470,15 +470,15 @@ TODO: this code needs heavy refactoring
|
|||
> tcollate = keyword_ "collate" *> names
|
||||
> lobPrecToken = lexeme $ do
|
||||
> p <- read <$> many1 digit <?> "unsigned integer"
|
||||
> x <- choice [Just LobK <$ keyword_ "k"
|
||||
> ,Just LobM <$ keyword_ "m"
|
||||
> ,Just LobG <$ keyword_ "g"
|
||||
> ,Just LobT <$ keyword_ "t"
|
||||
> ,Just LobP <$ keyword_ "p"
|
||||
> x <- choice [Just PrecK <$ keyword_ "k"
|
||||
> ,Just PrecM <$ keyword_ "m"
|
||||
> ,Just PrecG <$ keyword_ "g"
|
||||
> ,Just PrecT <$ keyword_ "t"
|
||||
> ,Just PrecP <$ keyword_ "p"
|
||||
> ,return Nothing]
|
||||
> return (p,x)
|
||||
> lobUnits = choice [LobCharacters <$ keyword_ "characters"
|
||||
> ,LobOctets <$ keyword_ "octets"]
|
||||
> lobUnits = choice [PrecCharacters <$ keyword_ "characters"
|
||||
> ,PrecOctets <$ keyword_ "octets"]
|
||||
> -- deal with multiset and array suffixes
|
||||
> tnSuffix x =
|
||||
> multisetSuffix x <|> arrayTNSuffix x <|> return x
|
||||
|
@ -506,6 +506,7 @@ TODO: this code needs heavy refactoring
|
|||
> ,"nchar varying"
|
||||
> ,"bit varying"
|
||||
> ,"binary large object"
|
||||
> ,"binary varying"
|
||||
> -- reserved keyword typenames:
|
||||
> ,"array"
|
||||
> ,"bigint"
|
||||
|
@ -530,6 +531,7 @@ TODO: this code needs heavy refactoring
|
|||
> ,"time"
|
||||
> ,"timestamp"
|
||||
> ,"varchar"
|
||||
> ,"varbinary"
|
||||
> ]
|
||||
|
||||
= Value expressions
|
||||
|
@ -1331,12 +1333,10 @@ allows offset and fetch in either order
|
|||
> ,keyword_ "row"])
|
||||
|
||||
> fetch :: Parser ValueExpr
|
||||
> fetch = choice [ansiFetch, limit]
|
||||
> fetch = fs *> valueExpr <* ro
|
||||
> where
|
||||
> fs = makeKeywordTree ["fetch first", "fetch next"]
|
||||
> ro = makeKeywordTree ["rows only", "row only"]
|
||||
> ansiFetch = fs *> valueExpr <* ro
|
||||
> limit = keyword_ "limit" *> valueExpr
|
||||
|
||||
== common table expressions
|
||||
|
||||
|
@ -1703,228 +1703,6 @@ The standard has a weird mix of reserved keywords and unreserved
|
|||
keywords (I'm not sure what exactly being an unreserved keyword
|
||||
means).
|
||||
|
||||
> _nonReservedWord :: [String]
|
||||
> _nonReservedWord =
|
||||
> ["a"
|
||||
> ,"absolute"
|
||||
> ,"action"
|
||||
> ,"ada"
|
||||
> ,"add"
|
||||
> ,"admin"
|
||||
> ,"after"
|
||||
> ,"always"
|
||||
> ,"asc"
|
||||
> ,"assertion"
|
||||
> ,"assignment"
|
||||
> ,"attribute"
|
||||
> ,"attributes"
|
||||
> ,"before"
|
||||
> ,"bernoulli"
|
||||
> ,"breadth"
|
||||
> ,"c"
|
||||
> ,"cascade"
|
||||
> ,"catalog"
|
||||
> ,"catalog_name"
|
||||
> ,"chain"
|
||||
> ,"character_set_catalog"
|
||||
> ,"character_set_name"
|
||||
> ,"character_set_schema"
|
||||
> ,"characteristics"
|
||||
> ,"characters"
|
||||
> ,"class_origin"
|
||||
> ,"cobol"
|
||||
> ,"collation"
|
||||
> ,"collation_catalog"
|
||||
> ,"collation_name"
|
||||
> ,"collation_schema"
|
||||
> ,"column_name"
|
||||
> ,"command_function"
|
||||
> ,"command_function_code"
|
||||
> ,"committed"
|
||||
> ,"condition_number"
|
||||
> ,"connection"
|
||||
> ,"connection_name"
|
||||
> ,"constraint_catalog"
|
||||
> ,"constraint_name"
|
||||
> ,"constraint_schema"
|
||||
> ,"constraints"
|
||||
> ,"constructor"
|
||||
> ,"continue"
|
||||
> ,"cursor_name"
|
||||
> ,"data"
|
||||
> ,"datetime_interval_code"
|
||||
> ,"datetime_interval_precision"
|
||||
> ,"defaults"
|
||||
> ,"deferrable"
|
||||
> ,"deferred"
|
||||
> ,"defined"
|
||||
> ,"definer"
|
||||
> ,"degree"
|
||||
> ,"depth"
|
||||
> ,"derived"
|
||||
> ,"desc"
|
||||
> ,"descriptor"
|
||||
> ,"diagnostics"
|
||||
> ,"dispatch"
|
||||
> ,"domain"
|
||||
> ,"dynamic_function"
|
||||
> ,"dynamic_function_code"
|
||||
> ,"enforced"
|
||||
> ,"exclude"
|
||||
> ,"excluding"
|
||||
> ,"expression"
|
||||
> ,"final"
|
||||
> ,"first"
|
||||
> ,"flag"
|
||||
> ,"following"
|
||||
> ,"fortran"
|
||||
> ,"found"
|
||||
> ,"g"
|
||||
> ,"general"
|
||||
> ,"generated"
|
||||
> ,"go"
|
||||
> ,"goto"
|
||||
> ,"granted"
|
||||
> ,"hierarchy"
|
||||
> ,"ignore"
|
||||
> ,"immediate"
|
||||
> ,"immediately"
|
||||
> ,"implementation"
|
||||
> ,"including"
|
||||
> ,"increment"
|
||||
> ,"initially"
|
||||
> ,"input"
|
||||
> ,"instance"
|
||||
> ,"instantiable"
|
||||
> ,"instead"
|
||||
> ,"invoker"
|
||||
> ,"isolation"
|
||||
> ,"k"
|
||||
> ,"key"
|
||||
> ,"key_member"
|
||||
> ,"key_type"
|
||||
> ,"last"
|
||||
> ,"length"
|
||||
> ,"level"
|
||||
> ,"locator"
|
||||
> ,"m"
|
||||
> ,"map"
|
||||
> ,"matched"
|
||||
> ,"maxvalue"
|
||||
> ,"message_length"
|
||||
> ,"message_octet_length"
|
||||
> ,"message_text"
|
||||
> ,"minvalue"
|
||||
> ,"more"
|
||||
> ,"mumps"
|
||||
> ,"name"
|
||||
> ,"names"
|
||||
> ,"nesting"
|
||||
> ,"next"
|
||||
> ,"nfc"
|
||||
> ,"nfd"
|
||||
> ,"nfkc"
|
||||
> ,"nfkd"
|
||||
> ,"normalized"
|
||||
> ,"nullable"
|
||||
> ,"nulls"
|
||||
> ,"number"
|
||||
> ,"object"
|
||||
> ,"octets"
|
||||
> ,"option"
|
||||
> ,"options"
|
||||
> ,"ordering"
|
||||
> ,"ordinality"
|
||||
> ,"others"
|
||||
> ,"output"
|
||||
> ,"overriding"
|
||||
> ,"p"
|
||||
> ,"pad"
|
||||
> ,"parameter_mode"
|
||||
> ,"parameter_name"
|
||||
> ,"parameter_ordinal_position"
|
||||
> ,"parameter_specific_catalog"
|
||||
> ,"parameter_specific_name"
|
||||
> ,"parameter_specific_schema"
|
||||
> ,"partial"
|
||||
> ,"pascal"
|
||||
> ,"path"
|
||||
> ,"placing"
|
||||
> ,"pli"
|
||||
> ,"preceding"
|
||||
> ,"preserve"
|
||||
> ,"prior"
|
||||
> ,"privileges"
|
||||
> ,"public"
|
||||
> ,"read"
|
||||
> ,"relative"
|
||||
> ,"repeatable"
|
||||
> ,"respect"
|
||||
> ,"restart"
|
||||
> ,"restrict"
|
||||
> ,"returned_cardinality"
|
||||
> ,"returned_length"
|
||||
> ,"returned_octet_length"
|
||||
> ,"returned_sqlstate"
|
||||
> ,"role"
|
||||
> ,"routine"
|
||||
> ,"routine_catalog"
|
||||
> ,"routine_name"
|
||||
> ,"routine_schema"
|
||||
> ,"row_count"
|
||||
> ,"scale"
|
||||
> ,"schema"
|
||||
> ,"schema_name"
|
||||
> ,"scope_catalog"
|
||||
> ,"scope_name"
|
||||
> ,"scope_schema"
|
||||
> ,"section"
|
||||
> ,"security"
|
||||
> ,"self"
|
||||
> ,"sequence"
|
||||
> ,"serializable"
|
||||
> ,"server_name"
|
||||
> ,"session"
|
||||
> ,"sets"
|
||||
> ,"simple"
|
||||
> ,"size"
|
||||
> ,"source"
|
||||
> ,"space"
|
||||
> ,"specific_name"
|
||||
> ,"state"
|
||||
> ,"statement"
|
||||
> ,"structure"
|
||||
> ,"style"
|
||||
> ,"subclass_origin"
|
||||
> ,"t"
|
||||
> ,"table_name"
|
||||
> ,"temporary"
|
||||
> ,"ties"
|
||||
> ,"top_level_count"
|
||||
> ,"transaction"
|
||||
> ,"transaction_active"
|
||||
> ,"transactions_committed"
|
||||
> ,"transactions_rolled_back"
|
||||
> ,"transform"
|
||||
> ,"transforms"
|
||||
> ,"trigger_catalog"
|
||||
> ,"trigger_name"
|
||||
> ,"trigger_schema"
|
||||
> ,"type"
|
||||
> ,"unbounded"
|
||||
> ,"uncommitted"
|
||||
> ,"under"
|
||||
> ,"unnamed"
|
||||
> ,"usage"
|
||||
> ,"user_defined_type_catalog"
|
||||
> ,"user_defined_type_code"
|
||||
> ,"user_defined_type_name"
|
||||
> ,"user_defined_type_schema"
|
||||
> ,"view"
|
||||
> ,"work"
|
||||
> ,"write"
|
||||
> ,"zone"]
|
||||
|
||||
> reservedWord :: [String]
|
||||
> reservedWord =
|
||||
> ["abs"
|
||||
|
@ -2251,10 +2029,6 @@ means).
|
|||
> ,"within"
|
||||
> ,"without"
|
||||
> --,"year"
|
||||
>
|
||||
> -- added for this parser
|
||||
> -- todo: remove this when dialects with limit are added
|
||||
> ,"limit"
|
||||
> ]
|
||||
|
||||
--------------------------------------------
|
||||
|
|
|
@ -257,18 +257,18 @@ which have been changed to try to improve the layout of the output.
|
|||
> typeName (PrecTypeName t a) = names t <+> parens (text $ show a)
|
||||
> typeName (PrecScaleTypeName t a b) =
|
||||
> names t <+> parens (text (show a) <+> comma <+> text (show b))
|
||||
> typeName (LobTypeName t i m u) =
|
||||
> typeName (PrecLengthTypeName t i m u) =
|
||||
> names t
|
||||
> <> parens (text (show i)
|
||||
> <> me (\x -> case x of
|
||||
> LobK -> text "K"
|
||||
> LobM -> text "M"
|
||||
> LobG -> text "G"
|
||||
> LobT -> text "T"
|
||||
> LobP -> text "P") m
|
||||
> PrecK -> text "K"
|
||||
> PrecM -> text "M"
|
||||
> PrecG -> text "G"
|
||||
> PrecT -> text "T"
|
||||
> PrecP -> text "P") m
|
||||
> <+> me (\x -> case x of
|
||||
> LobCharacters -> text "CHARACTERS"
|
||||
> LobOctets -> text "OCTETS") u)
|
||||
> PrecCharacters -> text "CHARACTERS"
|
||||
> PrecOctets -> text "OCTETS") u)
|
||||
> typeName (CharTypeName t i cs col) =
|
||||
> names t
|
||||
> <> me (\x -> parens (text $ show x)) i
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
> ,Name(..)
|
||||
> ,TypeName(..)
|
||||
> ,IntervalTypeField(..)
|
||||
> ,LobMultiplier(..)
|
||||
> ,LobUnits(..)
|
||||
> ,PrecMultiplier(..)
|
||||
> ,PrecUnits(..)
|
||||
> ,SetQuantifier(..)
|
||||
> ,SortSpec(..)
|
||||
> ,Direction(..)
|
||||
|
@ -172,7 +172,7 @@
|
|||
> = TypeName [Name]
|
||||
> | PrecTypeName [Name] Integer
|
||||
> | PrecScaleTypeName [Name] Integer Integer
|
||||
> | LobTypeName [Name] Integer (Maybe LobMultiplier) (Maybe LobUnits)
|
||||
> | PrecLengthTypeName [Name] Integer (Maybe PrecMultiplier) (Maybe PrecUnits)
|
||||
> -- precision, characterset, collate
|
||||
> | CharTypeName [Name] (Maybe Integer) [Name] [Name]
|
||||
> | TimeTypeName [Name] (Maybe Integer) Bool -- true == with time zone
|
||||
|
@ -185,10 +185,10 @@
|
|||
> data IntervalTypeField = Itf String (Maybe (Integer, Maybe Integer))
|
||||
> deriving (Eq,Show,Read,Data,Typeable)
|
||||
|
||||
> data LobMultiplier = LobK | LobM | LobG | LobT | LobP
|
||||
> deriving (Eq,Show,Read,Data,Typeable)
|
||||
> data LobUnits = LobCharacters
|
||||
> | LobOctets
|
||||
> data PrecMultiplier = PrecK | PrecM | PrecG | PrecT | PrecP
|
||||
> deriving (Eq,Show,Read,Data,Typeable)
|
||||
> data PrecUnits = PrecCharacters
|
||||
> | PrecOctets
|
||||
> deriving (Eq,Show,Read,Data,Typeable)
|
||||
|
||||
> -- | Used for 'expr in (value expression list)', and 'expr in
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue