refactor: remove Maybe from RetType for Proc type
This commit is contained in:
committed by
Steve Chavez
parent
bc1fb67df0
commit
d945e8c06a
@@ -255,16 +255,16 @@ decodeProcs =
|
|||||||
addKey :: ProcDescription -> (QualifiedIdentifier, ProcDescription)
|
addKey :: ProcDescription -> (QualifiedIdentifier, ProcDescription)
|
||||||
addKey pd = (QualifiedIdentifier (pdSchema pd) (pdName pd), pd)
|
addKey pd = (QualifiedIdentifier (pdSchema pd) (pdName pd), pd)
|
||||||
|
|
||||||
parseRetType :: Text -> Text -> Bool -> Bool -> Bool -> Maybe RetType
|
parseRetType :: Text -> Text -> Bool -> Bool -> Bool -> RetType
|
||||||
parseRetType schema name isSetOf isComposite isVoid
|
parseRetType schema name isSetOf isComposite isVoid
|
||||||
| isVoid = Nothing
|
| isVoid = Single $ Scalar True
|
||||||
| isSetOf = Just (SetOf pgType)
|
| isSetOf = SetOf pgType
|
||||||
| otherwise = Just (Single pgType)
|
| otherwise = Single pgType
|
||||||
where
|
where
|
||||||
qi = QualifiedIdentifier schema name
|
qi = QualifiedIdentifier schema name
|
||||||
pgType
|
pgType
|
||||||
| isComposite = Composite qi
|
| isComposite = Composite qi
|
||||||
| otherwise = Scalar
|
| otherwise = Scalar False
|
||||||
|
|
||||||
parseVolatility :: Char -> ProcVolatility
|
parseVolatility :: Char -> ProcVolatility
|
||||||
parseVolatility v | v == 'i' = Immutable
|
parseVolatility v | v == 'i' = Immutable
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..),
|
|||||||
import Protolude
|
import Protolude
|
||||||
|
|
||||||
data PgType
|
data PgType
|
||||||
= Scalar
|
= Scalar Bool -- True if the type is void
|
||||||
| Composite QualifiedIdentifier
|
| Composite QualifiedIdentifier
|
||||||
deriving (Eq, Ord, Generic, JSON.ToJSON)
|
deriving (Eq, Ord, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ data ProcDescription = ProcDescription
|
|||||||
, pdName :: Text
|
, pdName :: Text
|
||||||
, pdDescription :: Maybe Text
|
, pdDescription :: Maybe Text
|
||||||
, pdParams :: [ProcParam]
|
, pdParams :: [ProcParam]
|
||||||
, pdReturnType :: Maybe RetType
|
, pdReturnType :: RetType
|
||||||
, pdVolatility :: ProcVolatility
|
, pdVolatility :: ProcVolatility
|
||||||
, pdHasVariadic :: Bool
|
, pdHasVariadic :: Bool
|
||||||
}
|
}
|
||||||
@@ -70,22 +70,22 @@ type ProcsMap = HM.HashMap QualifiedIdentifier [ProcDescription]
|
|||||||
|
|
||||||
procReturnsScalar :: ProcDescription -> Bool
|
procReturnsScalar :: ProcDescription -> Bool
|
||||||
procReturnsScalar proc = case proc of
|
procReturnsScalar proc = case proc of
|
||||||
ProcDescription{pdReturnType = Just (Single Scalar)} -> True
|
ProcDescription{pdReturnType = Single (Scalar _)} -> True
|
||||||
ProcDescription{pdReturnType = Just (SetOf Scalar)} -> True
|
ProcDescription{pdReturnType = SetOf (Scalar _)} -> True
|
||||||
_ -> False
|
_ -> False
|
||||||
|
|
||||||
procReturnsSingle :: ProcDescription -> Bool
|
procReturnsSingle :: ProcDescription -> Bool
|
||||||
procReturnsSingle proc = case proc of
|
procReturnsSingle proc = case proc of
|
||||||
ProcDescription{pdReturnType = Just (Single _)} -> True
|
ProcDescription{pdReturnType = Single _} -> True
|
||||||
_ -> False
|
_ -> False
|
||||||
|
|
||||||
procReturnsVoid :: ProcDescription -> Bool
|
procReturnsVoid :: ProcDescription -> Bool
|
||||||
procReturnsVoid proc = case proc of
|
procReturnsVoid proc = case proc of
|
||||||
ProcDescription{pdReturnType = Nothing} -> True
|
ProcDescription{pdReturnType = Single (Scalar True)} -> True
|
||||||
_ -> False
|
_ -> False
|
||||||
|
|
||||||
procTableName :: ProcDescription -> Maybe TableName
|
procTableName :: ProcDescription -> Maybe TableName
|
||||||
procTableName proc = case pdReturnType proc of
|
procTableName proc = case pdReturnType proc of
|
||||||
Just (SetOf (Composite qi)) -> Just $ qiName qi
|
SetOf (Composite qi) -> Just $ qiName qi
|
||||||
Just (Single (Composite qi)) -> Just $ qiName qi
|
Single (Composite qi) -> Just $ qiName qi
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|||||||
Reference in New Issue
Block a user