Skip to content
Browse files

MB-6205: Make "updater_after" the default "stale" value

From now on the default value for "stale" is "updater_after". If
you want the old behaviour, query with "stale=false".

Change-Id: Ib20099647414a879acc20e5767730ecdb2746875
Reviewed-on: http://review.couchbase.org/19561
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
  • Loading branch information...
1 parent b89b029 commit 7782df1a53104e9c8bb9ef941a9b499bbc7cd61e @vmx vmx committed with vmx Aug 13, 2012
Showing with 16 additions and 10 deletions.
  1. +15 −9 src/geocouch/couch_httpd_spatial.erl
  2. +1 −1 src/geocouch/couch_spatial.hrl
View
24 src/geocouch/couch_httpd_spatial.erl
@@ -230,13 +230,19 @@ parse_spatial_params(Req) ->
parse_spatial_param("bbox", Bbox) ->
[{bbox, list_to_tuple(?JSON_DECODE("[" ++ Bbox ++ "]"))}];
-parse_spatial_param("stale", "ok") ->
- [{stale, ok}];
-parse_spatial_param("stale", "update_after") ->
- [{stale, update_after}];
-parse_spatial_param("stale", _Value) ->
- throw({query_parse_error,
- <<"stale only available as stale=ok or as stale=update_after">>});
+parse_spatial_param("stale", Value) ->
+ case string:to_lower(Value) of
+ "false" ->
+ [{stale, false}];
+ "ok" ->
+ [{stale, ok}];
+ "update_after" ->
+ [{stale, update_after}];
+ _ ->
+ throw({query_parse_error,
+ <<"stale only available as stale=ok, stale=update_after or "
+ "stale=false">>})
+ end;
parse_spatial_param("count", "true") ->
[{count, true}];
parse_spatial_param("count", _Value) ->
@@ -252,12 +258,12 @@ parse_spatial_param(Key, Value) ->
validate_spatial_query(bbox, Value, Args) ->
Args#spatial_query_args{bbox=Value};
+validate_spatial_query(stale, false, Args) ->
+ Args#spatial_query_args{stale=false};
validate_spatial_query(stale, ok, Args) ->
Args#spatial_query_args{stale=ok};
validate_spatial_query(stale, update_after, Args) ->
Args#spatial_query_args{stale=update_after};
-validate_spatial_query(stale, _, Args) ->
- Args;
validate_spatial_query(count, true, Args) ->
Args#spatial_query_args{count=true};
validate_spatial_query(bounds, Value, Args) ->
View
2 src/geocouch/couch_spatial.hrl
@@ -63,7 +63,7 @@
% #view_query_args
-record(spatial_query_args, {
bbox=nil,
- stale=nil,
+ stale=update_after :: update_after | ok | false,
count=false,
% Bounds of the cartesian plane
bounds=nil,

0 comments on commit 7782df1

Please sign in to comment.
Something went wrong with that request. Please try again.