Use protolude 0.2.2, replace undefined with witness
protolude provides headMay since 0.2.2, it can be used instead of safe.
This commit is contained in:
+1
-2
@@ -76,10 +76,9 @@ library
|
|||||||
, network-uri
|
, network-uri
|
||||||
, optparse-applicative >= 0.13 && < 0.15
|
, optparse-applicative >= 0.13 && < 0.15
|
||||||
, parsec
|
, parsec
|
||||||
, protolude >= 0.2 && < 0.2.2
|
, protolude >= 0.2.2
|
||||||
, Ranged-sets == 0.3.0
|
, Ranged-sets == 0.3.0
|
||||||
, regex-tdfa
|
, regex-tdfa
|
||||||
, safe
|
|
||||||
, scientific
|
, scientific
|
||||||
, swagger2
|
, swagger2
|
||||||
, text
|
, text
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ userApiRequest :: Schema -> Request -> RequestBody -> Either ApiRequestError Api
|
|||||||
userApiRequest schema req reqBody
|
userApiRequest schema req reqBody
|
||||||
| isTargetingProc && method `notElem` ["GET", "POST"] = Left ActionInappropriate
|
| isTargetingProc && method `notElem` ["GET", "POST"] = Left ActionInappropriate
|
||||||
| topLevelRange == emptyRange = Left InvalidRange
|
| topLevelRange == emptyRange = Left InvalidRange
|
||||||
| shouldParsePayload && isLeft payload = either (Left . InvalidBody . toS) undefined payload
|
| shouldParsePayload && isLeft payload = either (Left . InvalidBody . toS) witness payload
|
||||||
| otherwise = Right ApiRequest {
|
| otherwise = Right ApiRequest {
|
||||||
iAction = action
|
iAction = action
|
||||||
, iTarget = target
|
, iTarget = target
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ import PostgREST.OpenAPI
|
|||||||
|
|
||||||
import Data.Function (id)
|
import Data.Function (id)
|
||||||
import Protolude hiding (intercalate, Proxy)
|
import Protolude hiding (intercalate, Proxy)
|
||||||
import Safe (headMay)
|
|
||||||
|
|
||||||
postgrest :: AppConfig -> IORef (Maybe DbStructure) -> P.Pool -> IO UTCTime -> IO () -> Application
|
postgrest :: AppConfig -> IORef (Maybe DbStructure) -> P.Pool -> IO UTCTime -> IO () -> Application
|
||||||
postgrest conf refDbStructure pool getTime worker =
|
postgrest conf refDbStructure pool getTime worker =
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ getJoinConditions (Relation Table{tableSchema=tSchema, tableName=tN} cols Table{
|
|||||||
| typ == Many ->
|
| typ == Many ->
|
||||||
let ltN = fromMaybe "" (tableName <$> lt) in
|
let ltN = fromMaybe "" (tableName <$> lt) in
|
||||||
zipWith (toJoinCondition tN ltN) cols (fromMaybe [] lc1) ++ zipWith (toJoinCondition ftN ltN) fcs (fromMaybe [] lc2)
|
zipWith (toJoinCondition tN ltN) cols (fromMaybe [] lc1) ++ zipWith (toJoinCondition ftN ltN) fcs (fromMaybe [] lc2)
|
||||||
| typ == Root -> undefined
|
| typ == Root -> witness
|
||||||
where
|
where
|
||||||
toJoinCondition :: Text -> Text -> Column -> Column -> JoinCondition
|
toJoinCondition :: Text -> Text -> Column -> Column -> JoinCondition
|
||||||
toJoinCondition tb ftb c fc =
|
toJoinCondition tb ftb c fc =
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ pgFmtLit x =
|
|||||||
else slashed
|
else slashed
|
||||||
|
|
||||||
requestToCountQuery :: Schema -> DbRequest -> SqlQuery
|
requestToCountQuery :: Schema -> DbRequest -> SqlQuery
|
||||||
requestToCountQuery _ (DbMutate _) = undefined
|
requestToCountQuery _ (DbMutate _) = witness
|
||||||
requestToCountQuery schema (DbRead (Node (Select{where_=logicForest}, (mainTbl, _, _, _, _)) _)) =
|
requestToCountQuery schema (DbRead (Node (Select{where_=logicForest}, (mainTbl, _, _, _, _)) _)) =
|
||||||
unwords [
|
unwords [
|
||||||
"SELECT pg_catalog.count(*)",
|
"SELECT pg_catalog.count(*)",
|
||||||
@@ -272,7 +272,7 @@ requestToQuery schema isParent (DbRead (Node (Select colSelects tbls logicForest
|
|||||||
--the following is just to remove the warning
|
--the following is just to remove the warning
|
||||||
--getQueryParts is not total but requestToQuery is called only after addJoinConditions which ensures the only
|
--getQueryParts is not total but requestToQuery is called only after addJoinConditions which ensures the only
|
||||||
--posible relations are Child Parent Many
|
--posible relations are Child Parent Many
|
||||||
getQueryParts _ _ = undefined
|
getQueryParts _ _ = witness
|
||||||
requestToQuery schema _ (DbMutate (Insert mainTbl pkCols p@(PayloadJSON _ pType pKeys) onConflct logicForest returnings)) =
|
requestToQuery schema _ (DbMutate (Insert mainTbl pkCols p@(PayloadJSON _ pType pKeys) onConflct logicForest returnings)) =
|
||||||
unwords [
|
unwords [
|
||||||
("WITH " <> ignoredBody) `emptyOnFalse` not payloadIsEmpty,
|
("WITH " <> ignoredBody) `emptyOnFalse` not payloadIsEmpty,
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ extra-deps:
|
|||||||
- hjsonpointer-1.1.1
|
- hjsonpointer-1.1.1
|
||||||
- hjsonschema-1.5.0.1
|
- hjsonschema-1.5.0.1
|
||||||
- Ranged-sets-0.3.0
|
- Ranged-sets-0.3.0
|
||||||
- protolude-0.2
|
- protolude-0.2.2
|
||||||
- hasql-1.1
|
- hasql-1.1
|
||||||
- hasql-pool-0.4.3
|
- hasql-pool-0.4.3
|
||||||
- hasql-transaction-0.5.2
|
- hasql-transaction-0.5.2
|
||||||
|
|||||||
Reference in New Issue
Block a user