diff --git a/main/Main.hs b/main/Main.hs index 54410264e..d89ad3b36 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -33,7 +33,8 @@ import PostgREST.OpenAPI (isMalformedProxyUri) import PostgREST.Types (ConnectionStatus (..), DbStructure, PgVersion (..), Schema, minimumPgVersion) -import Protolude hiding (hPutStrLn, head, replace) +import Protolude hiding (hPutStrLn, head, replace, toS) +import Protolude.Conv (toS) #ifndef mingw32_HOST_OS diff --git a/postgrest.cabal b/postgrest.cabal index 6e5dc62aa..49b66922f 100644 --- a/postgrest.cabal +++ b/postgrest.cabal @@ -72,7 +72,7 @@ library , network-uri >= 2.6.1 && < 2.8 , optparse-applicative >= 0.13 && < 0.16 , parsec >= 3.1.11 && < 3.2 - , protolude >= 0.2.4 && < 0.3 + , protolude >= 0.3 && < 0.4 , regex-tdfa >= 1.2.2 && < 1.4 , scientific >= 0.3.4 && < 0.4 , swagger2 >= 2.4 && < 2.6 @@ -110,7 +110,7 @@ executable postgrest , hasql-transaction >= 0.7.2 && < 1.1 , network < 3.2 , postgrest - , protolude >= 0.2.4 && < 0.3 + , protolude >= 0.3 && < 0.4 , retry >= 0.7.4 && < 0.9 , text >= 1.2.2 && < 1.3 , time >= 1.6 && < 1.11 @@ -187,7 +187,7 @@ test-suite spec , monad-control >= 1.0.1 && < 1.1 , postgrest , process >= 1.4.2 && < 1.7 - , protolude >= 0.2.4 && < 0.3 + , protolude >= 0.3 && < 0.4 , regex-tdfa >= 1.2.2 && < 1.4 , text >= 1.2.2 && < 1.3 , time >= 1.6 && < 1.11 @@ -231,7 +231,7 @@ Test-Suite spec-querycost , monad-control >= 1.0.1 && < 1.1 , postgrest , process >= 1.4.2 && < 1.7 - , protolude >= 0.2.4 && < 0.3 + , protolude >= 0.3 && < 0.4 , regex-tdfa >= 1.2.2 && < 1.4 , text >= 1.2.2 && < 1.3 , time >= 1.6 && < 1.11 diff --git a/src/PostgREST/ApiRequest.hs b/src/PostgREST/ApiRequest.hs index 324ba42a5..8b8a10658 100644 --- a/src/PostgREST/ApiRequest.hs +++ b/src/PostgREST/ApiRequest.hs @@ -49,7 +49,8 @@ import PostgREST.RangeQuery (NonnegRange, allRange, rangeGeq, rangeLimit, rangeOffset, rangeRequested, restrictRange) import PostgREST.Types -import Protolude hiding (head) +import Protolude hiding (head, toS) +import Protolude.Conv (toS) type RequestBody = BL.ByteString diff --git a/src/PostgREST/App.hs b/src/PostgREST/App.hs index 88a2feef6..a0f2ae9a0 100644 --- a/src/PostgREST/App.hs +++ b/src/PostgREST/App.hs @@ -64,7 +64,8 @@ import PostgREST.Statements (callProcStatement, createReadStatement, createWriteStatement) import PostgREST.Types -import Protolude hiding (Proxy, intercalate) +import Protolude hiding (Proxy, intercalate, toS) +import Protolude.Conv (toS) postgrest :: AppConfig -> IORef (Maybe DbStructure) -> P.Pool -> IO UTCTime -> IO () -> Application postgrest conf refDbStructure pool getTime worker = @@ -180,7 +181,7 @@ app dbStructure proc cols conf apiRequest = , Just $ contentRangeH 1 0 $ if shouldCount then Just queryTotal else Nothing , if null pkCols && isNothing (iOnConflict apiRequest) then Nothing - else (\x -> ("Preference-Applied", show x)) <$> iPreferResolution apiRequest + else (\x -> ("Preference-Applied", encodeUtf8 (show x))) <$> iPreferResolution apiRequest ] ++ ctHeaders)) (unwrapGucHeader <$> ghdrs) if contentType == CTSingularJSON && queryTotal /= 1 then do diff --git a/src/PostgREST/Auth.hs b/src/PostgREST/Auth.hs index 4524cec90..8f16b3aaa 100644 --- a/src/PostgREST/Auth.hs +++ b/src/PostgREST/Auth.hs @@ -31,7 +31,8 @@ import Control.Lens.Operators import Crypto.JWT import PostgREST.Types -import Protolude +import Protolude hiding (toS) +import Protolude.Conv (toS) {-| Possible situations encountered with client JWTs diff --git a/src/PostgREST/Config.hs b/src/PostgREST/Config.hs index cfaec4e55..9b38fec83 100644 --- a/src/PostgREST/Config.hs +++ b/src/PostgREST/Config.hs @@ -32,7 +32,6 @@ import qualified Data.CaseInsensitive as CI import qualified Data.Configurator as C import qualified Text.PrettyPrint.ANSI.Leijen as L -import Control.Exception (Handler (..)) import Control.Lens (preview) import Control.Monad (fail) import Crypto.JWT (StringOrURI, stringOrUri) @@ -62,8 +61,8 @@ import PostgREST.Error (ApiRequestError (..)) import PostgREST.Parsers (pRoleClaimKey) import PostgREST.Types (JSPath, JSPathExp (..)) import Protolude hiding (concat, hPutStrLn, intercalate, null, - take, (<>)) - + take, toS, (<>)) +import Protolude.Conv (toS) -- | Config file settings for the server diff --git a/src/PostgREST/DbStructure.hs b/src/PostgREST/DbStructure.hs index f3cadf1a4..720d157cf 100644 --- a/src/PostgREST/DbStructure.hs +++ b/src/PostgREST/DbStructure.hs @@ -35,14 +35,13 @@ import Data.Set as S (fromList) import Data.Text (breakOn, dropAround, split, splitOn, strip) import GHC.Exts (groupWith) +import Protolude hiding (toS) +import Protolude.Conv (toS) +import Protolude.Unsafe (unsafeHead) import Text.InterpolatedString.Perl6 (q, qc) -import Unsafe (unsafeHead) - -import Control.Applicative import PostgREST.Private.Common import PostgREST.Types -import Protolude getDbStructure :: [Schema] -> PgVersion -> HT.Transaction DbStructure getDbStructure schemas pgVer = do diff --git a/src/PostgREST/Error.hs b/src/PostgREST/Error.hs index 9766b1924..51c0c177f 100644 --- a/src/PostgREST/Error.hs +++ b/src/PostgREST/Error.hs @@ -27,7 +27,8 @@ import Network.Wai (Response, responseLBS) import Network.HTTP.Types.Header import PostgREST.Types -import Protolude +import Protolude hiding (toS) +import Protolude.Conv (toS) class (JSON.ToJSON a) => PgrstError a where @@ -279,7 +280,7 @@ instance JSON.ToJSON SimpleError where invalidTokenHeader :: Text -> Header invalidTokenHeader m = - ("WWW-Authenticate", "Bearer error=\"invalid_token\", " <> "error_description=" <> show m) + ("WWW-Authenticate", "Bearer error=\"invalid_token\", " <> "error_description=" <> encodeUtf8 (show m)) singularityError :: (Integral a) => a -> SimpleError singularityError = SingularityError . toInteger diff --git a/src/PostgREST/Middleware.hs b/src/PostgREST/Middleware.hs index 93d3e4ec2..73bcd5bb6 100644 --- a/src/PostgREST/Middleware.hs +++ b/src/PostgREST/Middleware.hs @@ -27,7 +27,8 @@ import PostgREST.Config (AppConfig (..), corsPolicy) import PostgREST.Error (SimpleError (JwtTokenInvalid, JwtTokenMissing), errorResponseFor) import PostgREST.QueryBuilder (setLocalQuery, setLocalSearchPathQuery) -import Protolude hiding (head) +import Protolude hiding (head, toS) +import Protolude.Conv (toS) runWithClaims :: AppConfig -> JWTAttempt -> (ApiRequest -> H.Transaction Response) -> diff --git a/src/PostgREST/OpenAPI.hs b/src/PostgREST/OpenAPI.hs index 4dc497132..f98978271 100644 --- a/src/PostgREST/OpenAPI.hs +++ b/src/PostgREST/OpenAPI.hs @@ -32,7 +32,8 @@ import PostgREST.Types (Column (..), ForeignKey (..), PgArg (..), PrimaryKey (..), ProcDescription (..), Proxy (..), Table (..), toMime) import Protolude hiding (Proxy, dropWhile, get, - intercalate, (&)) + intercalate, toLower, toS, (&)) +import Protolude.Conv (toS) makeMimeList :: [ContentType] -> MimeList makeMimeList cs = MimeList $ map (fromString . toS . toMime) cs diff --git a/src/PostgREST/Parsers.hs b/src/PostgREST/Parsers.hs index 98239f8e5..12a989e32 100644 --- a/src/PostgREST/Parsers.hs +++ b/src/PostgREST/Parsers.hs @@ -22,7 +22,9 @@ import Text.ParserCombinators.Parsec hiding (many, (<|>)) import PostgREST.Error (ApiRequestError (ParseRequestError)) import PostgREST.RangeQuery (NonnegRange) import PostgREST.Types -import Protolude hiding (intercalate, option, replace, try) +import Protolude hiding (intercalate, option, replace, toS, + try) +import Protolude.Conv (toS) pRequestSelect :: Text -> Either ApiRequestError [Tree SelectItem] pRequestSelect selStr = diff --git a/src/PostgREST/Private/QueryFragment.hs b/src/PostgREST/Private/QueryFragment.hs index cbd5a868e..95d54edb1 100644 --- a/src/PostgREST/Private/QueryFragment.hs +++ b/src/PostgREST/Private/QueryFragment.hs @@ -16,7 +16,8 @@ import qualified Data.Text as T (map, null, takeWhile) import PostgREST.Types import Protolude hiding (cast, - intercalate, replace) + intercalate, replace, + toLower) import Text.InterpolatedString.Perl6 (qc) noLocationF :: SqlFragment diff --git a/src/PostgREST/RangeQuery.hs b/src/PostgREST/RangeQuery.hs index 0aadafeb1..0cb02a489 100644 --- a/src/PostgREST/RangeQuery.hs +++ b/src/PostgREST/RangeQuery.hs @@ -26,7 +26,8 @@ import Data.Ranged.Ranges import Network.HTTP.Types.Header import Network.HTTP.Types.Status -import Protolude +import Protolude hiding (toS) +import Protolude.Conv (toS) type NonnegRange = Range Integer @@ -91,9 +92,9 @@ rangeStatusHeader topLevelRange queryTotal tableTotal = contentRangeH :: (Integral a, Show a) => a -> a -> Maybe a -> Header contentRangeH lower upper total = - ("Content-Range", headerValue) + ("Content-Range", toUtf8 headerValue) where - headerValue = rangeString <> "/" <> totalString + headerValue = rangeString <> "/" <> totalString :: Text rangeString | totalNotZero && fromInRange = show lower <> "-" <> show upper | otherwise = "*" diff --git a/src/PostgREST/Statements.hs b/src/PostgREST/Statements.hs index b169f537d..056f39190 100644 --- a/src/PostgREST/Statements.hs +++ b/src/PostgREST/Statements.hs @@ -29,7 +29,8 @@ import PostgREST.Private.Common import PostgREST.Private.QueryFragment import PostgREST.Types import Protolude hiding (cast, - replace) + replace, toS) +import Protolude.Conv (toS) import Text.InterpolatedString.Perl6 (qc) {-| The generic query result format used by API responses. The location header diff --git a/src/PostgREST/Types.hs b/src/PostgREST/Types.hs index 9cdd54750..33e13906f 100644 --- a/src/PostgREST/Types.hs +++ b/src/PostgREST/Types.hs @@ -24,7 +24,8 @@ import Network.HTTP.Types.Header (Header, hContentType) import Data.Tree import PostgREST.RangeQuery (NonnegRange) -import Protolude +import Protolude hiding (toS) +import Protolude.Conv (toS) -- | Enumeration of currently supported response content types data ContentType = CTApplicationJSON | CTSingularJSON diff --git a/stack.yaml b/stack.yaml index 99140ca17..fdcdedd85 100644 --- a/stack.yaml +++ b/stack.yaml @@ -16,3 +16,4 @@ extra-deps: - configurator-pg-0.2.2@sha256:8f3f7c66dd4a53852283c70806ebc101a7219f8b01c3e80c5130e9749c998dc8,2987 - hspec-wai-json-0.10.1@sha256:67b405c38f0a9e2771480c8d3ecd8aeb8d8776a35d3b2906cb1b76c9538617e4,1629 - interpolatedstring-perl6-1.0.2@sha256:7ce49c8a69a2a1b89c001ed79db2aab656ffd0faf2a7a701a553b6deb5c8ba7f,1073 +- protolude-0.3.0@sha256:8361b811b420585b122a7ba715aa5923834db6e8c36309bf267df2dbf66b95ef,2693 diff --git a/stack.yaml.lock b/stack.yaml.lock index 04648b38e..cc4d05a75 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -25,6 +25,13 @@ packages: sha256: f7f0b06c58db814d1f12ed6f4f4cb67ff8c72e51da61c04db12c2aedb896542e original: hackage: interpolatedstring-perl6-1.0.2@sha256:7ce49c8a69a2a1b89c001ed79db2aab656ffd0faf2a7a701a553b6deb5c8ba7f,1073 +- completed: + hackage: protolude-0.3.0@sha256:8361b811b420585b122a7ba715aa5923834db6e8c36309bf267df2dbf66b95ef,2693 + pantry-tree: + size: 1644 + sha256: babf32b414f25f790b7a4ce6bae5c960bc51a11a289e7c47335b222e6762560c + original: + hackage: protolude-0.3.0 snapshots: - completed: size: 492015 diff --git a/test/Main.hs b/test/Main.hs index 869f6a667..d713942b4 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -16,7 +16,8 @@ import PostgREST.App (postgrest) import PostgREST.Config (AppConfig (..)) import PostgREST.DbStructure (getDbStructure, getPgVersion) import PostgREST.Types (pgVersion95, pgVersion96) -import Protolude hiding (toList) +import Protolude hiding (toList, toS) +import Protolude.Conv (toS) import SpecHelper import qualified Feature.AndOrParamsSpec diff --git a/test/QueryCost.hs b/test/QueryCost.hs index 81c5860be..2ef2a756c 100644 --- a/test/QueryCost.hs +++ b/test/QueryCost.hs @@ -10,7 +10,8 @@ import qualified Hasql.Transaction as HT import qualified Hasql.Transaction.Sessions as HT import Text.Heredoc -import Protolude hiding (get) +import Protolude hiding (get, toS) +import Protolude.Conv (toS) import PostgREST.QueryBuilder (requestToCallProcQuery) import PostgREST.Types diff --git a/test/SpecHelper.hs b/test/SpecHelper.hs index 00eeb14bb..41ad4659e 100644 --- a/test/SpecHelper.hs +++ b/test/SpecHelper.hs @@ -24,7 +24,8 @@ import Text.Heredoc import PostgREST.Config (AppConfig (..)) import PostgREST.Types (JSPathExp (..)) -import Protolude +import Protolude hiding (toS) +import Protolude.Conv (toS) matchContentTypeJson :: MatchHeader matchContentTypeJson = "Content-Type" <:> "application/json; charset=utf-8"