Update to protolude 0.3.0

The good part is that protolude 0.3.0 builds with GHC 8.10.

The bad part is that this change is a bit painful:
- the default `toS` has changed to no longer convert to and from ByteString
- similarly, `show` no longer outputs ByteString

The changes here are pretty much minimal to keep things compiling; I didn't
see a nice way to work with the new ConvertText class, even though `toUtf8`
seems like it might help if used besides `toS` at just the right spots.
This commit is contained in:
Robert Vollmert
2020-04-23 14:14:21 -05:00
committed by Steve Chavez
parent 2e6a094d48
commit 3da5a2875e
20 changed files with 52 additions and 30 deletions
+2 -1
View File
@@ -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
+4 -4
View File
@@ -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
+2 -1
View File
@@ -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
+3 -2
View File
@@ -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
+2 -1
View File
@@ -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
+2 -3
View File
@@ -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
+3 -4
View File
@@ -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
+3 -2
View File
@@ -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
+2 -1
View File
@@ -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) ->
+2 -1
View File
@@ -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
+3 -1
View File
@@ -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 =
+2 -1
View File
@@ -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
+4 -3
View File
@@ -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 = "*"
+2 -1
View File
@@ -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
+2 -1
View File
@@ -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
+1
View File
@@ -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
+7
View File
@@ -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
+2 -1
View File
@@ -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
+2 -1
View File
@@ -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
+2 -1
View File
@@ -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"