Browse files

Serve null instead of empty string

  • Loading branch information...
1 parent 95da30b commit b5e822bf4386b6660e2843da4bc3f317d0f89000 @dzhus dzhus committed Mar 22, 2012
Showing with 5 additions and 6 deletions.
  1. +2 −1 README.org
  2. +3 −5 src/Snap/Snaplet/Redson/Snapless/CRUD.hs
View
3 README.org
@@ -431,7 +431,8 @@
Response is a list of JSON objects for matched instances. If
_fields is provided, then response is a list of arrays instead,
where every array contains values of specified fields in instance
- (in order given by _fields parameter).
+ (in order given by _fields parameter; if value is not present
+ then null is used).
No per-field read permissions are checked.
** Extra features
View
8 src/Snap/Snaplet/Redson/Snapless/CRUD.hs
@@ -147,11 +147,9 @@ getOldIndices key findices = do
------------------------------------------------------------------------------
--- | Extract values of named fields from commit. If field is not
--- present in commit, empty string is used for its value instead.
-onlyFields :: Commit -> [FieldName] -> [FieldValue]
-onlyFields commit names =
- map (\fieldName -> fromMaybe "" (M.lookup fieldName commit)) names
+-- | Extract values of named fields from commit.
+onlyFields :: Commit -> [FieldName] -> [Maybe FieldValue]
+onlyFields commit names = map (flip M.lookup commit) names
------------------------------------------------------------------------------

0 comments on commit b5e822b

Please sign in to comment.