Derp, actually put the data on a put request

This commit is contained in:
Joe Nelson
2014-11-06 18:31:13 -08:00
parent ffa2870061
commit 76ea92bfce
5 changed files with 73 additions and 18 deletions
+4 -3
View File
@@ -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
View File
@@ -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