Navigation Menu

Skip to content

Commit

Permalink
Fix some arguments name of geo_in_rectangle.
Browse files Browse the repository at this point in the history
  • Loading branch information
komainu8 committed Apr 27, 2017
1 parent 36407ea commit ab7cee7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/groonga/client/request/select.rb
Expand Up @@ -95,8 +95,8 @@ def query(value)
#
# @example: Use geo_in_rectangle function
# request.
# filter.geo_in_rectangle("50x50", "0x100", "100x0")
# # -> --filter 'geo_in_rectangle("50x50", "0x100", "100x0")'
# filter.geo_in_rectangle(:location, "0x100", "100x0")
# # -> --filter 'geo_in_rectangle(location, "0x100", "100x0")'
#
# @example Use geo_in_circle function
# request.
Expand Down Expand Up @@ -231,27 +231,29 @@ def initialize(request)
#
# @example: Basic usage
# request.
# filter.geo_in_rectangle("50x50", "0x100", "100x0").
# # -> --filter 'in_values(50x50, 0x100, 100x0)'
# filter.geo_in_rectangle(:location, "0x100", "100x0").
# # -> --filter 'in_values(location, 0x100, 100x0)'
#
# @param point [String] The point to be checked.
# `"#{LONGITUDE}x#{LATITUDE}"` is the point format.
# @param column_name [Symbol] The column name to be checked.
#
# @param top_left [String] The top left of the condition rectangle.
# `"#{LONGITUDE}x#{LATITUDE}"` is the point format.
#
# @param bottom_right [String] The bottom right of the condition rectangle.
# `"#{LONGITUDE}x#{LATITUDE}"` is the point format.
#
# @return [Groonga::Client::Request::Select]
# The new request with the given condition.
#
# @since 0.5.0
def geo_in_rectangle(point, top_left, bottom_right)
expression = "geo_in_rectangle(%{point}"
def geo_in_rectangle(column_name_or_point,
top_left, bottom_right)
expression = "geo_in_rectangle(%{column_name_or_point}"
expression << ", %{top_left}"
expression << ", %{bottom_right}"
expression << ")"
@request.filter(expression,
point: point,
column_name_or_point: column_name_or_point,
top_left: top_left,
bottom_right: bottom_right)
end
Expand Down
8 changes: 8 additions & 0 deletions test/request/select/test-filter.rb
Expand Up @@ -207,6 +207,14 @@ def geo_in_rectangle(*args)
@request.filter.geo_in_rectangle(*args).to_parameters
end

test("column") do
assert_equal({
:table => "posts",
:filter => "geo_in_rectangle(location, \"0x100\", \"100x0\")",
},
geo_in_rectangle(:location, "0x100", "100x0"))
end

test("point") do
assert_equal({
:table => "posts",
Expand Down

0 comments on commit ab7cee7

Please sign in to comment.