cov: Remove unused code
This commit is contained in:
committed by
Wolfgang Walther
parent
97d8456382
commit
6dd126461e
@@ -67,8 +67,7 @@ data Action = ActionCreate | ActionRead{isHead :: Bool}
|
|||||||
data Target = TargetIdent QualifiedIdentifier
|
data Target = TargetIdent QualifiedIdentifier
|
||||||
| TargetProc{tProc :: ProcDescription, tpIsRootSpec :: Bool}
|
| TargetProc{tProc :: ProcDescription, tpIsRootSpec :: Bool}
|
||||||
| TargetDefaultSpec{tdsSchema :: Schema} -- The default spec offered at root "/"
|
| TargetDefaultSpec{tdsSchema :: Schema} -- The default spec offered at root "/"
|
||||||
| TargetUnknown [Text]
|
| TargetUnknown
|
||||||
deriving Eq
|
|
||||||
|
|
||||||
-- | RPC query param value `/rpc/func?v=<value>`, used for VARIADIC functions on form-urlencoded POST and GETs
|
-- | RPC query param value `/rpc/func?v=<value>`, used for VARIADIC functions on form-urlencoded POST and GETs
|
||||||
-- | It can be fixed `?v=1` or repeated `?v=1&v=2&v=3.
|
-- | It can be fixed `?v=1` or repeated `?v=1&v=2&v=3.
|
||||||
@@ -279,7 +278,7 @@ userApiRequest confSchemas rootSpec dbStructure req reqBody
|
|||||||
Nothing -> TargetDefaultSpec schema
|
Nothing -> TargetDefaultSpec schema
|
||||||
[table] -> TargetIdent $ QualifiedIdentifier schema table
|
[table] -> TargetIdent $ QualifiedIdentifier schema table
|
||||||
["rpc", pName] -> TargetProc (callFindProc pName) False
|
["rpc", pName] -> TargetProc (callFindProc pName) False
|
||||||
other -> TargetUnknown other
|
_ -> TargetUnknown
|
||||||
|
|
||||||
shouldParsePayload = action `elem` [ActionCreate, ActionUpdate, ActionSingleUpsert, ActionInvoke InvPost]
|
shouldParsePayload = action `elem` [ActionCreate, ActionUpdate, ActionSingleUpsert, ActionInvoke InvPost]
|
||||||
relevantPayload = case (target, action) of
|
relevantPayload = case (target, action) of
|
||||||
|
|||||||
@@ -137,9 +137,9 @@ app dbStructure conf apiRequest =
|
|||||||
case gucs of
|
case gucs of
|
||||||
Left err -> return $ errorResponseFor err
|
Left err -> return $ errorResponseFor err
|
||||||
Right (ghdrs, gstatus) -> do
|
Right (ghdrs, gstatus) -> do
|
||||||
total <- if | plannedCount -> H.statement () explStm
|
total <- if | plannedCount -> H.statement mempty explStm
|
||||||
| estimatedCount -> if tableTotal > (fromIntegral <$> maxRows)
|
| estimatedCount -> if tableTotal > (fromIntegral <$> maxRows)
|
||||||
then do estTotal <- H.statement () explStm
|
then do estTotal <- H.statement mempty explStm
|
||||||
pure $ if estTotal > tableTotal then estTotal else tableTotal
|
pure $ if estTotal > tableTotal then estTotal else tableTotal
|
||||||
else pure tableTotal
|
else pure tableTotal
|
||||||
| otherwise -> pure tableTotal
|
| otherwise -> pure tableTotal
|
||||||
@@ -197,7 +197,7 @@ app dbStructure conf apiRequest =
|
|||||||
row <- H.statement mempty $
|
row <- H.statement mempty $
|
||||||
createWriteStatement sq mq
|
createWriteStatement sq mq
|
||||||
(contentType == CTSingularJSON) False (contentType == CTTextCSV)
|
(contentType == CTSingularJSON) False (contentType == CTTextCSV)
|
||||||
(iPreferRepresentation apiRequest) [] pgVer prepared
|
(iPreferRepresentation apiRequest) mempty pgVer prepared
|
||||||
let (_, queryTotal, _, body, gucHeaders, gucStatus) = row
|
let (_, queryTotal, _, body, gucHeaders, gucStatus) = row
|
||||||
gucs = (,) <$> gucHeaders <*> gucStatus
|
gucs = (,) <$> gucHeaders <*> gucStatus
|
||||||
case gucs of
|
case gucs of
|
||||||
@@ -230,7 +230,7 @@ app dbStructure conf apiRequest =
|
|||||||
else do
|
else do
|
||||||
row <- H.statement mempty $
|
row <- H.statement mempty $
|
||||||
createWriteStatement sq mq (contentType == CTSingularJSON) False
|
createWriteStatement sq mq (contentType == CTSingularJSON) False
|
||||||
(contentType == CTTextCSV) (iPreferRepresentation apiRequest) [] pgVer prepared
|
(contentType == CTTextCSV) (iPreferRepresentation apiRequest) mempty pgVer prepared
|
||||||
let (_, queryTotal, _, body, gucHeaders, gucStatus) = row
|
let (_, queryTotal, _, body, gucHeaders, gucStatus) = row
|
||||||
gucs = (,) <$> gucHeaders <*> gucStatus
|
gucs = (,) <$> gucHeaders <*> gucStatus
|
||||||
case gucs of
|
case gucs of
|
||||||
@@ -256,7 +256,7 @@ app dbStructure conf apiRequest =
|
|||||||
let stm = createWriteStatement sq mq
|
let stm = createWriteStatement sq mq
|
||||||
(contentType == CTSingularJSON) False
|
(contentType == CTSingularJSON) False
|
||||||
(contentType == CTTextCSV)
|
(contentType == CTTextCSV)
|
||||||
(iPreferRepresentation apiRequest) [] pgVer prepared
|
(iPreferRepresentation apiRequest) mempty pgVer prepared
|
||||||
row <- H.statement mempty stm
|
row <- H.statement mempty stm
|
||||||
let (_, queryTotal, _, body, gucHeaders, gucStatus) = row
|
let (_, queryTotal, _, body, gucHeaders, gucStatus) = row
|
||||||
gucs = (,) <$> gucHeaders <*> gucStatus
|
gucs = (,) <$> gucHeaders <*> gucStatus
|
||||||
@@ -338,7 +338,7 @@ app dbStructure conf apiRequest =
|
|||||||
_ -> return notFound
|
_ -> return notFound
|
||||||
|
|
||||||
where
|
where
|
||||||
notFound = responseLBS status404 [] ""
|
notFound = responseLBS status404 mempty ""
|
||||||
maxRows = configDbMaxRows conf
|
maxRows = configDbMaxRows conf
|
||||||
prepared = configDbPreparedStatements conf
|
prepared = configDbPreparedStatements conf
|
||||||
exactCount = iPreferCount apiRequest == Just ExactCount
|
exactCount = iPreferCount apiRequest == Just ExactCount
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import Data.Vector as V
|
|||||||
import Control.Lens (set)
|
import Control.Lens (set)
|
||||||
import Data.Time.Clock (UTCTime)
|
import Data.Time.Clock (UTCTime)
|
||||||
|
|
||||||
import Control.Lens.Operators
|
|
||||||
import Crypto.JWT
|
import Crypto.JWT
|
||||||
|
|
||||||
import PostgREST.Error (SimpleError (..))
|
import PostgREST.Error (SimpleError (..))
|
||||||
@@ -41,7 +40,6 @@ import Protolude.Conv (toS)
|
|||||||
data JWTAttempt = JWTInvalid JWTError
|
data JWTAttempt = JWTInvalid JWTError
|
||||||
| JWTMissingSecret
|
| JWTMissingSecret
|
||||||
| JWTClaims (M.HashMap Text JSON.Value)
|
| JWTClaims (M.HashMap Text JSON.Value)
|
||||||
deriving (Eq, Show)
|
|
||||||
|
|
||||||
|
|
||||||
jwtClaims :: JWTAttempt -> Either SimpleError (M.HashMap Text JSON.Value)
|
jwtClaims :: JWTAttempt -> Either SimpleError (M.HashMap Text JSON.Value)
|
||||||
@@ -117,7 +115,5 @@ parseSecret str =
|
|||||||
jwkFromSecret :: ByteString -> JWK
|
jwkFromSecret :: ByteString -> JWK
|
||||||
jwkFromSecret key =
|
jwkFromSecret key =
|
||||||
fromKeyMaterial km
|
fromKeyMaterial km
|
||||||
& jwkUse ?~ Sig
|
|
||||||
& jwkAlg ?~ JWSAlg HS256
|
|
||||||
where
|
where
|
||||||
km = OctKeyMaterial (OctKeyParameters (JOSE.Types.Base64Octets key))
|
km = OctKeyMaterial (OctKeyParameters (JOSE.Types.Base64Octets key))
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ data Command
|
|||||||
= CmdRun
|
= CmdRun
|
||||||
| CmdDumpConfig
|
| CmdDumpConfig
|
||||||
| CmdDumpSchema
|
| CmdDumpSchema
|
||||||
deriving (Eq)
|
|
||||||
|
|
||||||
-- | Config file settings for the server
|
-- | Config file settings for the server
|
||||||
data AppConfig = AppConfig {
|
data AppConfig = AppConfig {
|
||||||
@@ -118,7 +117,6 @@ data AppConfig = AppConfig {
|
|||||||
, configServerUnixSocket :: Maybe FilePath
|
, configServerUnixSocket :: Maybe FilePath
|
||||||
, configServerUnixSocketMode :: Either Text FileMode
|
, configServerUnixSocketMode :: Either Text FileMode
|
||||||
}
|
}
|
||||||
deriving (Show)
|
|
||||||
|
|
||||||
configDbPoolTimeout' :: (Fractional a) => AppConfig -> a
|
configDbPoolTimeout' :: (Fractional a) => AppConfig -> a
|
||||||
configDbPoolTimeout' =
|
configDbPoolTimeout' =
|
||||||
|
|||||||
@@ -46,11 +46,11 @@ import PostgREST.Types
|
|||||||
getDbStructure :: [Schema] -> [Schema] -> PgVersion -> Bool -> HT.Transaction DbStructure
|
getDbStructure :: [Schema] -> [Schema] -> PgVersion -> Bool -> HT.Transaction DbStructure
|
||||||
getDbStructure schemas extraSearchPath pgVer prepared = do
|
getDbStructure schemas extraSearchPath pgVer prepared = do
|
||||||
HT.sql "set local schema ''" -- This voids the search path. The following queries need this for getting the fully qualified name(schema.name) of every db object
|
HT.sql "set local schema ''" -- This voids the search path. The following queries need this for getting the fully qualified name(schema.name) of every db object
|
||||||
tabs <- HT.statement () $ allTables prepared
|
tabs <- HT.statement mempty $ allTables prepared
|
||||||
cols <- HT.statement schemas $ allColumns tabs prepared
|
cols <- HT.statement schemas $ allColumns tabs prepared
|
||||||
srcCols <- HT.statement (schemas, extraSearchPath) $ pfkSourceColumns cols prepared
|
srcCols <- HT.statement (schemas, extraSearchPath) $ pfkSourceColumns cols prepared
|
||||||
m2oRels <- HT.statement () $ allM2ORels tabs cols prepared
|
m2oRels <- HT.statement mempty $ allM2ORels tabs cols prepared
|
||||||
keys <- HT.statement () $ allPrimaryKeys tabs prepared
|
keys <- HT.statement mempty $ allPrimaryKeys tabs prepared
|
||||||
procs <- HT.statement schemas $ allProcs prepared
|
procs <- HT.statement schemas $ allProcs prepared
|
||||||
|
|
||||||
let rels = addO2MRels . addM2MRels $ addViewM2ORels srcCols m2oRels
|
let rels = addO2MRels . addM2MRels $ addViewM2ORels srcCols m2oRels
|
||||||
@@ -160,7 +160,7 @@ decodeProcs =
|
|||||||
qi = QualifiedIdentifier schema name
|
qi = QualifiedIdentifier schema name
|
||||||
pgType
|
pgType
|
||||||
| isComposite = Composite qi
|
| isComposite = Composite qi
|
||||||
| otherwise = Scalar qi
|
| otherwise = Scalar
|
||||||
|
|
||||||
parseVolatility :: Char -> ProcVolatility
|
parseVolatility :: Char -> ProcVolatility
|
||||||
parseVolatility v | v == 'i' = Immutable
|
parseVolatility v | v == 'i' = Immutable
|
||||||
@@ -835,7 +835,7 @@ pfkSourceColumns cols =
|
|||||||
order by view_schema, view_name, view_column_name; |]
|
order by view_schema, view_name, view_column_name; |]
|
||||||
|
|
||||||
getPgVersion :: H.Session PgVersion
|
getPgVersion :: H.Session PgVersion
|
||||||
getPgVersion = H.statement () $ H.Statement sql HE.noParams versionRow False
|
getPgVersion = H.statement mempty $ H.Statement sql HE.noParams versionRow False
|
||||||
where
|
where
|
||||||
sql = "SELECT current_setting('server_version_num')::integer, current_setting('server_version')"
|
sql = "SELECT current_setting('server_version_num')::integer, current_setting('server_version')"
|
||||||
versionRow = HD.singleRow $ PgVersion <$> column HD.int4 <*> column HD.text
|
versionRow = HD.singleRow $ PgVersion <$> column HD.int4 <*> column HD.text
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ data ApiRequestError
|
|||||||
| UnacceptableSchema [Text]
|
| UnacceptableSchema [Text]
|
||||||
| UnknownRelation -- Unreachable?
|
| UnknownRelation -- Unreachable?
|
||||||
| UnsupportedVerb -- Unreachable?
|
| UnsupportedVerb -- Unreachable?
|
||||||
deriving (Show, Eq)
|
|
||||||
|
|
||||||
instance PgrstError ApiRequestError where
|
instance PgrstError ApiRequestError where
|
||||||
status InvalidRange = HT.status416
|
status InvalidRange = HT.status416
|
||||||
@@ -114,7 +113,7 @@ compressedRel Relation{..} =
|
|||||||
"relationship" .= (constName <> fmtEls (colName <$> relColumns) <> fmtEls (colName <$> relFColumns))
|
"relationship" .= (constName <> fmtEls (colName <$> relColumns) <> fmtEls (colName <$> relFColumns))
|
||||||
]
|
]
|
||||||
|
|
||||||
data PgError = PgError Authenticated P.UsageError deriving Show
|
data PgError = PgError Authenticated P.UsageError
|
||||||
type Authenticated = Bool
|
type Authenticated = Bool
|
||||||
|
|
||||||
instance PgrstError PgError where
|
instance PgrstError PgError where
|
||||||
@@ -232,7 +231,6 @@ data SimpleError
|
|||||||
| JwtTokenInvalid Text
|
| JwtTokenInvalid Text
|
||||||
| SingularityError Integer
|
| SingularityError Integer
|
||||||
| ContentTypeError [ByteString]
|
| ContentTypeError [ByteString]
|
||||||
deriving (Show, Eq)
|
|
||||||
|
|
||||||
instance PgrstError SimpleError where
|
instance PgrstError SimpleError where
|
||||||
status GucHeadersError = HT.status500
|
status GucHeadersError = HT.status500
|
||||||
|
|||||||
+34
-36
@@ -32,7 +32,7 @@ import Protolude.Conv (toS)
|
|||||||
data ContentType = CTApplicationJSON | CTSingularJSON
|
data ContentType = CTApplicationJSON | CTSingularJSON
|
||||||
| CTTextCSV | CTTextPlain
|
| CTTextCSV | CTTextPlain
|
||||||
| CTOpenAPI | CTUrlEncoded | CTOctetStream
|
| CTOpenAPI | CTUrlEncoded | CTOctetStream
|
||||||
| CTAny | CTOther ByteString deriving (Show, Eq)
|
| CTAny | CTOther ByteString deriving (Eq)
|
||||||
|
|
||||||
-- | Convert from ContentType to a full HTTP Header
|
-- | Convert from ContentType to a full HTTP Header
|
||||||
toHeader :: ContentType -> Header
|
toHeader :: ContentType -> Header
|
||||||
@@ -75,7 +75,7 @@ type SqlQuery = ByteString
|
|||||||
-- | A part of a SQL query that cannot be executed independently
|
-- | A part of a SQL query that cannot be executed independently
|
||||||
type SqlFragment = ByteString
|
type SqlFragment = ByteString
|
||||||
|
|
||||||
data PreferResolution = MergeDuplicates | IgnoreDuplicates deriving Eq
|
data PreferResolution = MergeDuplicates | IgnoreDuplicates
|
||||||
instance Show PreferResolution where
|
instance Show PreferResolution where
|
||||||
show MergeDuplicates = "resolution=merge-duplicates"
|
show MergeDuplicates = "resolution=merge-duplicates"
|
||||||
show IgnoreDuplicates = "resolution=ignore-duplicates"
|
show IgnoreDuplicates = "resolution=ignore-duplicates"
|
||||||
@@ -126,7 +126,7 @@ data DbStructure = DbStructure {
|
|||||||
, dbPrimaryKeys :: [PrimaryKey]
|
, dbPrimaryKeys :: [PrimaryKey]
|
||||||
, dbProcs :: ProcsMap
|
, dbProcs :: ProcsMap
|
||||||
, pgVersion :: PgVersion
|
, pgVersion :: PgVersion
|
||||||
} deriving (Show, Eq, Generic, JSON.ToJSON)
|
} deriving (Generic, JSON.ToJSON)
|
||||||
|
|
||||||
-- TODO Table could hold references to all its Columns
|
-- TODO Table could hold references to all its Columns
|
||||||
tableCols :: DbStructure -> Schema -> TableName -> [Column]
|
tableCols :: DbStructure -> Schema -> TableName -> [Column]
|
||||||
@@ -141,14 +141,14 @@ data PgArg = PgArg {
|
|||||||
, pgaType :: Text
|
, pgaType :: Text
|
||||||
, pgaReq :: Bool
|
, pgaReq :: Bool
|
||||||
, pgaVar :: Bool
|
, pgaVar :: Bool
|
||||||
} deriving (Show, Eq, Ord, Generic, JSON.ToJSON)
|
} deriving (Eq, Ord, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
data PgType = Scalar QualifiedIdentifier | Composite QualifiedIdentifier deriving (Eq, Show, Ord, Generic, JSON.ToJSON)
|
data PgType = Scalar | Composite QualifiedIdentifier deriving (Eq, Ord, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
data RetType = Single PgType | SetOf PgType deriving (Eq, Show, Ord, Generic, JSON.ToJSON)
|
data RetType = Single PgType | SetOf PgType deriving (Eq, Ord, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
data ProcVolatility = Volatile | Stable | Immutable
|
data ProcVolatility = Volatile | Stable | Immutable
|
||||||
deriving (Eq, Show, Ord, Generic, JSON.ToJSON)
|
deriving (Eq, Ord, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
data ProcDescription = ProcDescription {
|
data ProcDescription = ProcDescription {
|
||||||
pdSchema :: Schema
|
pdSchema :: Schema
|
||||||
@@ -158,7 +158,7 @@ data ProcDescription = ProcDescription {
|
|||||||
, pdReturnType :: RetType
|
, pdReturnType :: RetType
|
||||||
, pdVolatility :: ProcVolatility
|
, pdVolatility :: ProcVolatility
|
||||||
, pdHasVariadic :: Bool
|
, pdHasVariadic :: Bool
|
||||||
} deriving (Show, Eq, Generic, JSON.ToJSON)
|
} deriving (Eq, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
-- Order by least number of args in the case of overloaded functions
|
-- Order by least number of args in the case of overloaded functions
|
||||||
instance Ord ProcDescription where
|
instance Ord ProcDescription where
|
||||||
@@ -203,9 +203,9 @@ specifiedProcArgs keys proc =
|
|||||||
|
|
||||||
procReturnsScalar :: ProcDescription -> Bool
|
procReturnsScalar :: ProcDescription -> Bool
|
||||||
procReturnsScalar proc = case proc of
|
procReturnsScalar proc = case proc of
|
||||||
ProcDescription{pdReturnType = (Single (Scalar _))} -> True
|
ProcDescription{pdReturnType = (Single Scalar)} -> True
|
||||||
ProcDescription{pdReturnType = (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
|
||||||
@@ -234,7 +234,7 @@ instance Eq Table where
|
|||||||
tableQi :: Table -> QualifiedIdentifier
|
tableQi :: Table -> QualifiedIdentifier
|
||||||
tableQi Table{tableSchema=s, tableName=n} = QualifiedIdentifier s n
|
tableQi Table{tableSchema=s, tableName=n} = QualifiedIdentifier s n
|
||||||
|
|
||||||
newtype ForeignKey = ForeignKey { fkCol :: Column } deriving (Show, Eq, Ord, Generic, JSON.ToJSON)
|
newtype ForeignKey = ForeignKey { fkCol :: Column } deriving (Eq, Ord, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
data Column =
|
data Column =
|
||||||
Column {
|
Column {
|
||||||
@@ -247,7 +247,7 @@ data Column =
|
|||||||
, colDefault :: Maybe Text
|
, colDefault :: Maybe Text
|
||||||
, colEnum :: [Text]
|
, colEnum :: [Text]
|
||||||
, colFK :: Maybe ForeignKey
|
, colFK :: Maybe ForeignKey
|
||||||
} deriving (Show, Ord, Generic, JSON.ToJSON)
|
} deriving (Ord, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
instance Eq Column where
|
instance Eq Column where
|
||||||
Column{colTable=t1,colName=n1} == Column{colTable=t2,colName=n2} = t1 == t2 && n1 == n2
|
Column{colTable=t1,colName=n1} == Column{colTable=t2,colName=n2} = t1 == t2 && n1 == n2
|
||||||
@@ -259,7 +259,7 @@ type ViewColumn = Column
|
|||||||
data PrimaryKey = PrimaryKey {
|
data PrimaryKey = PrimaryKey {
|
||||||
pkTable :: Table
|
pkTable :: Table
|
||||||
, pkName :: Text
|
, pkName :: Text
|
||||||
} deriving (Show, Eq, Generic, JSON.ToJSON)
|
} deriving (Generic, JSON.ToJSON)
|
||||||
|
|
||||||
data OrderDirection = OrderAsc | OrderDesc deriving (Eq)
|
data OrderDirection = OrderAsc | OrderDesc deriving (Eq)
|
||||||
instance Show OrderDirection where
|
instance Show OrderDirection where
|
||||||
@@ -275,7 +275,7 @@ data OrderTerm = OrderTerm {
|
|||||||
otTerm :: Field
|
otTerm :: Field
|
||||||
, otDirection :: Maybe OrderDirection
|
, otDirection :: Maybe OrderDirection
|
||||||
, otNullOrder :: Maybe OrderNulls
|
, otNullOrder :: Maybe OrderNulls
|
||||||
} deriving (Show, Eq)
|
} deriving (Eq)
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
Represents a pg identifier with a prepended schema name "schema.table"
|
Represents a pg identifier with a prepended schema name "schema.table"
|
||||||
@@ -284,7 +284,7 @@ data OrderTerm = OrderTerm {
|
|||||||
data QualifiedIdentifier = QualifiedIdentifier {
|
data QualifiedIdentifier = QualifiedIdentifier {
|
||||||
qiSchema :: Schema
|
qiSchema :: Schema
|
||||||
, qiName :: TableName
|
, qiName :: TableName
|
||||||
} deriving (Show, Eq, Ord, Generic, JSON.ToJSON, JSON.ToJSONKey)
|
} deriving (Eq, Ord, Generic, JSON.ToJSON, JSON.ToJSONKey)
|
||||||
instance Hashable QualifiedIdentifier
|
instance Hashable QualifiedIdentifier
|
||||||
|
|
||||||
-- | The relationship [cardinality](https://en.wikipedia.org/wiki/Cardinality_(data_modeling)).
|
-- | The relationship [cardinality](https://en.wikipedia.org/wiki/Cardinality_(data_modeling)).
|
||||||
@@ -310,7 +310,7 @@ data Relation = Relation {
|
|||||||
, relFColumns :: [Column]
|
, relFColumns :: [Column]
|
||||||
, relType :: Cardinality
|
, relType :: Cardinality
|
||||||
, relLink :: Link -- ^ Constraint on O2M/M2O, Junction for M2M Cardinality
|
, relLink :: Link -- ^ Constraint on O2M/M2O, Junction for M2M Cardinality
|
||||||
} deriving (Show, Eq, Generic, JSON.ToJSON)
|
} deriving (Eq, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
type ConstraintName = Text
|
type ConstraintName = Text
|
||||||
|
|
||||||
@@ -324,7 +324,7 @@ data Link
|
|||||||
, junLink2 :: Link
|
, junLink2 :: Link
|
||||||
, junCols2 :: [Column]
|
, junCols2 :: [Column]
|
||||||
}
|
}
|
||||||
deriving (Show, Eq, Generic, JSON.ToJSON)
|
deriving (Eq, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
isSelfReference :: Relation -> Bool
|
isSelfReference :: Relation -> Bool
|
||||||
isSelfReference r = relTable r == relFTable r
|
isSelfReference r = relTable r == relFTable r
|
||||||
@@ -341,16 +341,16 @@ data PayloadJSON =
|
|||||||
}|
|
}|
|
||||||
RawJSON {
|
RawJSON {
|
||||||
pjRaw :: BL.ByteString
|
pjRaw :: BL.ByteString
|
||||||
} deriving (Show, Eq)
|
}
|
||||||
|
|
||||||
data PJType = PJArray { pjaLength :: Int } | PJObject deriving (Show, Eq)
|
data PJType = PJArray { pjaLength :: Int } | PJObject
|
||||||
|
|
||||||
data Proxy = Proxy {
|
data Proxy = Proxy {
|
||||||
proxyScheme :: Text
|
proxyScheme :: Text
|
||||||
, proxyHost :: Text
|
, proxyHost :: Text
|
||||||
, proxyPort :: Integer
|
, proxyPort :: Integer
|
||||||
, proxyPath :: Text
|
, proxyPath :: Text
|
||||||
} deriving (Show, Eq)
|
}
|
||||||
|
|
||||||
type Operator = Text
|
type Operator = Text
|
||||||
operators :: M.HashMap Operator SqlFragment
|
operators :: M.HashMap Operator SqlFragment
|
||||||
@@ -382,10 +382,10 @@ ftsOperators = M.fromList [
|
|||||||
("wfts", "@@ websearch_to_tsquery")
|
("wfts", "@@ websearch_to_tsquery")
|
||||||
]
|
]
|
||||||
|
|
||||||
data OpExpr = OpExpr Bool Operation deriving (Eq, Show)
|
data OpExpr = OpExpr Bool Operation deriving (Eq)
|
||||||
data Operation = Op Operator SingleVal |
|
data Operation = Op Operator SingleVal |
|
||||||
In ListVal |
|
In ListVal |
|
||||||
Fts Operator (Maybe Language) SingleVal deriving (Eq, Show)
|
Fts Operator (Maybe Language) SingleVal deriving (Eq)
|
||||||
type Language = Text
|
type Language = Text
|
||||||
|
|
||||||
-- | Represents a single value in a filter, e.g. id=eq.singleval
|
-- | Represents a single value in a filter, e.g. id=eq.singleval
|
||||||
@@ -406,7 +406,7 @@ instance Show LogicOperator where
|
|||||||
/ \
|
/ \
|
||||||
id.eq.1 id.eq.2
|
id.eq.1 id.eq.2
|
||||||
-}
|
-}
|
||||||
data LogicTree = Expr Bool LogicOperator [LogicTree] | Stmnt Filter deriving (Show, Eq)
|
data LogicTree = Expr Bool LogicOperator [LogicTree] | Stmnt Filter deriving (Eq)
|
||||||
|
|
||||||
type FieldName = Text
|
type FieldName = Text
|
||||||
{-|
|
{-|
|
||||||
@@ -414,9 +414,9 @@ type FieldName = Text
|
|||||||
-}
|
-}
|
||||||
type JsonPath = [JsonOperation]
|
type JsonPath = [JsonOperation]
|
||||||
-- | Represents the single arrow `->` or double arrow `->>` operators
|
-- | Represents the single arrow `->` or double arrow `->>` operators
|
||||||
data JsonOperation = JArrow{jOp :: JsonOperand} | J2Arrow{jOp :: JsonOperand} deriving (Show, Eq)
|
data JsonOperation = JArrow{jOp :: JsonOperand} | J2Arrow{jOp :: JsonOperand} deriving (Eq)
|
||||||
-- | Represents the key(`->'key'`) or index(`->'1`::int`), the index is Text because we reuse our escaping functons and let pg do the casting with '1'::int
|
-- | Represents the key(`->'key'`) or index(`->'1`::int`), the index is Text because we reuse our escaping functons and let pg do the casting with '1'::int
|
||||||
data JsonOperand = JKey{jVal :: Text} | JIdx{jVal :: Text} deriving (Show, Eq)
|
data JsonOperand = JKey{jVal :: Text} | JIdx{jVal :: Text} deriving (Eq)
|
||||||
|
|
||||||
type Field = (FieldName, JsonPath)
|
type Field = (FieldName, JsonPath)
|
||||||
type Alias = Text
|
type Alias = Text
|
||||||
@@ -429,7 +429,6 @@ type NodeName = Text
|
|||||||
`SET LOCAL "response.headers" = '[{"Set-Cookie": ".."}]'
|
`SET LOCAL "response.headers" = '[{"Set-Cookie": ".."}]'
|
||||||
-}
|
-}
|
||||||
newtype GucHeader = GucHeader (CI.CI ByteString, ByteString)
|
newtype GucHeader = GucHeader (CI.CI ByteString, ByteString)
|
||||||
deriving (Show, Eq)
|
|
||||||
|
|
||||||
instance JSON.FromJSON GucHeader where
|
instance JSON.FromJSON GucHeader where
|
||||||
parseJSON (JSON.Object o) = case headMay (M.toList o) of
|
parseJSON (JSON.Object o) = case headMay (M.toList o) of
|
||||||
@@ -457,9 +456,9 @@ type SelectItem = (Field, Maybe Cast, Maybe Alias, Maybe EmbedHint)
|
|||||||
type EmbedHint = Text
|
type EmbedHint = Text
|
||||||
-- | Path of the embedded levels, e.g "clients.projects.name=eq.." gives Path ["clients", "projects"]
|
-- | Path of the embedded levels, e.g "clients.projects.name=eq.." gives Path ["clients", "projects"]
|
||||||
type EmbedPath = [Text]
|
type EmbedPath = [Text]
|
||||||
data Filter = Filter { field::Field, opExpr::OpExpr } deriving (Show, Eq)
|
data Filter = Filter { field::Field, opExpr::OpExpr } deriving (Eq)
|
||||||
data JoinCondition = JoinCondition (QualifiedIdentifier, FieldName)
|
data JoinCondition = JoinCondition (QualifiedIdentifier, FieldName)
|
||||||
(QualifiedIdentifier, FieldName) deriving (Show, Eq)
|
(QualifiedIdentifier, FieldName) deriving (Eq)
|
||||||
|
|
||||||
data ReadQuery = Select {
|
data ReadQuery = Select {
|
||||||
select :: [SelectItem]
|
select :: [SelectItem]
|
||||||
@@ -472,7 +471,7 @@ data ReadQuery = Select {
|
|||||||
, joinConditions :: [JoinCondition]
|
, joinConditions :: [JoinCondition]
|
||||||
, order :: [OrderTerm]
|
, order :: [OrderTerm]
|
||||||
, range_ :: NonnegRange
|
, range_ :: NonnegRange
|
||||||
} deriving (Show, Eq)
|
} deriving (Eq)
|
||||||
|
|
||||||
data MutateQuery =
|
data MutateQuery =
|
||||||
Insert {
|
Insert {
|
||||||
@@ -494,7 +493,7 @@ data MutateQuery =
|
|||||||
in_ :: QualifiedIdentifier
|
in_ :: QualifiedIdentifier
|
||||||
, where_ :: [LogicTree]
|
, where_ :: [LogicTree]
|
||||||
, returning :: [FieldName]
|
, returning :: [FieldName]
|
||||||
} deriving (Show, Eq)
|
}
|
||||||
|
|
||||||
type ReadRequest = Tree ReadNode
|
type ReadRequest = Tree ReadNode
|
||||||
type MutateRequest = MutateQuery
|
type MutateRequest = MutateQuery
|
||||||
@@ -510,7 +509,7 @@ fstFieldNames (Node (sel, _) _) =
|
|||||||
data PgVersion = PgVersion {
|
data PgVersion = PgVersion {
|
||||||
pgvNum :: Int32
|
pgvNum :: Int32
|
||||||
, pgvName :: Text
|
, pgvName :: Text
|
||||||
} deriving (Eq, Show, Generic, JSON.ToJSON)
|
} deriving (Eq, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
instance Ord PgVersion where
|
instance Ord PgVersion where
|
||||||
(PgVersion v1 _) `compare` (PgVersion v2 _) = v1 `compare` v2
|
(PgVersion v1 _) `compare` (PgVersion v2 _) = v1 `compare` v2
|
||||||
@@ -552,7 +551,7 @@ sourceCTEName = "pgrst_source"
|
|||||||
-- | full jspath, e.g. .property[0].attr.detail
|
-- | full jspath, e.g. .property[0].attr.detail
|
||||||
type JSPath = [JSPathExp]
|
type JSPath = [JSPathExp]
|
||||||
-- | jspath expression, e.g. .property, .property[0] or ."property-dash"
|
-- | jspath expression, e.g. .property, .property[0] or ."property-dash"
|
||||||
data JSPathExp = JSPKey Text | JSPIdx Int deriving (Eq)
|
data JSPathExp = JSPKey Text | JSPIdx Int
|
||||||
|
|
||||||
instance Show JSPathExp where
|
instance Show JSPathExp where
|
||||||
-- TODO: this needs to be quoted properly for special chars
|
-- TODO: this needs to be quoted properly for special chars
|
||||||
@@ -564,16 +563,15 @@ data ConnectionStatus
|
|||||||
= NotConnected
|
= NotConnected
|
||||||
| Connected PgVersion
|
| Connected PgVersion
|
||||||
| FatalConnectionError Text
|
| FatalConnectionError Text
|
||||||
deriving (Eq, Show)
|
deriving (Eq)
|
||||||
|
|
||||||
-- | Schema cache status
|
-- | Schema cache status
|
||||||
data SCacheStatus
|
data SCacheStatus
|
||||||
= SCLoaded
|
= SCLoaded
|
||||||
| SCOnRetry
|
| SCOnRetry
|
||||||
| SCFatalFail
|
| SCFatalFail
|
||||||
deriving (Eq, Show)
|
|
||||||
|
|
||||||
data LogLevel = LogCrit | LogError | LogWarn | LogInfo deriving (Eq)
|
data LogLevel = LogCrit | LogError | LogWarn | LogInfo
|
||||||
|
|
||||||
instance Show LogLevel where
|
instance Show LogLevel where
|
||||||
show LogCrit = "crit"
|
show LogCrit = "crit"
|
||||||
|
|||||||
Reference in New Issue
Block a user