Skip to content

Commit

Permalink
MB-7193: Make Spatial Views work that contain slashes
Browse files Browse the repository at this point in the history
Spatial Views that contained slashed in either the Design Document
or the function name didn't work.

Those three commits need to be merged at the same time:
http://review.couchbase.org/23138
http://review.couchbase.org/23175
http://review.couchbase.org/23139

Change-Id: I9142509f8fe9f2afab681f549a145856c065652d
Reviewed-on: http://review.couchbase.org/23175
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
  • Loading branch information
Volker Mische authored and fdmanana committed Dec 13, 2012
1 parent 849d544 commit 59ee7e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
21 changes: 10 additions & 11 deletions src/geocouch/couch_httpd_spatial_merger.erl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -134,17 +134,16 @@ validate_spatial_param(_) ->
"least 1 property.">>}). "least 1 property.">>}).


parse_spatial_name(Name) -> parse_spatial_name(Name) ->
case string:tokens(couch_util:trim(?b2l(Name)), "/") of Tokens = string:tokens(couch_util:trim(?b2l(Name)), "/"),
[DDocName, ViewName0] -> case [?l2b(couch_httpd:unquote(Token)) || Token <- Tokens] of
{nil, <<"_design/", (?l2b(DDocName))/binary>>, ?l2b(ViewName0)}; [DDocName, ViewName] ->
["_design", DDocName, ViewName0] -> {nil, <<"_design/", DDocName/binary>>, ViewName};
{nil, <<"_design/", (?l2b(DDocName))/binary>>, ?l2b(ViewName0)}; [<<"_design">>, DDocName, ViewName] ->
[DDocDbName1, DDocName, ViewName0] -> {nil, <<"_design/", DDocName/binary>>, ViewName};
DDocDbName = ?l2b(couch_httpd:unquote(DDocDbName1)), [DDocDbName, DDocName, ViewName] ->
{DDocDbName, <<"_design/", (?l2b(DDocName))/binary>>, ?l2b(ViewName0)}; {DDocDbName, <<"_design/", DDocName/binary>>, ViewName};
[DDocDbName1, "_design", DDocName, ViewName0] -> [DDocDbName, <<"_design">>, DDocName, ViewName] ->
DDocDbName = ?l2b(couch_httpd:unquote(DDocDbName1)), {DDocDbName, <<"_design/", DDocName/binary>>, ViewName};
{DDocDbName, <<"_design/", (?l2b(DDocName))/binary>>, ?l2b(ViewName0)};
_ -> _ ->
throw({bad_request, "A `spatial` property must have the shape" throw({bad_request, "A `spatial` property must have the shape"
" `ddoc_name/spatial_name`."}) " `ddoc_name/spatial_name`."})
Expand Down
4 changes: 2 additions & 2 deletions src/geocouch/couch_spatial_merger.erl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ http_index_folder_req_details(#simple_index_spec{} = Spec, MergeParams, _DDoc) -
} = MergeParams, } = MergeParams,
{ok, #httpdb{url = Url, lhttpc_options = Options}} = {ok, #httpdb{url = Url, lhttpc_options = Options}} =
couch_index_merger:open_db(DbUrl, nil, Timeout), couch_index_merger:open_db(DbUrl, nil, Timeout),
SpatialUrl = Url ++ ?b2l(DDocId) ++ "/_spatial/" ++ ?b2l(SpatialName) ++ SpatialUrl = Url ++ couch_httpd:quote(DDocId) ++ "/_spatial/" ++
spatial_qs(SpatialArgs), couch_httpd:quote(SpatialName) ++ spatial_qs(SpatialArgs),
put(from_url, DbUrl), put(from_url, DbUrl),
{SpatialUrl, get, [], [], Options}. {SpatialUrl, get, [], [], Options}.


Expand Down

0 comments on commit 59ee7e5

Please sign in to comment.