Skip to content

Commit

Permalink
fix ctx RequestContext
Browse files Browse the repository at this point in the history
  • Loading branch information
monacoremo committed Jan 31, 2021
1 parent 44963e2 commit 1e6c272
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/PostgREST/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ handleRead headersOnly identifier context@RequestContext{..} = do
bField <- binaryField context req

let
ApiRequest{..} = rApiRequest
AppConfig{..} = rConfig
ApiRequest{..} = ctxApiRequest
AppConfig{..} = ctxConfig
countQuery = QueryBuilder.readRequestToCountQuery req

(tableTotal, queryTotal, _ , body, gucHeaders, gucStatus) <-
Expand All @@ -186,14 +186,14 @@ handleRead headersOnly identifier context@RequestContext{..} = do
else
countQuery
)
(rContentType == Types.CTSingularJSON)
(ctxContentType == Types.CTSingularJSON)
(shouldCount iPreferCount)
(rContentType == Types.CTTextCSV)
(ctxContentType == Types.CTTextCSV)
bField
(Types.pgVersion rDbStructure)
(Types.pgVersion ctxDbStructure)
configDbPreparedStatements

total <- readTotal rConfig rApiRequest tableTotal countQuery
total <- readTotal ctxConfig ctxApiRequest tableTotal countQuery
response <- liftEither $ gucResponse <$> gucStatus <*> gucHeaders

let
Expand All @@ -208,7 +208,7 @@ handleRead headersOnly identifier context@RequestContext{..} = do
]
++ contentTypeHeaders context

failNotSingular rContentType queryTotal . response status headers $
failNotSingular ctxContentType queryTotal . response status headers $
if headersOnly then mempty else toS body

readTotal :: AppConfig -> ApiRequest -> Maybe Int64 -> SQL.Snippet -> DbHandler (Maybe Int64)
Expand Down Expand Up @@ -454,22 +454,22 @@ writeQuery identifier@QualifiedIdentifier{..} isInsert pkCols context@RequestCon

mutateReq <-
liftEither $
ReqBuilder.mutateRequest qiSchema qiName rApiRequest
(Types.tablePKCols rDbStructure qiSchema qiName)
ReqBuilder.mutateRequest qiSchema qiName ctxApiRequest
(Types.tablePKCols ctxDbStructure qiSchema qiName)
readReq

(_, queryTotal, fields, body, gucHeaders, gucStatus) <-
lift . SQL.statement mempty $
Statements.createWriteStatement
(QueryBuilder.readRequestToQuery readReq)
(QueryBuilder.mutateRequestToQuery mutateReq)
(rContentType == Types.CTSingularJSON)
(ctxContentType == Types.CTSingularJSON)
isInsert
(rContentType == Types.CTTextCSV)
(iPreferRepresentation rApiRequest)
(ctxContentType == Types.CTTextCSV)
(iPreferRepresentation ctxApiRequest)
pkCols
(Types.pgVersion rDbStructure)
(configDbPreparedStatements rConfig)
(Types.pgVersion ctxDbStructure)
(configDbPreparedStatements ctxConfig)

liftEither $
CreateResult queryTotal fields body <$> gucStatus <*> gucHeaders
Expand Down

0 comments on commit 1e6c272

Please sign in to comment.