From 17cfd474b4b67590fa406bb30d25d0b6fe6003f3 Mon Sep 17 00:00:00 2001 From: Kei Hibino Date: Sat, 11 May 2013 03:20:28 +0900 Subject: [PATCH] Fix values list for update statement. --- DB-record/src/Database/Record/ToSql.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DB-record/src/Database/Record/ToSql.hs b/DB-record/src/Database/Record/ToSql.hs index 3ad4402b..45a7d516 100644 --- a/DB-record/src/Database/Record/ToSql.hs +++ b/DB-record/src/Database/Record/ToSql.hs @@ -60,12 +60,14 @@ instance ToSql q () where fromRecord :: ToSql q a => a -> [q] fromRecord = runFromRecord recordToSql +-- | Expect update form like +-- "UPDATE SET c0 = ?, c1 = ?, ..., cn = ? WHERE key = ? " updateValuesByUnique' :: RecordToSql q ra -> KeyConstraint Unique ra -> ra -> [q] -updateValuesByUnique' pr uk a = hd ++ tl where - (hd, _uk:tl) = splitAt (index uk) (runFromRecord pr a) +updateValuesByUnique' pr uk a = hd ++ tl ++ [key] where + (hd, key:tl) = splitAt (index uk) (runFromRecord pr a) updateValuesByUnique :: ToSql q ra => KeyConstraint Unique ra