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:
committed by
Steve Chavez
parent
2e6a094d48
commit
3da5a2875e
+2
-1
@@ -33,7 +33,8 @@ import PostgREST.OpenAPI (isMalformedProxyUri)
|
|||||||
import PostgREST.Types (ConnectionStatus (..), DbStructure,
|
import PostgREST.Types (ConnectionStatus (..), DbStructure,
|
||||||
PgVersion (..), Schema,
|
PgVersion (..), Schema,
|
||||||
minimumPgVersion)
|
minimumPgVersion)
|
||||||
import Protolude hiding (hPutStrLn, head, replace)
|
import Protolude hiding (hPutStrLn, head, replace, toS)
|
||||||
|
import Protolude.Conv (toS)
|
||||||
|
|
||||||
|
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
|
|||||||
+4
-4
@@ -72,7 +72,7 @@ library
|
|||||||
, network-uri >= 2.6.1 && < 2.8
|
, network-uri >= 2.6.1 && < 2.8
|
||||||
, optparse-applicative >= 0.13 && < 0.16
|
, optparse-applicative >= 0.13 && < 0.16
|
||||||
, parsec >= 3.1.11 && < 3.2
|
, parsec >= 3.1.11 && < 3.2
|
||||||
, protolude >= 0.2.4 && < 0.3
|
, protolude >= 0.3 && < 0.4
|
||||||
, regex-tdfa >= 1.2.2 && < 1.4
|
, regex-tdfa >= 1.2.2 && < 1.4
|
||||||
, scientific >= 0.3.4 && < 0.4
|
, scientific >= 0.3.4 && < 0.4
|
||||||
, swagger2 >= 2.4 && < 2.6
|
, swagger2 >= 2.4 && < 2.6
|
||||||
@@ -110,7 +110,7 @@ executable postgrest
|
|||||||
, hasql-transaction >= 0.7.2 && < 1.1
|
, hasql-transaction >= 0.7.2 && < 1.1
|
||||||
, network < 3.2
|
, network < 3.2
|
||||||
, postgrest
|
, postgrest
|
||||||
, protolude >= 0.2.4 && < 0.3
|
, protolude >= 0.3 && < 0.4
|
||||||
, retry >= 0.7.4 && < 0.9
|
, retry >= 0.7.4 && < 0.9
|
||||||
, text >= 1.2.2 && < 1.3
|
, text >= 1.2.2 && < 1.3
|
||||||
, time >= 1.6 && < 1.11
|
, time >= 1.6 && < 1.11
|
||||||
@@ -187,7 +187,7 @@ test-suite spec
|
|||||||
, monad-control >= 1.0.1 && < 1.1
|
, monad-control >= 1.0.1 && < 1.1
|
||||||
, postgrest
|
, postgrest
|
||||||
, process >= 1.4.2 && < 1.7
|
, process >= 1.4.2 && < 1.7
|
||||||
, protolude >= 0.2.4 && < 0.3
|
, protolude >= 0.3 && < 0.4
|
||||||
, regex-tdfa >= 1.2.2 && < 1.4
|
, regex-tdfa >= 1.2.2 && < 1.4
|
||||||
, text >= 1.2.2 && < 1.3
|
, text >= 1.2.2 && < 1.3
|
||||||
, time >= 1.6 && < 1.11
|
, time >= 1.6 && < 1.11
|
||||||
@@ -231,7 +231,7 @@ Test-Suite spec-querycost
|
|||||||
, monad-control >= 1.0.1 && < 1.1
|
, monad-control >= 1.0.1 && < 1.1
|
||||||
, postgrest
|
, postgrest
|
||||||
, process >= 1.4.2 && < 1.7
|
, process >= 1.4.2 && < 1.7
|
||||||
, protolude >= 0.2.4 && < 0.3
|
, protolude >= 0.3 && < 0.4
|
||||||
, regex-tdfa >= 1.2.2 && < 1.4
|
, regex-tdfa >= 1.2.2 && < 1.4
|
||||||
, text >= 1.2.2 && < 1.3
|
, text >= 1.2.2 && < 1.3
|
||||||
, time >= 1.6 && < 1.11
|
, time >= 1.6 && < 1.11
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ import PostgREST.RangeQuery (NonnegRange, allRange, rangeGeq,
|
|||||||
rangeLimit, rangeOffset, rangeRequested,
|
rangeLimit, rangeOffset, rangeRequested,
|
||||||
restrictRange)
|
restrictRange)
|
||||||
import PostgREST.Types
|
import PostgREST.Types
|
||||||
import Protolude hiding (head)
|
import Protolude hiding (head, toS)
|
||||||
|
import Protolude.Conv (toS)
|
||||||
|
|
||||||
type RequestBody = BL.ByteString
|
type RequestBody = BL.ByteString
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ import PostgREST.Statements (callProcStatement,
|
|||||||
createReadStatement,
|
createReadStatement,
|
||||||
createWriteStatement)
|
createWriteStatement)
|
||||||
import PostgREST.Types
|
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 :: AppConfig -> IORef (Maybe DbStructure) -> P.Pool -> IO UTCTime -> IO () -> Application
|
||||||
postgrest conf refDbStructure pool getTime worker =
|
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
|
, Just $ contentRangeH 1 0 $ if shouldCount then Just queryTotal else Nothing
|
||||||
, if null pkCols && isNothing (iOnConflict apiRequest)
|
, if null pkCols && isNothing (iOnConflict apiRequest)
|
||||||
then Nothing
|
then Nothing
|
||||||
else (\x -> ("Preference-Applied", show x)) <$> iPreferResolution apiRequest
|
else (\x -> ("Preference-Applied", encodeUtf8 (show x))) <$> iPreferResolution apiRequest
|
||||||
] ++ ctHeaders)) (unwrapGucHeader <$> ghdrs)
|
] ++ ctHeaders)) (unwrapGucHeader <$> ghdrs)
|
||||||
if contentType == CTSingularJSON && queryTotal /= 1
|
if contentType == CTSingularJSON && queryTotal /= 1
|
||||||
then do
|
then do
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ import Control.Lens.Operators
|
|||||||
import Crypto.JWT
|
import Crypto.JWT
|
||||||
|
|
||||||
import PostgREST.Types
|
import PostgREST.Types
|
||||||
import Protolude
|
import Protolude hiding (toS)
|
||||||
|
import Protolude.Conv (toS)
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
Possible situations encountered with client JWTs
|
Possible situations encountered with client JWTs
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import qualified Data.CaseInsensitive as CI
|
|||||||
import qualified Data.Configurator as C
|
import qualified Data.Configurator as C
|
||||||
import qualified Text.PrettyPrint.ANSI.Leijen as L
|
import qualified Text.PrettyPrint.ANSI.Leijen as L
|
||||||
|
|
||||||
import Control.Exception (Handler (..))
|
|
||||||
import Control.Lens (preview)
|
import Control.Lens (preview)
|
||||||
import Control.Monad (fail)
|
import Control.Monad (fail)
|
||||||
import Crypto.JWT (StringOrURI, stringOrUri)
|
import Crypto.JWT (StringOrURI, stringOrUri)
|
||||||
@@ -62,8 +61,8 @@ import PostgREST.Error (ApiRequestError (..))
|
|||||||
import PostgREST.Parsers (pRoleClaimKey)
|
import PostgREST.Parsers (pRoleClaimKey)
|
||||||
import PostgREST.Types (JSPath, JSPathExp (..))
|
import PostgREST.Types (JSPath, JSPathExp (..))
|
||||||
import Protolude hiding (concat, hPutStrLn, intercalate, null,
|
import Protolude hiding (concat, hPutStrLn, intercalate, null,
|
||||||
take, (<>))
|
take, toS, (<>))
|
||||||
|
import Protolude.Conv (toS)
|
||||||
|
|
||||||
|
|
||||||
-- | Config file settings for the server
|
-- | Config file settings for the server
|
||||||
|
|||||||
@@ -35,14 +35,13 @@ import Data.Set as S (fromList)
|
|||||||
import Data.Text (breakOn, dropAround, split,
|
import Data.Text (breakOn, dropAround, split,
|
||||||
splitOn, strip)
|
splitOn, strip)
|
||||||
import GHC.Exts (groupWith)
|
import GHC.Exts (groupWith)
|
||||||
|
import Protolude hiding (toS)
|
||||||
|
import Protolude.Conv (toS)
|
||||||
|
import Protolude.Unsafe (unsafeHead)
|
||||||
import Text.InterpolatedString.Perl6 (q, qc)
|
import Text.InterpolatedString.Perl6 (q, qc)
|
||||||
import Unsafe (unsafeHead)
|
|
||||||
|
|
||||||
import Control.Applicative
|
|
||||||
|
|
||||||
import PostgREST.Private.Common
|
import PostgREST.Private.Common
|
||||||
import PostgREST.Types
|
import PostgREST.Types
|
||||||
import Protolude
|
|
||||||
|
|
||||||
getDbStructure :: [Schema] -> PgVersion -> HT.Transaction DbStructure
|
getDbStructure :: [Schema] -> PgVersion -> HT.Transaction DbStructure
|
||||||
getDbStructure schemas pgVer = do
|
getDbStructure schemas pgVer = do
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ import Network.Wai (Response, responseLBS)
|
|||||||
import Network.HTTP.Types.Header
|
import Network.HTTP.Types.Header
|
||||||
|
|
||||||
import PostgREST.Types
|
import PostgREST.Types
|
||||||
import Protolude
|
import Protolude hiding (toS)
|
||||||
|
import Protolude.Conv (toS)
|
||||||
|
|
||||||
|
|
||||||
class (JSON.ToJSON a) => PgrstError a where
|
class (JSON.ToJSON a) => PgrstError a where
|
||||||
@@ -279,7 +280,7 @@ instance JSON.ToJSON SimpleError where
|
|||||||
|
|
||||||
invalidTokenHeader :: Text -> Header
|
invalidTokenHeader :: Text -> Header
|
||||||
invalidTokenHeader m =
|
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 :: (Integral a) => a -> SimpleError
|
||||||
singularityError = SingularityError . toInteger
|
singularityError = SingularityError . toInteger
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ import PostgREST.Config (AppConfig (..), corsPolicy)
|
|||||||
import PostgREST.Error (SimpleError (JwtTokenInvalid, JwtTokenMissing),
|
import PostgREST.Error (SimpleError (JwtTokenInvalid, JwtTokenMissing),
|
||||||
errorResponseFor)
|
errorResponseFor)
|
||||||
import PostgREST.QueryBuilder (setLocalQuery, setLocalSearchPathQuery)
|
import PostgREST.QueryBuilder (setLocalQuery, setLocalSearchPathQuery)
|
||||||
import Protolude hiding (head)
|
import Protolude hiding (head, toS)
|
||||||
|
import Protolude.Conv (toS)
|
||||||
|
|
||||||
runWithClaims :: AppConfig -> JWTAttempt ->
|
runWithClaims :: AppConfig -> JWTAttempt ->
|
||||||
(ApiRequest -> H.Transaction Response) ->
|
(ApiRequest -> H.Transaction Response) ->
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ import PostgREST.Types (Column (..), ForeignKey (..), PgArg (..),
|
|||||||
PrimaryKey (..), ProcDescription (..),
|
PrimaryKey (..), ProcDescription (..),
|
||||||
Proxy (..), Table (..), toMime)
|
Proxy (..), Table (..), toMime)
|
||||||
import Protolude hiding (Proxy, dropWhile, get,
|
import Protolude hiding (Proxy, dropWhile, get,
|
||||||
intercalate, (&))
|
intercalate, toLower, toS, (&))
|
||||||
|
import Protolude.Conv (toS)
|
||||||
|
|
||||||
makeMimeList :: [ContentType] -> MimeList
|
makeMimeList :: [ContentType] -> MimeList
|
||||||
makeMimeList cs = MimeList $ map (fromString . toS . toMime) cs
|
makeMimeList cs = MimeList $ map (fromString . toS . toMime) cs
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ import Text.ParserCombinators.Parsec hiding (many, (<|>))
|
|||||||
import PostgREST.Error (ApiRequestError (ParseRequestError))
|
import PostgREST.Error (ApiRequestError (ParseRequestError))
|
||||||
import PostgREST.RangeQuery (NonnegRange)
|
import PostgREST.RangeQuery (NonnegRange)
|
||||||
import PostgREST.Types
|
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 :: Text -> Either ApiRequestError [Tree SelectItem]
|
||||||
pRequestSelect selStr =
|
pRequestSelect selStr =
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ import qualified Data.Text as T (map, null,
|
|||||||
takeWhile)
|
takeWhile)
|
||||||
import PostgREST.Types
|
import PostgREST.Types
|
||||||
import Protolude hiding (cast,
|
import Protolude hiding (cast,
|
||||||
intercalate, replace)
|
intercalate, replace,
|
||||||
|
toLower)
|
||||||
import Text.InterpolatedString.Perl6 (qc)
|
import Text.InterpolatedString.Perl6 (qc)
|
||||||
|
|
||||||
noLocationF :: SqlFragment
|
noLocationF :: SqlFragment
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ import Data.Ranged.Ranges
|
|||||||
import Network.HTTP.Types.Header
|
import Network.HTTP.Types.Header
|
||||||
import Network.HTTP.Types.Status
|
import Network.HTTP.Types.Status
|
||||||
|
|
||||||
import Protolude
|
import Protolude hiding (toS)
|
||||||
|
import Protolude.Conv (toS)
|
||||||
|
|
||||||
type NonnegRange = Range Integer
|
type NonnegRange = Range Integer
|
||||||
|
|
||||||
@@ -91,9 +92,9 @@ rangeStatusHeader topLevelRange queryTotal tableTotal =
|
|||||||
|
|
||||||
contentRangeH :: (Integral a, Show a) => a -> a -> Maybe a -> Header
|
contentRangeH :: (Integral a, Show a) => a -> a -> Maybe a -> Header
|
||||||
contentRangeH lower upper total =
|
contentRangeH lower upper total =
|
||||||
("Content-Range", headerValue)
|
("Content-Range", toUtf8 headerValue)
|
||||||
where
|
where
|
||||||
headerValue = rangeString <> "/" <> totalString
|
headerValue = rangeString <> "/" <> totalString :: Text
|
||||||
rangeString
|
rangeString
|
||||||
| totalNotZero && fromInRange = show lower <> "-" <> show upper
|
| totalNotZero && fromInRange = show lower <> "-" <> show upper
|
||||||
| otherwise = "*"
|
| otherwise = "*"
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ import PostgREST.Private.Common
|
|||||||
import PostgREST.Private.QueryFragment
|
import PostgREST.Private.QueryFragment
|
||||||
import PostgREST.Types
|
import PostgREST.Types
|
||||||
import Protolude hiding (cast,
|
import Protolude hiding (cast,
|
||||||
replace)
|
replace, toS)
|
||||||
|
import Protolude.Conv (toS)
|
||||||
import Text.InterpolatedString.Perl6 (qc)
|
import Text.InterpolatedString.Perl6 (qc)
|
||||||
|
|
||||||
{-| The generic query result format used by API responses. The location header
|
{-| The generic query result format used by API responses. The location header
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ import Network.HTTP.Types.Header (Header, hContentType)
|
|||||||
import Data.Tree
|
import Data.Tree
|
||||||
|
|
||||||
import PostgREST.RangeQuery (NonnegRange)
|
import PostgREST.RangeQuery (NonnegRange)
|
||||||
import Protolude
|
import Protolude hiding (toS)
|
||||||
|
import Protolude.Conv (toS)
|
||||||
|
|
||||||
-- | Enumeration of currently supported response content types
|
-- | Enumeration of currently supported response content types
|
||||||
data ContentType = CTApplicationJSON | CTSingularJSON
|
data ContentType = CTApplicationJSON | CTSingularJSON
|
||||||
|
|||||||
@@ -16,3 +16,4 @@ extra-deps:
|
|||||||
- configurator-pg-0.2.2@sha256:8f3f7c66dd4a53852283c70806ebc101a7219f8b01c3e80c5130e9749c998dc8,2987
|
- configurator-pg-0.2.2@sha256:8f3f7c66dd4a53852283c70806ebc101a7219f8b01c3e80c5130e9749c998dc8,2987
|
||||||
- hspec-wai-json-0.10.1@sha256:67b405c38f0a9e2771480c8d3ecd8aeb8d8776a35d3b2906cb1b76c9538617e4,1629
|
- hspec-wai-json-0.10.1@sha256:67b405c38f0a9e2771480c8d3ecd8aeb8d8776a35d3b2906cb1b76c9538617e4,1629
|
||||||
- interpolatedstring-perl6-1.0.2@sha256:7ce49c8a69a2a1b89c001ed79db2aab656ffd0faf2a7a701a553b6deb5c8ba7f,1073
|
- interpolatedstring-perl6-1.0.2@sha256:7ce49c8a69a2a1b89c001ed79db2aab656ffd0faf2a7a701a553b6deb5c8ba7f,1073
|
||||||
|
- protolude-0.3.0@sha256:8361b811b420585b122a7ba715aa5923834db6e8c36309bf267df2dbf66b95ef,2693
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ packages:
|
|||||||
sha256: f7f0b06c58db814d1f12ed6f4f4cb67ff8c72e51da61c04db12c2aedb896542e
|
sha256: f7f0b06c58db814d1f12ed6f4f4cb67ff8c72e51da61c04db12c2aedb896542e
|
||||||
original:
|
original:
|
||||||
hackage: interpolatedstring-perl6-1.0.2@sha256:7ce49c8a69a2a1b89c001ed79db2aab656ffd0faf2a7a701a553b6deb5c8ba7f,1073
|
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:
|
snapshots:
|
||||||
- completed:
|
- completed:
|
||||||
size: 492015
|
size: 492015
|
||||||
|
|||||||
+2
-1
@@ -16,7 +16,8 @@ import PostgREST.App (postgrest)
|
|||||||
import PostgREST.Config (AppConfig (..))
|
import PostgREST.Config (AppConfig (..))
|
||||||
import PostgREST.DbStructure (getDbStructure, getPgVersion)
|
import PostgREST.DbStructure (getDbStructure, getPgVersion)
|
||||||
import PostgREST.Types (pgVersion95, pgVersion96)
|
import PostgREST.Types (pgVersion95, pgVersion96)
|
||||||
import Protolude hiding (toList)
|
import Protolude hiding (toList, toS)
|
||||||
|
import Protolude.Conv (toS)
|
||||||
import SpecHelper
|
import SpecHelper
|
||||||
|
|
||||||
import qualified Feature.AndOrParamsSpec
|
import qualified Feature.AndOrParamsSpec
|
||||||
|
|||||||
+2
-1
@@ -10,7 +10,8 @@ import qualified Hasql.Transaction as HT
|
|||||||
import qualified Hasql.Transaction.Sessions as HT
|
import qualified Hasql.Transaction.Sessions as HT
|
||||||
import Text.Heredoc
|
import Text.Heredoc
|
||||||
|
|
||||||
import Protolude hiding (get)
|
import Protolude hiding (get, toS)
|
||||||
|
import Protolude.Conv (toS)
|
||||||
|
|
||||||
import PostgREST.QueryBuilder (requestToCallProcQuery)
|
import PostgREST.QueryBuilder (requestToCallProcQuery)
|
||||||
import PostgREST.Types
|
import PostgREST.Types
|
||||||
|
|||||||
+2
-1
@@ -24,7 +24,8 @@ import Text.Heredoc
|
|||||||
|
|
||||||
import PostgREST.Config (AppConfig (..))
|
import PostgREST.Config (AppConfig (..))
|
||||||
import PostgREST.Types (JSPathExp (..))
|
import PostgREST.Types (JSPathExp (..))
|
||||||
import Protolude
|
import Protolude hiding (toS)
|
||||||
|
import Protolude.Conv (toS)
|
||||||
|
|
||||||
matchContentTypeJson :: MatchHeader
|
matchContentTypeJson :: MatchHeader
|
||||||
matchContentTypeJson = "Content-Type" <:> "application/json; charset=utf-8"
|
matchContentTypeJson = "Content-Type" <:> "application/json; charset=utf-8"
|
||||||
|
|||||||
Reference in New Issue
Block a user