Do hlint 2.1 hints
This commit is contained in:
committed by
Steve Chávez
parent
63ead89470
commit
dadfe965b9
@@ -110,8 +110,7 @@ userApiRequest schema req reqBody
|
|||||||
iAction = action
|
iAction = action
|
||||||
, iTarget = target
|
, iTarget = target
|
||||||
, iRange = ranges
|
, iRange = ranges
|
||||||
, iAccepts = fromMaybe [CTAny] $
|
, iAccepts = maybe [CTAny] (map decodeContentType . parseHttpAccept) $ lookupHeader "accept"
|
||||||
map decodeContentType . parseHttpAccept <$> lookupHeader "accept"
|
|
||||||
, iPayload = relevantPayload
|
, iPayload = relevantPayload
|
||||||
, iPreferRepresentation = representation
|
, iPreferRepresentation = representation
|
||||||
, iPreferSingleObjectParameter = singleObject
|
, iPreferSingleObjectParameter = singleObject
|
||||||
@@ -130,7 +129,7 @@ userApiRequest schema req reqBody
|
|||||||
$ rawQueryString req
|
$ rawQueryString req
|
||||||
, iJWT = tokenStr
|
, iJWT = tokenStr
|
||||||
, iHeaders = [ (toS $ CI.foldedCase k, toS v) | (k,v) <- hdrs, k /= hAuthorization, k /= hCookie]
|
, iHeaders = [ (toS $ CI.foldedCase k, toS v) | (k,v) <- hdrs, k /= hAuthorization, k /= hCookie]
|
||||||
, iCookies = fromMaybe [] $ parseCookiesText <$> lookupHeader "Cookie"
|
, iCookies = maybe [] parseCookiesText $ lookupHeader "Cookie"
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
-- rpcQParams = Rpc query params e.g. /rpc/name?param1=val1, similar to filter but with no operator(eq, lt..)
|
-- rpcQParams = Rpc query params e.g. /rpc/name?param1=val1, similar to filter but with no operator(eq, lt..)
|
||||||
@@ -143,7 +142,7 @@ userApiRequest schema req reqBody
|
|||||||
((<> ".") <$> "not":M.keys operators) ++
|
((<> ".") <$> "not":M.keys operators) ++
|
||||||
((<> "(") <$> M.keys ftsOperators)
|
((<> "(") <$> M.keys ftsOperators)
|
||||||
isEmbedPath = T.isInfixOf "."
|
isEmbedPath = T.isInfixOf "."
|
||||||
isTargetingProc = fromMaybe False $ (== "rpc") <$> listToMaybe path
|
isTargetingProc = (== Just "rpc") $ listToMaybe path
|
||||||
payload =
|
payload =
|
||||||
case (decodeContentType . fromMaybe "application/json" $ lookupHeader "content-type", action) of
|
case (decodeContentType . fromMaybe "application/json" $ lookupHeader "content-type", action) of
|
||||||
(_, ActionInvoke{isReadOnly=True}) ->
|
(_, ActionInvoke{isReadOnly=True}) ->
|
||||||
@@ -215,7 +214,7 @@ userApiRequest schema req reqBody
|
|||||||
limitParams :: M.HashMap ByteString NonnegRange
|
limitParams :: M.HashMap ByteString NonnegRange
|
||||||
limitParams = M.fromList [(toS (replaceLast "limit" k), restrictRange (readMaybe =<< (toS <$> v)) allRange) | (k,v) <- qParams, isJust v, endingIn ["limit"] k]
|
limitParams = M.fromList [(toS (replaceLast "limit" k), restrictRange (readMaybe =<< (toS <$> v)) allRange) | (k,v) <- qParams, isJust v, endingIn ["limit"] k]
|
||||||
offsetParams :: M.HashMap ByteString NonnegRange
|
offsetParams :: M.HashMap ByteString NonnegRange
|
||||||
offsetParams = M.fromList [(toS (replaceLast "limit" k), fromMaybe allRange (rangeGeq <$> (readMaybe =<< (toS <$> v)))) | (k,v) <- qParams, isJust v, endingIn ["offset"] k]
|
offsetParams = M.fromList [(toS (replaceLast "limit" k), maybe allRange rangeGeq (readMaybe =<< (toS <$> v))) | (k,v) <- qParams, isJust v, endingIn ["offset"] k]
|
||||||
|
|
||||||
urlRange = M.unionWith f limitParams offsetParams
|
urlRange = M.unionWith f limitParams offsetParams
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ transactionMode proc action =
|
|||||||
ActionInfo -> HT.Read
|
ActionInfo -> HT.Read
|
||||||
ActionInspect -> HT.Read
|
ActionInspect -> HT.Read
|
||||||
ActionInvoke{isReadOnly=False} ->
|
ActionInvoke{isReadOnly=False} ->
|
||||||
let v = fromMaybe Volatile $ pdVolatility <$> proc in
|
let v = maybe Volatile pdVolatility proc in
|
||||||
if v == Stable || v == Immutable
|
if v == Stable || v == Immutable
|
||||||
then HT.Read
|
then HT.Read
|
||||||
else HT.Write
|
else HT.Write
|
||||||
@@ -286,7 +286,7 @@ app dbStructure proc conf apiRequest =
|
|||||||
PJObject -> True
|
PJObject -> True
|
||||||
PJArray _ -> False
|
PJArray _ -> False
|
||||||
singular = contentType == CTSingularJSON
|
singular = contentType == CTSingularJSON
|
||||||
specifiedPgArgs = filter ((`S.member` pjKeys) . pgaName) $ fromMaybe [] (pdArgs <$> proc)
|
specifiedPgArgs = filter ((`S.member` pjKeys) . pgaName) $ maybe [] pdArgs proc
|
||||||
row <- H.statement (toS pjRaw) $
|
row <- H.statement (toS pjRaw) $
|
||||||
callProc qi specifiedPgArgs returnsScalar q cq shouldCount
|
callProc qi specifiedPgArgs returnsScalar q cq shouldCount
|
||||||
singular (iPreferSingleObjectParameter apiRequest)
|
singular (iPreferSingleObjectParameter apiRequest)
|
||||||
@@ -397,8 +397,8 @@ contentRangeH lower upper total =
|
|||||||
rangeString
|
rangeString
|
||||||
| totalNotZero && fromInRange = show lower <> "-" <> show upper
|
| totalNotZero && fromInRange = show lower <> "-" <> show upper
|
||||||
| otherwise = "*"
|
| otherwise = "*"
|
||||||
totalString = fromMaybe "*" (show <$> total)
|
totalString = maybe "*" show total
|
||||||
totalNotZero = fromMaybe True ((/=) 0 <$> total)
|
totalNotZero = maybe True (0 /=) total
|
||||||
fromInRange = lower <= upper
|
fromInRange = lower <= upper
|
||||||
|
|
||||||
extractQueryResult :: Maybe ResultsWithCount -> ResultsWithCount
|
extractQueryResult :: Maybe ResultsWithCount -> ResultsWithCount
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ parseJWK str =
|
|||||||
hs256jwk :: ByteString -> JWK
|
hs256jwk :: ByteString -> JWK
|
||||||
hs256jwk key =
|
hs256jwk key =
|
||||||
fromKeyMaterial km
|
fromKeyMaterial km
|
||||||
& jwkUse .~ Just Sig
|
& jwkUse ?~ Sig
|
||||||
& jwkAlg .~ (Just $ JWSAlg HS256)
|
& jwkAlg ?~ JWSAlg HS256
|
||||||
where
|
where
|
||||||
km = OctKeyMaterial (OctKeyParameters (JOSE.Types.Base64Octets key))
|
km = OctKeyMaterial (OctKeyParameters (JOSE.Types.Base64Octets key))
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import PostgREST.Parsers
|
|||||||
import PostgREST.RangeQuery (NonnegRange, restrictRange, allRange)
|
import PostgREST.RangeQuery (NonnegRange, restrictRange, allRange)
|
||||||
import PostgREST.Types
|
import PostgREST.Types
|
||||||
|
|
||||||
import Protolude hiding (from, dropWhile, drop)
|
import Protolude hiding (from)
|
||||||
import Text.Regex.TDFA ((=~))
|
import Text.Regex.TDFA ((=~))
|
||||||
import Unsafe (unsafeHead)
|
import Unsafe (unsafeHead)
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ getJoinConditions (Relation Table{tableSchema=tSchema, tableName=tN} cols Table{
|
|||||||
if | typ == Child || typ == Parent ->
|
if | typ == Child || typ == Parent ->
|
||||||
zipWith (toJoinCondition tN ftN) cols fCols
|
zipWith (toJoinCondition tN ftN) cols fCols
|
||||||
| typ == Many ->
|
| typ == Many ->
|
||||||
let ltN = fromMaybe "" (tableName <$> lt) in
|
let ltN = maybe "" tableName lt in
|
||||||
zipWith (toJoinCondition tN ltN) cols (fromMaybe [] lc1) ++ zipWith (toJoinCondition ftN ltN) fCols (fromMaybe [] lc2)
|
zipWith (toJoinCondition tN ltN) cols (fromMaybe [] lc1) ++ zipWith (toJoinCondition ftN ltN) fCols (fromMaybe [] lc2)
|
||||||
| typ == Root -> witness
|
| typ == Root -> witness
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -538,7 +538,7 @@ columnFromRow tabs (s, t, n, desc, pos, nul, typ, u, l, p, d, e) = buildColumn <
|
|||||||
buildColumn tbl = Column tbl n desc pos nul typ u l p d (parseEnum e) Nothing
|
buildColumn tbl = Column tbl n desc pos nul typ u l p d (parseEnum e) Nothing
|
||||||
table = find (\tbl -> tableSchema tbl == s && tableName tbl == t) tabs
|
table = find (\tbl -> tableSchema tbl == s && tableName tbl == t) tabs
|
||||||
parseEnum :: Maybe Text -> [Text]
|
parseEnum :: Maybe Text -> [Text]
|
||||||
parseEnum str = fromMaybe [] $ split (==',') <$> str
|
parseEnum = maybe [] (split (==','))
|
||||||
|
|
||||||
allChildRelations :: [Table] -> [Column] -> H.Statement () [Relation]
|
allChildRelations :: [Table] -> [Column] -> H.Statement () [Relation]
|
||||||
allChildRelations tabs cols =
|
allChildRelations tabs cols =
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import PostgREST.Config (AppConfig (..), corsPolicy)
|
|||||||
import PostgREST.Error (simpleError)
|
import PostgREST.Error (simpleError)
|
||||||
import PostgREST.QueryBuilder (pgFmtLit, unquoted, pgFmtSetLocal)
|
import PostgREST.QueryBuilder (pgFmtLit, unquoted, pgFmtSetLocal)
|
||||||
|
|
||||||
import Protolude hiding (concat, null)
|
import Protolude
|
||||||
|
|
||||||
runWithClaims :: AppConfig -> JWTAttempt ->
|
runWithClaims :: AppConfig -> JWTAttempt ->
|
||||||
(ApiRequest -> H.Transaction Response) ->
|
(ApiRequest -> H.Transaction Response) ->
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ makeProperty pks c = (colName c, Inline s)
|
|||||||
]
|
]
|
||||||
d =
|
d =
|
||||||
if length n > 1 then
|
if length n > 1 then
|
||||||
Just $ append (fromMaybe "" ((`append` "\n\n") <$> colDescription c)) (intercalate "\n" n)
|
Just $ append (maybe "" (`append` "\n\n") $ colDescription c) (intercalate "\n" n)
|
||||||
else
|
else
|
||||||
colDescription c
|
colDescription c
|
||||||
s =
|
s =
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ module PostgREST.Parsers where
|
|||||||
import Protolude hiding (try, intercalate, replace, option)
|
import Protolude hiding (try, intercalate, replace, option)
|
||||||
import Control.Monad ((>>))
|
import Control.Monad ((>>))
|
||||||
import Data.Foldable (foldl1)
|
import Data.Foldable (foldl1)
|
||||||
|
import Data.Functor (($>))
|
||||||
import qualified Data.HashMap.Strict as M
|
import qualified Data.HashMap.Strict as M
|
||||||
import Data.Text (intercalate, replace, strip)
|
import Data.Text (intercalate, replace, strip)
|
||||||
import Data.List (init, last)
|
import Data.List (init, last)
|
||||||
@@ -68,17 +69,18 @@ pFieldForest = pFieldTree `sepBy1` lexeme (char ',')
|
|||||||
Node <$> pFieldSelect <*> pure []
|
Node <$> pFieldSelect <*> pure []
|
||||||
|
|
||||||
pStar :: Parser Text
|
pStar :: Parser Text
|
||||||
pStar = toS <$> (string "*" *> pure ("*"::ByteString))
|
pStar = toS <$> (string "*" $> ("*"::ByteString))
|
||||||
|
|
||||||
pFieldName :: Parser Text
|
pFieldName :: Parser Text
|
||||||
pFieldName = do
|
pFieldName =
|
||||||
matches <- (many1 (letter <|> digit <|> oneOf "_") `sepBy1` dash) <?> "field name (* or [a..z0..9_])"
|
intercalate "-" . map toS <$>
|
||||||
return $ intercalate "-" $ map toS matches
|
(many1 (letter <|> digit <|> oneOf "_") `sepBy1` dash) <?>
|
||||||
|
"field name (* or [a..z0..9_])"
|
||||||
where
|
where
|
||||||
isDash :: GenParser Char st ()
|
isDash :: GenParser Char st ()
|
||||||
isDash = try ( char '-' >> notFollowedBy (char '>') )
|
isDash = try ( char '-' >> notFollowedBy (char '>') )
|
||||||
dash :: Parser Char
|
dash :: Parser Char
|
||||||
dash = isDash *> pure '-'
|
dash = isDash $> '-'
|
||||||
|
|
||||||
pJsonPath :: Parser JsonPath
|
pJsonPath :: Parser JsonPath
|
||||||
pJsonPath = many pJsonOperation
|
pJsonPath = many pJsonOperation
|
||||||
@@ -184,12 +186,12 @@ pLogicTree = Stmnt <$> try pLogicFilter
|
|||||||
pLogicFilter :: Parser Filter
|
pLogicFilter :: Parser Filter
|
||||||
pLogicFilter = Filter <$> pField <* pDelimiter <*> pOpExpr pLogicSingleVal
|
pLogicFilter = Filter <$> pField <* pDelimiter <*> pOpExpr pLogicSingleVal
|
||||||
pNot :: Parser Bool
|
pNot :: Parser Bool
|
||||||
pNot = try (string "not" *> pDelimiter *> pure True)
|
pNot = try (string "not" *> pDelimiter $> True)
|
||||||
<|> pure False
|
<|> pure False
|
||||||
<?> "negation operator (not)"
|
<?> "negation operator (not)"
|
||||||
pLogicOp :: Parser LogicOperator
|
pLogicOp :: Parser LogicOperator
|
||||||
pLogicOp = try (string "and" *> pure And)
|
pLogicOp = try (string "and" $> And)
|
||||||
<|> string "or" *> pure Or
|
<|> string "or" $> Or
|
||||||
<?> "logic operator (and, or)"
|
<?> "logic operator (and, or)"
|
||||||
|
|
||||||
pLogicSingleVal :: Parser SingleVal
|
pLogicSingleVal :: Parser SingleVal
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ import Data.Scientific ( FPFormat (..)
|
|||||||
, formatScientific
|
, formatScientific
|
||||||
, isInteger
|
, isInteger
|
||||||
)
|
)
|
||||||
import Protolude hiding (from, intercalate, ord, cast, replace)
|
import Protolude hiding ( intercalate, cast, replace)
|
||||||
import PostgREST.ApiRequest (PreferRepresentation (..))
|
import PostgREST.ApiRequest (PreferRepresentation (..))
|
||||||
|
|
||||||
{-| The generic query result format used by API responses. The location header
|
{-| The generic query result format used by API responses. The location header
|
||||||
@@ -229,7 +229,7 @@ requestToQuery schema isParent (DbRead (Node (Select colSelects tbls logicForest
|
|||||||
("LIMIT " <> maybe "ALL" show (rangeLimit range) <> " OFFSET " <> show (rangeOffset range)) `emptyOnFalse` (isParent || range == allRange) ]
|
("LIMIT " <> maybe "ALL" show (rangeLimit range) <> " OFFSET " <> show (rangeOffset range)) `emptyOnFalse` (isParent || range == allRange) ]
|
||||||
|
|
||||||
where
|
where
|
||||||
mainTbl = fromMaybe nodeName (tableName . relTable <$> maybeRelation)
|
mainTbl = maybe nodeName (tableName . relTable) maybeRelation
|
||||||
isSelfJoin = maybe False (\r -> relType r /= Root && relTable r == relFTable r) maybeRelation
|
isSelfJoin = maybe False (\r -> relType r /= Root && relTable r == relFTable r) maybeRelation
|
||||||
(qi, tables, joinConds) =
|
(qi, tables, joinConds) =
|
||||||
let depthAlias name dpth = if dpth /= 0 then name <> "_" <> show dpth else name in -- Root node doesn't get aliased
|
let depthAlias name dpth = if dpth /= 0 then name <> "_" <> show dpth else name in -- Root node doesn't get aliased
|
||||||
@@ -413,7 +413,7 @@ pgFmtFilter table (Filter fld (OpExpr hasNot oper)) = notOp <> " " <> case oper
|
|||||||
|
|
||||||
In vals -> pgFmtField table fld <> " " <>
|
In vals -> pgFmtField table fld <> " " <>
|
||||||
let emptyValForIn = "= any('{}') " in -- Workaround because for postgresql "col IN ()" is invalid syntax, we instead do "col = any('{}')"
|
let emptyValForIn = "= any('{}') " in -- Workaround because for postgresql "col IN ()" is invalid syntax, we instead do "col = any('{}')"
|
||||||
case ((&&) (length vals == 1) . T.null) <$> headMay vals of
|
case (&&) (length vals == 1) . T.null <$> headMay vals of
|
||||||
Just False -> sqlOperator "in" <> "(" <> intercalate ", " (map unknownLiteral vals) <> ") "
|
Just False -> sqlOperator "in" <> "(" <> intercalate ", " (map unknownLiteral vals) <> ") "
|
||||||
Just True -> emptyValForIn
|
Just True -> emptyValForIn
|
||||||
Nothing -> emptyValForIn
|
Nothing -> emptyValForIn
|
||||||
|
|||||||
@@ -32,14 +32,13 @@ rangeParse range = do
|
|||||||
case listToMaybe (range =~ rangeRegex :: [[BS.ByteString]]) of
|
case listToMaybe (range =~ rangeRegex :: [[BS.ByteString]]) of
|
||||||
Just parsedRange ->
|
Just parsedRange ->
|
||||||
let [_, mLower, mUpper] = readMaybe . toS <$> parsedRange
|
let [_, mLower, mUpper] = readMaybe . toS <$> parsedRange
|
||||||
lower = fromMaybe emptyRange (rangeGeq <$> mLower)
|
lower = maybe emptyRange rangeGeq mLower
|
||||||
upper = fromMaybe allRange (rangeLeq <$> mUpper) in
|
upper = maybe allRange rangeLeq mUpper in
|
||||||
rangeIntersection lower upper
|
rangeIntersection lower upper
|
||||||
Nothing -> allRange
|
Nothing -> allRange
|
||||||
|
|
||||||
rangeRequested :: RequestHeaders -> NonnegRange
|
rangeRequested :: RequestHeaders -> NonnegRange
|
||||||
rangeRequested headers = fromMaybe allRange $
|
rangeRequested headers = maybe allRange rangeParse $ lookup hRange headers
|
||||||
rangeParse <$> lookup hRange headers
|
|
||||||
|
|
||||||
restrictRange :: Maybe Integer -> NonnegRange -> NonnegRange
|
restrictRange :: Maybe Integer -> NonnegRange -> NonnegRange
|
||||||
restrictRange Nothing r = r
|
restrictRange Nothing r = r
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Network.HTTP.Types
|
|||||||
import SpecHelper
|
import SpecHelper
|
||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
|
|
||||||
import Protolude hiding (get)
|
import Protolude
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
spec :: SpecWith Application
|
spec :: SpecWith Application
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Network.HTTP.Types
|
|||||||
import SpecHelper
|
import SpecHelper
|
||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
|
|
||||||
import Protolude hiding (get)
|
import Protolude
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
spec :: SpecWith Application
|
spec :: SpecWith Application
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Control.Monad.Base
|
|||||||
import Control.Monad.Trans.Control
|
import Control.Monad.Trans.Control
|
||||||
import Control.Concurrent.Async (mapConcurrently)
|
import Control.Concurrent.Async (mapConcurrently)
|
||||||
|
|
||||||
import Test.Hspec hiding (pendingWith)
|
import Test.Hspec
|
||||||
import Test.Hspec.Wai.Internal
|
import Test.Hspec.Wai.Internal
|
||||||
import Test.Hspec.Wai
|
import Test.Hspec.Wai
|
||||||
import Test.Hspec.Wai.JSON
|
import Test.Hspec.Wai.JSON
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import SpecHelper
|
|||||||
import Network.HTTP.Types
|
import Network.HTTP.Types
|
||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
|
|
||||||
import Protolude hiding (get)
|
import Protolude
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
spec :: SpecWith Application
|
spec :: SpecWith Application
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Network.HTTP.Types
|
|||||||
import SpecHelper
|
import SpecHelper
|
||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
|
|
||||||
import Protolude hiding (get)
|
import Protolude
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
spec :: SpecWith Application
|
spec :: SpecWith Application
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module Feature.PgVersion95Spec where
|
module Feature.PgVersion95Spec where
|
||||||
|
|
||||||
import Test.Hspec hiding (pendingWith)
|
import Test.Hspec
|
||||||
import Test.Hspec.Wai
|
import Test.Hspec.Wai
|
||||||
import Test.Hspec.Wai.JSON
|
import Test.Hspec.Wai.JSON
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module Feature.PgVersion96Spec where
|
module Feature.PgVersion96Spec where
|
||||||
|
|
||||||
import Test.Hspec hiding (pendingWith)
|
import Test.Hspec
|
||||||
import Test.Hspec.Wai
|
import Test.Hspec.Wai
|
||||||
import Test.Hspec.Wai.JSON
|
import Test.Hspec.Wai.JSON
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
module Feature.ProxySpec where
|
module Feature.ProxySpec where
|
||||||
|
|
||||||
import Test.Hspec hiding (pendingWith)
|
import Test.Hspec
|
||||||
|
|
||||||
import SpecHelper
|
import SpecHelper
|
||||||
|
|
||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
|
|
||||||
import Protolude hiding (get)
|
import Protolude
|
||||||
|
|
||||||
spec :: SpecWith Application
|
spec :: SpecWith Application
|
||||||
spec =
|
spec =
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module Feature.QueryLimitedSpec where
|
module Feature.QueryLimitedSpec where
|
||||||
|
|
||||||
import Test.Hspec hiding (pendingWith)
|
import Test.Hspec
|
||||||
import Test.Hspec.Wai
|
import Test.Hspec.Wai
|
||||||
import Test.Hspec.Wai.JSON
|
import Test.Hspec.Wai.JSON
|
||||||
import Network.HTTP.Types
|
import Network.HTTP.Types
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module Feature.QuerySpec where
|
module Feature.QuerySpec where
|
||||||
|
|
||||||
import Test.Hspec hiding (pendingWith)
|
import Test.Hspec
|
||||||
import Test.Hspec.Wai
|
import Test.Hspec.Wai
|
||||||
import Test.Hspec.Wai.JSON
|
import Test.Hspec.Wai.JSON
|
||||||
import Network.HTTP.Types
|
import Network.HTTP.Types
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module Feature.RpcSpec where
|
module Feature.RpcSpec where
|
||||||
|
|
||||||
import Test.Hspec hiding (pendingWith)
|
import Test.Hspec
|
||||||
import Test.Hspec.Wai
|
import Test.Hspec.Wai
|
||||||
import Test.Hspec.Wai.JSON
|
import Test.Hspec.Wai.JSON
|
||||||
import Network.HTTP.Types
|
import Network.HTTP.Types
|
||||||
@@ -372,7 +372,7 @@ spec =
|
|||||||
[json|[{"text_search_vector":"'amus':5 'fair':7 'impossibl':9 'peu':4"},{"text_search_vector":"'art':4 'spass':5 'unmog':7"}]|]
|
[json|[{"text_search_vector":"'amus':5 'fair':7 'impossibl':9 'peu':4"},{"text_search_vector":"'art':4 'spass':5 'unmog':7"}]|]
|
||||||
{ matchHeaders = [matchContentTypeJson] }
|
{ matchHeaders = [matchContentTypeJson] }
|
||||||
|
|
||||||
it "should work with an argument of custom type in public schema" $ do
|
it "should work with an argument of custom type in public schema" $
|
||||||
get "/rpc/test_arg?my_arg=something" `shouldRespondWith`
|
get "/rpc/test_arg?my_arg=something" `shouldRespondWith`
|
||||||
[json|"foobar"|]
|
[json|"foobar"|]
|
||||||
{ matchHeaders = [matchContentTypeJson] }
|
{ matchHeaders = [matchContentTypeJson] }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module Feature.StructureSpec where
|
module Feature.StructureSpec where
|
||||||
|
|
||||||
import Test.Hspec hiding (pendingWith)
|
import Test.Hspec
|
||||||
import Test.Hspec.Wai
|
import Test.Hspec.Wai
|
||||||
import Network.HTTP.Types
|
import Network.HTTP.Types
|
||||||
|
|
||||||
|
|||||||
+4
-5
@@ -19,7 +19,7 @@ import Text.Heredoc
|
|||||||
import PostgREST.Config (AppConfig(..))
|
import PostgREST.Config (AppConfig(..))
|
||||||
import PostgREST.Types (JSPathExp(..))
|
import PostgREST.Types (JSPathExp(..))
|
||||||
|
|
||||||
import Test.Hspec hiding (pendingWith)
|
import Test.Hspec
|
||||||
import Test.Hspec.Wai
|
import Test.Hspec.Wai
|
||||||
|
|
||||||
import Network.HTTP.Types
|
import Network.HTTP.Types
|
||||||
@@ -61,9 +61,8 @@ validateOpenApiResponse headers = do
|
|||||||
D4.fetchFilesystemAndValidate schemaContext ((fromJust . decode) respBody) `shouldReturn` Right ()
|
D4.fetchFilesystemAndValidate schemaContext ((fromJust . decode) respBody) `shouldReturn` Right ()
|
||||||
|
|
||||||
getEnvVarWithDefault :: Text -> Text -> IO Text
|
getEnvVarWithDefault :: Text -> Text -> IO Text
|
||||||
getEnvVarWithDefault var def = do
|
getEnvVarWithDefault var def = toS <$>
|
||||||
varValue <- getEnv (toS var) `E.catchIOError` const (return $ toS def)
|
getEnv (toS var) `E.catchIOError` const (return $ toS def)
|
||||||
return $ toS varValue
|
|
||||||
|
|
||||||
_baseCfg :: AppConfig
|
_baseCfg :: AppConfig
|
||||||
_baseCfg = -- Connection Settings
|
_baseCfg = -- Connection Settings
|
||||||
@@ -166,5 +165,5 @@ isErrorFormat s =
|
|||||||
S.null (S.difference keys validKeys)
|
S.null (S.difference keys validKeys)
|
||||||
where
|
where
|
||||||
obj = decode s :: Maybe (M.Map Text Value)
|
obj = decode s :: Maybe (M.Map Text Value)
|
||||||
keys = fromMaybe S.empty (M.keysSet <$> obj)
|
keys = maybe S.empty M.keysSet obj
|
||||||
validKeys = S.fromList ["message", "details", "hint", "code"]
|
validKeys = S.fromList ["message", "details", "hint", "code"]
|
||||||
|
|||||||
Reference in New Issue
Block a user