Derp, actually put the data on a put request
This commit is contained in:
+4
-3
@@ -146,10 +146,11 @@ app conn req respond =
|
||||
cols <- columns ver (cs table) conn
|
||||
let colNames = S.fromList $ map (cs . colName) cols
|
||||
let specifiedCols = S.fromList $ map fst $ getRow row
|
||||
return $ if colNames == specifiedCols then
|
||||
responseLBS status200 [ jsonContentType ] ""
|
||||
if colNames == specifiedCols then do
|
||||
_ <- upsert ver table row qq conn
|
||||
return $ responseLBS status204 [ jsonContentType ] ""
|
||||
|
||||
else if S.null colNames then responseLBS status404 [] ""
|
||||
else return $ if S.null colNames then responseLBS status404 [] ""
|
||||
else responseLBS status400 []
|
||||
"You must specify all columns in PUT request"
|
||||
)
|
||||
|
||||
+2
-2
@@ -191,8 +191,8 @@ upsert :: Schema -> Text -> SqlRow -> Net.Query -> Connection -> IO (M.Map Strin
|
||||
upsert schema table row qq conn = do
|
||||
stmt <- prepare conn $ cs sql
|
||||
_ <- execute stmt $ join $ replicate 2 $ sqlRowValues row
|
||||
Just m <- fetchRowMap stmt
|
||||
return m
|
||||
m <- fetchRowMap stmt
|
||||
return $ fromMaybe M.empty m
|
||||
|
||||
where sql = upsertClause schema table row qq
|
||||
|
||||
|
||||
Reference in New Issue
Block a user