eiri commented on a change in pull request #1085: Return update_seq and offset 
when update_seq is true and keys is set
URL: https://github.com/apache/couchdb/pull/1085#discussion_r161753349
 
 

 ##########
 File path: src/fabric/src/fabric_view_all_docs.erl
 ##########
 @@ -97,7 +98,14 @@ go(DbName, Options, QueryArgs, Callback, Acc0) ->
     end,
     case Resp of
         {ok, TotalRows} ->
-            {ok, Acc1} = Callback({meta, [{total, TotalRows}]}, Acc0),
+            case UpdateSeq of
 
 Review comment:
   Two things:
   
   1. If we really want back compatibility we need `offset` in meta in both 
cases, this is how it was in CouchDB 1.x. Query attribute `update_seq` only 
controls show/hide of `update_seq` in meta, not both.
   
   2. You are exporting variable `Meta` from case here. This is bad erlang and 
compiler would warn you if we'd have `+warn_export_vars` turned on with 
something like
   ```bash
   ~/couchdb/src/fabric/src/fabric_view_all_docs.erl:108: Warning: variable 
'Meta' exported from 'case' (line 101)
   ```
   
   The idiomatic way to do this is to assign `Meta` the return value of `case`, 
i.e.
   ```erlang
   Meta = case UpdateSeq of
     false -> [{total, TotalRows}, {offset, null}];
     true -> [{total, TotalRows}, {offset, null}, {update_seq, null}]
   end.
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to