Add Preference-Applied header for POST upsert

- Ensure creating nothing on ignore-duplicates succeeds
- Refactor locationF query
This commit is contained in:
steve-chavez
2018-02-21 07:33:54 -05:00
committed by Steve Chávez
parent 6675821c64
commit 108f3cd651
5 changed files with 42 additions and 25 deletions
+6 -3
View File
@@ -157,10 +157,10 @@ app dbStructure proc conf apiRequest =
&& iPreferRepresentation apiRequest == Full
then return $ singularityError (toInteger nRows)
else do
let stm = createWriteStatement sq mq
let pkCols = tablePKCols dbStructure tSchema tName
stm = createWriteStatement sq mq
(contentType == CTSingularJSON) isSingle
(contentType == CTTextCSV) (iPreferRepresentation apiRequest)
(tablePKCols dbStructure tSchema tName)
(contentType == CTTextCSV) (iPreferRepresentation apiRequest) pkCols
row <- H.query (toS pjRaw) stm
let (_, _, fs, body) = extractQueryResult row
headers = catMaybes [
@@ -172,6 +172,9 @@ app dbStructure proc conf apiRequest =
else Nothing
, Just . contentRangeH 1 0 $
toInteger <$> if shouldCount then Just nRows else Nothing
, if null pkCols
then Nothing
else (\x -> ("Preference-Applied", show x)) <$> iPreferResolution apiRequest
]
return . responseLBS status201 headers $