[ARVADOS] updated: 4982008e820ed48f362226c61540c18305c6acd6
git at public.curoverse.com
git at public.curoverse.com
Mon Feb 9 12:13:33 EST 2015
Summary of changes:
services/api/lib/record_filters.rb | 16 +++++----
.../api/test/functional/arvados/v1/filters_test.rb | 41 ++++++++++++++++++++++
2 files changed, 50 insertions(+), 7 deletions(-)
via 4982008e820ed48f362226c61540c18305c6acd6 (commit)
via 77daa60985c94cf4137c8a54681bb89278db8436 (commit)
via bd720586c0152ca4e7d109389bda2c0e463c76bb (commit)
from cda964acdb8132d90b881e62db008c574fdd5cc4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 4982008e820ed48f362226c61540c18305c6acd6
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Feb 9 12:10:29 2015 -0500
4523: Add tests for some edge cases.
diff --git a/services/api/test/functional/arvados/v1/filters_test.rb b/services/api/test/functional/arvados/v1/filters_test.rb
index 2e8e231..fda857c 100644
--- a/services/api/test/functional/arvados/v1/filters_test.rb
+++ b/services/api/test/functional/arvados/v1/filters_test.rb
@@ -13,4 +13,45 @@ class Arvados::V1::FiltersTest < ActionController::TestCase
assert_includes(found.collect(&:group_class), nil,
"'group_class not in ['project']' filter should pass null")
end
+
+ test 'error message for non-array element in filters array' do
+ @controller = Arvados::V1::CollectionsController.new
+ authorize_with :active
+ get :index, {
+ filters: [{bogus: 'filter'}],
+ }
+ assert_response 422
+ assert_match(/Invalid element in filters array/,
+ json_response['errors'].join(' '))
+ end
+
+ test 'error message for full text search on a specific column' do
+ @controller = Arvados::V1::CollectionsController.new
+ authorize_with :active
+ get :index, {
+ filters: [['uuid', '@@', 'abcdef']],
+ }
+ assert_response 422
+ assert_match /not supported/, json_response['errors'].join(' ')
+ end
+
+ test 'difficult characters in full text search' do
+ @controller = Arvados::V1::CollectionsController.new
+ authorize_with :active
+ get :index, {
+ filters: [['any', '@@', 'a|b"c']],
+ }
+ assert_response :success
+ # (Doesn't matter so much which results are returned.)
+ end
+
+ test 'array operand in full text search' do
+ @controller = Arvados::V1::CollectionsController.new
+ authorize_with :active
+ get :index, {
+ filters: [['any', '@@', ['abc', 'def']]],
+ }
+ assert_response :success
+ # (Doesn't matter so much which results are returned.)
+ end
end
commit 77daa60985c94cf4137c8a54681bb89278db8436
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Feb 9 12:05:16 2015 -0500
4523: Fix up whitespace.
diff --git a/services/api/lib/record_filters.rb b/services/api/lib/record_filters.rb
index 1e6be5f..3786a70 100644
--- a/services/api/lib/record_filters.rb
+++ b/services/api/lib/record_filters.rb
@@ -42,9 +42,11 @@ module RecordFilters
if attrs_in != 'any'
raise ArgumentError.new("Full text search on individual columns is not supported")
end
- attrs = [] # skip the generic per-column operator loop below
- # Use to_tsquery since plainto_tsquery does not support prefix search.
- # Instead split operand, add ':*' to each word and join the words with ' & '
+ # Skip the generic per-column operator loop below
+ attrs = []
+ # Use to_tsquery since plainto_tsquery does not support prefix
+ # search. Instead split operand, add ':*' to each word and
+ # join the words with ' & '
cond_out << model_class.full_text_tsvector+" @@ to_tsquery(?)"
param_out << operand.split.each {|s| s.concat(':*')}.join(' & ')
end
commit bd720586c0152ca4e7d109389bda2c0e463c76bb
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Feb 9 10:42:22 2015 -0500
4523: Remove unneeded else.
diff --git a/services/api/lib/record_filters.rb b/services/api/lib/record_filters.rb
index 0b65108..1e6be5f 100644
--- a/services/api/lib/record_filters.rb
+++ b/services/api/lib/record_filters.rb
@@ -37,7 +37,8 @@ module RecordFilters
cond_out = []
- if operator == '@@' # full-text-search
+ if operator == '@@'
+ # Full-text search
if attrs_in != 'any'
raise ArgumentError.new("Full text search on individual columns is not supported")
end
@@ -46,8 +47,8 @@ module RecordFilters
# Instead split operand, add ':*' to each word and join the words with ' & '
cond_out << model_class.full_text_tsvector+" @@ to_tsquery(?)"
param_out << operand.split.each {|s| s.concat(':*')}.join(' & ')
- else
- attrs.each do |attr|
+ end
+ attrs.each do |attr|
if !model_class.searchable_columns(operator).index attr.to_s
raise ArgumentError.new("Invalid attribute '#{attr}' in filter")
end
@@ -116,7 +117,6 @@ module RecordFilters
end
cond_out << cond.join(' OR ')
end
- end
end
conds_out << cond_out.join(' OR ') if cond_out.any?
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list