scoped_search 4.1.3 → 4.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8e71c1616716946f906c72f741b5e9b1950fdd8
4
- data.tar.gz: d9386d5cc2fca4d418bc9a3d7a96d5b18601659b
3
+ metadata.gz: cf2c98d3eed66905e04497673572661d98ca832a
4
+ data.tar.gz: 5cda23768c0ffef857dc038d74abd2539bf8881c
5
5
  SHA512:
6
- metadata.gz: cc2400a7f26ef7f1bfed7273094a7cac04c5cb09b35509a4d2e3464b543f9f1413214c9100117d0d356620b9df8ed47fd504a0d5a208ec087ec5742f0d9c3afe
7
- data.tar.gz: 3715276e0f495f13f1fd9158d6f4032c0a949682843e235e4b4dea8c035c33ad52de21427d894e1e4109f732299b5d5c8336e7cf9a6f20c70eeb2b29790ba580
6
+ metadata.gz: 96425ef732825dfb333d977f55a55be95ef3ac9dfda0ba9c4353fc97227d5caebfc4977b8cbdb786eb5929db84885f74435b7ca8795e449dcd2f7b432b0abbf5
7
+ data.tar.gz: '068d65cd7fe9e1d4e58b0080d92a22a9216ed879e17275aec5bce2651ce6cced96251803f062113c6ab66135a3ae90e478cf7b90bd2ea7b0437f5f83a96516ce'
@@ -8,6 +8,11 @@ Please add an entry to the "Unreleased changes" section in your pull requests.
8
8
 
9
9
  *Nothing yet*
10
10
 
11
+ === Version 4.1.4
12
+
13
+ - Bugfix related to LIKE queries on virtual fields (#178)
14
+ - Add an "onClear" option to scopedSearch (#176)
15
+
11
16
  === Version 4.1.3
12
17
 
13
18
  - Bugfix related to default fields for sets when using ext_method (#174)
@@ -25,6 +25,7 @@ $.widget( "custom.catcomplete", $.ui.autocomplete, {
25
25
  var options = arguments[0] || {};
26
26
  $(this).each(function(i,el){
27
27
  var target = $(el);
28
+ var clearFn = options.onClear || function(){ target.val(''); };
28
29
 
29
30
  target.catcomplete({
30
31
  source: options.source || function( request, response ) {
@@ -50,6 +51,6 @@ $.widget( "custom.catcomplete", $.ui.autocomplete, {
50
51
  $(this).catcomplete( target.attr('id'));
51
52
  });
52
53
  target.after('<a class="autocomplete-clear" tabindex="-1" title="Clear">&times;</a>')
53
- target.next().on("click",function(){ target.val(''); })
54
+ target.next().on("click", clearFn)
54
55
  })
55
- };
56
+ };
@@ -113,7 +113,7 @@ module ScopedSearch
113
113
  # By default, it will simply look up the correct SQL operator in the SQL_OPERATORS
114
114
  # hash, but this can be overridden by a database adapter.
115
115
  def sql_operator(operator, field)
116
- raise ScopedSearch::QueryNotSupported, "the operator '#{operator}' is not supported for field type '#{field.type}'" if [:like, :unlike].include?(operator) and !field.textual?
116
+ raise ScopedSearch::QueryNotSupported, "the operator '#{operator}' is not supported for field type '#{field.type}'" if !field.ext_method and [:like, :unlike].include?(operator) and !field.textual?
117
117
  SQL_OPERATORS[operator]
118
118
  end
119
119
 
@@ -554,7 +554,7 @@ module ScopedSearch
554
554
  # Switches out the default LIKE operator in the default <tt>sql_operator</tt>
555
555
  # method for ILIKE or @@ if full text searching is enabled.
556
556
  def sql_operator(operator, field)
557
- raise ScopedSearch::QueryNotSupported, "the operator '#{operator}' is not supported for field type '#{field.type}'" if [:like, :unlike].include?(operator) and !field.textual?
557
+ raise ScopedSearch::QueryNotSupported, "the operator '#{operator}' is not supported for field type '#{field.type}'" if !field.ext_method and [:like, :unlike].include?(operator) and !field.textual?
558
558
  return '@@' if [:like, :unlike].include?(operator) && field.full_text_search
559
559
  case operator
560
560
  when :like then 'ILIKE'
@@ -1,3 +1,3 @@
1
1
  module ScopedSearch
2
- VERSION = "4.1.3"
2
+ VERSION = "4.1.4"
3
3
  end
@@ -90,6 +90,11 @@ describe ScopedSearch::QueryBuilder do
90
90
  ScopedSearch::QueryBuilder.build_query(@definition, 'test_field = test_val').should eq(include: ['test1'], joins: ['test2'])
91
91
  end
92
92
 
93
+ it "should support LIKE query even if database field doesn't exist" do
94
+ klass.should_receive(:ext_test).with('test_field', 'LIKE', 'test_val').and_return(conditions: 'field LIKE ?', parameter: ['%test_val%'])
95
+ ScopedSearch::QueryBuilder.build_query(@definition, 'test_field ~ test_val').should eq(conditions: ['(field LIKE ?)', '%test_val%'])
96
+ end
97
+
93
98
  it "should raise error when non-hash returned" do
94
99
  klass.should_receive(:ext_test).and_return('test')
95
100
  lambda { ScopedSearch::QueryBuilder.build_query(@definition, 'test_field = test_val') }.should raise_error(ScopedSearch::QueryNotSupported, /should return hash/)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scoped_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.3
4
+ version: 4.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amos Benari
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-03-08 00:00:00.000000000 Z
13
+ date: 2018-09-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord