diff --git a/src/PostgREST/Query/QueryBuilder.hs b/src/PostgREST/Query/QueryBuilder.hs index cdd2f5a7e1..f40cec557b 100644 --- a/src/PostgREST/Query/QueryBuilder.hs +++ b/src/PostgREST/Query/QueryBuilder.hs @@ -161,8 +161,8 @@ mutateRequestToQuery (Delete mainQi body logicForest pkFlts range ordts returnin else "WITH " <> normalizedBody body <> " ") <> "DELETE FROM " <> SQL.sql (fromQi mainQi) <> " " <> (if not (null logicForest) || hasEmptyBody - then mempty else - "USING (SELECT * FROM json_populate_recordset (null::" <> SQL.sql (fromQi mainQi) <> " , " <> SQL.sql selectBody <> " )) pgrst_delete_body ") <> + then mempty + else "USING (SELECT * FROM json_populate_recordset (null::" <> SQL.sql (fromQi mainQi) <> " , " <> SQL.sql selectBody <> " )) pgrst_delete_body ") <> "WHERE " <> whereLogic <> " " <> SQL.sql (returningF mainQi returnings) diff --git a/src/PostgREST/Request/ApiRequest.hs b/src/PostgREST/Request/ApiRequest.hs index 6e78e48a27..709a20ccd1 100644 --- a/src/PostgREST/Request/ApiRequest.hs +++ b/src/PostgREST/Request/ApiRequest.hs @@ -69,7 +69,7 @@ import qualified PostgREST.Request.Preferences as Preferences import qualified PostgREST.Request.QueryParams as QueryParams import Protolude ---import Debug.Trace as BUG + type RequestBody = LBS.ByteString @@ -269,7 +269,7 @@ apiRequest conf@AppConfig{..} dbStructure req reqBody queryparams@QueryParams{.. payload :: Either ByteString Payload payload = case (contentMediaType, pathIsProc) of (MTApplicationJSON, _) -> - if isJust columns -- || method == "DELETE" -- For DELETES, always searches for primary keys only + if isJust columns then Right $ RawJSON reqBody else note "All object keys must match" . payloadAttributes reqBody =<< if LBS.null reqBody && pathIsProc diff --git a/src/PostgREST/Request/DbRequestBuilder.hs b/src/PostgREST/Request/DbRequestBuilder.hs index ea6204d936..71c4e7b19d 100644 --- a/src/PostgREST/Request/DbRequestBuilder.hs +++ b/src/PostgREST/Request/DbRequestBuilder.hs @@ -56,7 +56,7 @@ import PostgREST.Request.Types import qualified PostgREST.Request.QueryParams as QueryParams import Protolude hiding (from) ---import Debug.Trace as BUG + -- | Builds the ReadRequest tree on a number of stages. -- | Adds filters, order, limits on its respective nodes. -- | Adds joins conditions obtained from resource embedding.