fix: fix output of RPCs returning scalar values with multiple rows
resolves #1584 BREAKING CHANGE: Changed output of RPCs to match return type better: * single scalar return: value (unchanged) * setof scalar return: array of values (new; was array of objects) * single composite return: object (new; was array of objects) * setof composite return: array of objects (unchanged) * void return: nothing (new; was "null") A single OUT column is now treated as "composite" instead of "scalar", i.e. consistent with multiple OUT columns.
This commit is contained in:
committed by
Wolfgang Walther
parent
093fd3c8f6
commit
0c25f12825
+10
-4
@@ -297,9 +297,8 @@ app dbStructure conf apiRequest =
|
||||
preferParams = iPreferParameters apiRequest
|
||||
pq = requestToCallProcQuery (QualifiedIdentifier pdSchema pdName) (specifiedProcArgs (iColumns apiRequest) proc)
|
||||
(iPayload apiRequest) returnsScalar preferParams returning
|
||||
stm = callProcStatement returnsScalar pq q cq shouldCount (contentType == CTSingularJSON)
|
||||
(contentType == CTTextCSV) (contentType `elem` rawContentTypes) (preferParams == Just MultipleObjects)
|
||||
bField pgVer prepared
|
||||
stm = callProcStatement returnsScalar returnsSingle pq q cq shouldCount (contentType == CTSingularJSON)
|
||||
(contentType == CTTextCSV) (preferParams == Just MultipleObjects) bField pgVer prepared
|
||||
row <- H.statement mempty stm
|
||||
let (tableTotal, queryTotal, body, gucHeaders, gucStatus) = row
|
||||
gucs = (,) <$> gucHeaders <*> gucStatus
|
||||
@@ -351,6 +350,10 @@ app dbStructure conf apiRequest =
|
||||
case iTarget apiRequest of
|
||||
TargetProc proc _ -> procReturnsScalar proc
|
||||
_ -> False
|
||||
returnsSingle =
|
||||
case iTarget apiRequest of
|
||||
TargetProc proc _ -> procReturnsSingle proc
|
||||
_ -> False
|
||||
pgVer = pgVersion dbStructure
|
||||
profileH = contentProfileH <$> iProfile apiRequest
|
||||
|
||||
@@ -401,7 +404,10 @@ responseContentTypeOrError accepts rawContentTypes action target = serves conten
|
||||
-}
|
||||
binaryField :: ContentType -> [ContentType] -> Bool -> ReadRequest -> Either Response (Maybe FieldName)
|
||||
binaryField ct rawContentTypes isScalarProc readReq
|
||||
| isScalarProc = Right Nothing
|
||||
| isScalarProc =
|
||||
if ct `elem` rawContentTypes
|
||||
then Right $ Just "pgrst_scalar"
|
||||
else Right Nothing
|
||||
| ct `elem` rawContentTypes =
|
||||
let fieldName = headMay fldNames in
|
||||
if length fldNames == 1 && fieldName /= Just "*"
|
||||
|
||||
Reference in New Issue
Block a user