scoped_search 4.1.9 → 4.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +76 -0
- data/.travis.yml +33 -0
- data/CHANGELOG.rdoc +10 -1
- data/Gemfile.activerecord61 +17 -0
- data/Gemfile.activerecord61_with_activesupport61 +18 -0
- data/lib/scoped_search/definition.rb +18 -10
- data/lib/scoped_search/query_builder.rb +16 -7
- data/lib/scoped_search/version.rb +1 -1
- data/lib/scoped_search.rb +2 -2
- data/spec/database.jruby.yml +1 -1
- data/spec/database.ruby.yml +1 -1
- data/spec/integration/ordinal_querying_spec.rb +6 -0
- data/spec/integration/rails_helper_spec.rb +12 -12
- data/spec/integration/set_query_spec.rb +6 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a3be22acffe6a33b115957197a5eca96b2e9cf2abe445b657b302663594abbe
|
4
|
+
data.tar.gz: a97d2cd9a8db87347dee308b1340e87967a887dd6b3c5c7b2124f7d9859a9843
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 840841fa78847d12b0f71ef620dbc73905e34a48325e10864ac56bf4aa746659d12f5cbbb18847c660e019bd42700700afb04928e7ccd48871bfe427ca8ba824
|
7
|
+
data.tar.gz: 11839160ebde29751173c28c718546d92a4378c316f081632f18eef2d688d569a4f1277caf14c40c4896f2168a7e4f42d0717af7482d430de13e9b04b3e77b9a
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on: [pull_request]
|
11
|
+
|
12
|
+
env:
|
13
|
+
TESTOPTS: --verbose
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
test:
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
ruby_version:
|
22
|
+
- 2.7.1
|
23
|
+
- 3.0.0
|
24
|
+
- ruby-head
|
25
|
+
- jruby-head
|
26
|
+
gemfile:
|
27
|
+
- Gemfile.activerecord52
|
28
|
+
- Gemfile.activerecord52_with_activesupport52
|
29
|
+
- Gemfile.activerecord60
|
30
|
+
- Gemfile.activerecord60_with_activesupport60
|
31
|
+
- Gemfile.activerecord61
|
32
|
+
- Gemfile.activerecord61_with_activesupport61
|
33
|
+
|
34
|
+
exclude:
|
35
|
+
- ruby_version: 2.7.1
|
36
|
+
gemfile: Gemfile.activerecord52
|
37
|
+
- ruby_version: 2.7.1
|
38
|
+
gemfile: Gemfile.activerecord52_with_activesupport52
|
39
|
+
- ruby_version: 3.0.0
|
40
|
+
gemfile: Gemfile.activerecord52
|
41
|
+
- ruby_version: 3.0.0
|
42
|
+
gemfile: Gemfile.activerecord52_with_activesupport52
|
43
|
+
- ruby_version: ruby-head
|
44
|
+
gemfile: Gemfile.activerecord52
|
45
|
+
- ruby_version: ruby-head
|
46
|
+
gemfile: Gemfile.activerecord52_with_activesupport52
|
47
|
+
services:
|
48
|
+
postgres:
|
49
|
+
image: postgres:12.1
|
50
|
+
ports: ['5432:5432']
|
51
|
+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
52
|
+
env:
|
53
|
+
POSTGRES_DB: scoped_search_test
|
54
|
+
mariadb:
|
55
|
+
image: mariadb:10
|
56
|
+
ports: ['3306:3306']
|
57
|
+
env:
|
58
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
|
59
|
+
MYSQL_DATABASE: scoped_search_test
|
60
|
+
|
61
|
+
env:
|
62
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
|
63
|
+
|
64
|
+
steps:
|
65
|
+
- uses: actions/checkout@v2
|
66
|
+
- name: Set up Ruby
|
67
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
68
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
69
|
+
uses: ruby/setup-ruby@v1
|
70
|
+
with:
|
71
|
+
ruby-version: ${{ matrix.ruby_version }}
|
72
|
+
bundler-cache: true
|
73
|
+
# - name: Install dependencies
|
74
|
+
# run: bundle install
|
75
|
+
- name: Run tests
|
76
|
+
run: bundle exec rake
|
data/.travis.yml
CHANGED
@@ -22,6 +22,7 @@ rvm:
|
|
22
22
|
- "2.5.1"
|
23
23
|
- "2.6.0"
|
24
24
|
- "2.7.1"
|
25
|
+
- "3.0.2"
|
25
26
|
- ruby-head
|
26
27
|
- jruby-19mode
|
27
28
|
- jruby-head
|
@@ -34,6 +35,8 @@ gemfile:
|
|
34
35
|
- Gemfile.activerecord52_with_activesupport52
|
35
36
|
- Gemfile.activerecord60
|
36
37
|
- Gemfile.activerecord60_with_activesupport60
|
38
|
+
- Gemfile.activerecord61
|
39
|
+
- Gemfile.activerecord61_with_activesupport61
|
37
40
|
|
38
41
|
matrix:
|
39
42
|
allow_failures:
|
@@ -77,6 +80,26 @@ matrix:
|
|
77
80
|
gemfile: Gemfile.activerecord60_with_activesupport60
|
78
81
|
- rvm: "2.4.0"
|
79
82
|
gemfile: Gemfile.activerecord60_with_activesupport60
|
83
|
+
- rvm: "2.0"
|
84
|
+
gemfile: Gemfile.activerecord61
|
85
|
+
- rvm: "2.1"
|
86
|
+
gemfile: Gemfile.activerecord61
|
87
|
+
- rvm: "2.2.2"
|
88
|
+
gemfile: Gemfile.activerecord61
|
89
|
+
- rvm: "2.3.7"
|
90
|
+
gemfile: Gemfile.activerecord61
|
91
|
+
- rvm: "2.4.0"
|
92
|
+
gemfile: Gemfile.activerecord61
|
93
|
+
- rvm: "2.0"
|
94
|
+
gemfile: Gemfile.activerecord61_with_activesupport61
|
95
|
+
- rvm: "2.1"
|
96
|
+
gemfile: Gemfile.activerecord61_with_activesupport61
|
97
|
+
- rvm: "2.2.2"
|
98
|
+
gemfile: Gemfile.activerecord61_with_activesupport61
|
99
|
+
- rvm: "2.3.7"
|
100
|
+
gemfile: Gemfile.activerecord61_with_activesupport61
|
101
|
+
- rvm: "2.4.0"
|
102
|
+
gemfile: Gemfile.activerecord61_with_activesupport61
|
80
103
|
- rvm: "2.7.1"
|
81
104
|
gemfile: Gemfile.activerecord42
|
82
105
|
- rvm: "2.7.1"
|
@@ -87,3 +110,13 @@ matrix:
|
|
87
110
|
gemfile: Gemfile.activerecord52
|
88
111
|
- rvm: "2.7.1"
|
89
112
|
gemfile: Gemfile.activerecord52_with_activesupport52
|
113
|
+
- rvm: "3.0.2"
|
114
|
+
gemfile: Gemfile.activerecord42
|
115
|
+
- rvm: "3.0.2"
|
116
|
+
gemfile: Gemfile.activerecord50
|
117
|
+
- rvm: "3.0.2"
|
118
|
+
gemfile: Gemfile.activerecord51
|
119
|
+
- rvm: "3.0.2"
|
120
|
+
gemfile: Gemfile.activerecord52
|
121
|
+
- rvm: "3.0.2"
|
122
|
+
gemfile: Gemfile.activerecord52_with_activesupport52
|
data/CHANGELOG.rdoc
CHANGED
@@ -6,7 +6,16 @@ Please add an entry to the "Unreleased changes" section in your pull requests.
|
|
6
6
|
|
7
7
|
=== Unreleased changes
|
8
8
|
|
9
|
-
|
9
|
+
=== Version 4.1.10
|
10
|
+
|
11
|
+
- Fix querying through associations in Rails 6.1 (undefined method join_keys) (#201)
|
12
|
+
- Fix query generation when going through STI associations (#211)
|
13
|
+
- Properly support Ruby 3
|
14
|
+
- Add support for postgres citext type
|
15
|
+
|
16
|
+
=== Version 4.1.9
|
17
|
+
- Fix querying on nested has-many associations (#196)
|
18
|
+
- Abide "has_many ..., primary_key" overrides in relation searches
|
10
19
|
|
11
20
|
=== Version 4.1.8
|
12
21
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
gemspec
|
3
|
+
|
4
|
+
gem 'actionview', '~> 6.1.0'
|
5
|
+
gem 'activerecord', '~> 6.1.0'
|
6
|
+
|
7
|
+
platforms :jruby do
|
8
|
+
gem 'activerecord-jdbcsqlite3-adapter'
|
9
|
+
gem 'activerecord-jdbcmysql-adapter'
|
10
|
+
gem 'activerecord-jdbcpostgresql-adapter'
|
11
|
+
end
|
12
|
+
|
13
|
+
platforms :ruby do
|
14
|
+
gem 'sqlite3', '~> 1.4'
|
15
|
+
gem 'mysql2', '> 0.5'
|
16
|
+
gem 'pg', '>= 0.18', '< 2.0'
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
gemspec
|
3
|
+
|
4
|
+
gem 'actionview', '~> 6.1.0'
|
5
|
+
gem 'activerecord', '~> 6.1.0'
|
6
|
+
gem 'activesupport', '~> 6.1.0'
|
7
|
+
|
8
|
+
platforms :jruby do
|
9
|
+
gem 'activerecord-jdbcsqlite3-adapter'
|
10
|
+
gem 'activerecord-jdbcmysql-adapter'
|
11
|
+
gem 'activerecord-jdbcpostgresql-adapter'
|
12
|
+
end
|
13
|
+
|
14
|
+
platforms :ruby do
|
15
|
+
gem 'sqlite3', '~> 1.4'
|
16
|
+
gem 'mysql2', '> 0.5'
|
17
|
+
gem 'pg', '>= 0.18', '< 2.0'
|
18
|
+
end
|
@@ -157,7 +157,7 @@ module ScopedSearch
|
|
157
157
|
|
158
158
|
# Returns true if this is a textual column.
|
159
159
|
def textual?
|
160
|
-
[:string, :text].include?(type)
|
160
|
+
[:string, :text, :citext].include?(type)
|
161
161
|
end
|
162
162
|
|
163
163
|
def uuid?
|
@@ -172,7 +172,7 @@ module ScopedSearch
|
|
172
172
|
# Returns the default search operator for this field.
|
173
173
|
def default_operator
|
174
174
|
@default_operator ||= case type
|
175
|
-
when :string, :text then :like
|
175
|
+
when :string, :text, :citext then :like
|
176
176
|
else :eq
|
177
177
|
end
|
178
178
|
end
|
@@ -266,7 +266,7 @@ module ScopedSearch
|
|
266
266
|
def default_fields_for(value, operator = nil)
|
267
267
|
|
268
268
|
column_types = [:virtual]
|
269
|
-
column_types += [:string, :text]
|
269
|
+
column_types += [:string, :text, :citext] if [nil, :like, :unlike, :ne, :eq].include?(operator)
|
270
270
|
column_types += [:double, :float, :decimal] if value =~ NUMERICAL_REGXP
|
271
271
|
column_types += [:integer] if value =~ INTEGER_REGXP
|
272
272
|
column_types += [:uuid] if value =~ UUID_REGXP
|
@@ -281,13 +281,13 @@ module ScopedSearch
|
|
281
281
|
# In case Time responds to #zone, we know this is Rails environment and we can use Time.zone.parse. The benefit is that the
|
282
282
|
# current timezone is respected and does not have to be specified explicitly. That way even relative dates work as expected.
|
283
283
|
def parse_temporal(value)
|
284
|
-
return Date.current if value =~ /\btoday\b/i
|
285
|
-
return 1.day.ago
|
286
|
-
return 1.day.from_now
|
284
|
+
return date_with_timezone(Date.current) if value =~ /\btoday\b/i
|
285
|
+
return date_with_timezone(1.day.ago) if value =~ /\byesterday\b/i
|
286
|
+
return date_with_timezone(1.day.from_now) if value =~ /\btomorrow\b/i
|
287
287
|
return (eval($1.strip.gsub(/\s+/,'.').downcase)).to_datetime if value =~ /\A\s*(\d+\s+\b(?:hours?|minutes?)\b\s+\bago)\b\s*\z/i
|
288
|
-
return (eval($1.strip.gsub(/\s+/,'.').downcase))
|
288
|
+
return date_with_timezone(eval($1.strip.gsub(/\s+/,'.').downcase)) if value =~ /\A\s*(\d+\s+\b(?:days?|weeks?|months?|years?)\b\s+\bago)\b\s*\z/i
|
289
289
|
return (eval($1.strip.gsub(/from\s+now/i,'from_now').gsub(/\s+/,'.').downcase)).to_datetime if value =~ /\A\s*(\d+\s+\b(?:hours?|minutes?)\b\s+\bfrom\s+now)\b\s*\z/i
|
290
|
-
return (eval($1.strip.gsub(/from\s+now/i,'from_now').gsub(/\s+/,'.').downcase))
|
290
|
+
return date_with_timezone(eval($1.strip.gsub(/from\s+now/i,'from_now').gsub(/\s+/,'.').downcase)) if value =~ /\A\s*(\d+\s+\b(?:days?|weeks?|months?|years?)\b\s+\bfrom\s+now)\b\s*\z/i
|
291
291
|
if Time.respond_to?(:zone) && !Time.zone.nil?
|
292
292
|
parsed = Time.zone.parse(value) rescue nil
|
293
293
|
parsed && parsed.to_datetime
|
@@ -305,8 +305,8 @@ module ScopedSearch
|
|
305
305
|
end
|
306
306
|
|
307
307
|
# Defines a new search field for this search definition.
|
308
|
-
def define(*args)
|
309
|
-
Field.new(self, *args)
|
308
|
+
def define(*args, **kwargs)
|
309
|
+
Field.new(self, *args, **kwargs)
|
310
310
|
end
|
311
311
|
|
312
312
|
# Returns a reflection for a given klass and name
|
@@ -334,6 +334,14 @@ module ScopedSearch
|
|
334
334
|
|
335
335
|
search_scope
|
336
336
|
end
|
337
|
+
|
338
|
+
# This should get called only when the relative specifiers (1 day ago and
|
339
|
+
# so on), this code path is only viable when Rails are available
|
340
|
+
def date_with_timezone(datetime)
|
341
|
+
date = datetime.to_date
|
342
|
+
return datetime unless date.respond_to?(:in_time_zone)
|
343
|
+
date.in_time_zone.to_datetime
|
344
|
+
end
|
337
345
|
end
|
338
346
|
|
339
347
|
# Registers the complete_for method within the class that is used for searching.
|
@@ -38,7 +38,9 @@ module ScopedSearch
|
|
38
38
|
|
39
39
|
# Initializes the instance by setting the relevant parameters
|
40
40
|
def initialize(definition, ast, profile)
|
41
|
-
@definition
|
41
|
+
@definition = definition
|
42
|
+
@ast = ast
|
43
|
+
@definition.profile = profile
|
42
44
|
end
|
43
45
|
|
44
46
|
# Actually builds the find parameters hash that should be used in the search_for
|
@@ -287,15 +289,20 @@ module ScopedSearch
|
|
287
289
|
connection = many_class.connection
|
288
290
|
sql = connection.quote_table_name(many_class.table_name)
|
289
291
|
join_reflections = nested_has_many(many_class, field.relation)
|
290
|
-
table_names = [many_class.table_name] + join_reflections.map(&:table_name)
|
292
|
+
table_names = [[many_class.table_name, many_class.sti_name.tableize]] + join_reflections.map(&:table_name)
|
291
293
|
|
292
294
|
join_reflections.zip(table_names.zip(join_reflections.drop(1))).reduce(sql) do |acc, (reflection, (previous_table, next_reflection))|
|
293
|
-
|
294
|
-
|
295
|
-
|
295
|
+
fk1, pk1 = if reflection.respond_to?(:join_keys)
|
296
|
+
klass = reflection.method(:join_keys).arity == 1 ? [reflection.klass] : [] # ActiveRecord <5.2 workaround
|
297
|
+
reflection.join_keys(*klass).values # We are joining the tables "in reverse", so the PK and FK are swapped
|
298
|
+
else
|
299
|
+
[reflection.join_primary_key, reflection.join_foreign_key] #ActiveRecord 6.1
|
300
|
+
end
|
301
|
+
|
302
|
+
previous_table, sti_name = previous_table
|
296
303
|
# primary and foreign keys + optional conditions for the joins
|
297
304
|
join_condition = if with_polymorphism?(reflection)
|
298
|
-
field.reflection_conditions(definition.reflection_by_name(next_reflection.klass, previous_table))
|
305
|
+
field.reflection_conditions(definition.reflection_by_name(next_reflection.klass, sti_name || previous_table))
|
299
306
|
else
|
300
307
|
''
|
301
308
|
end
|
@@ -443,7 +450,9 @@ module ScopedSearch
|
|
443
450
|
field = definition.field_by_name(value)
|
444
451
|
if field && field.set? && field.complete_value.values.include?(true)
|
445
452
|
key = field.complete_value.map{|k,v| k if v == true}.compact.first
|
446
|
-
|
453
|
+
sql, *params = builder.set_test(field, :eq, key, &block)
|
454
|
+
params.each { |p| yield(:parameter, p) }
|
455
|
+
return sql
|
447
456
|
end
|
448
457
|
# Search keywords found without context, just search on all the default fields
|
449
458
|
fragments = definition.default_fields_for(value).map do |field|
|
data/lib/scoped_search.rb
CHANGED
@@ -34,9 +34,9 @@ module ScopedSearch
|
|
34
34
|
|
35
35
|
definitions.each do |definition|
|
36
36
|
if definition[:on].kind_of?(Array)
|
37
|
-
definition[:on].each { |field| self.scoped_search_definition.define(definition.merge(:on => field)) }
|
37
|
+
definition[:on].each { |field| self.scoped_search_definition.define(**definition.merge(:on => field)) }
|
38
38
|
else
|
39
|
-
self.scoped_search_definition.define(definition)
|
39
|
+
self.scoped_search_definition.define(**definition)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
return self.scoped_search_definition
|
data/spec/database.jruby.yml
CHANGED
data/spec/database.ruby.yml
CHANGED
@@ -210,6 +210,12 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
210
210
|
@class.search_for('timestamp > "3 hours ago"').length.should == 4
|
211
211
|
end
|
212
212
|
|
213
|
+
it "should take timezone into consideration" do
|
214
|
+
now = Time.now
|
215
|
+
expected = DateTime.new(now.year, now.month, now.day, 0, 0, 0, now.zone).utc.strftime('%Y-%m-%d %H:%M:%S')
|
216
|
+
@class.search_for('timestamp > yesterday').to_sql.should include(expected)
|
217
|
+
end
|
218
|
+
|
213
219
|
it "should accept 1 week from now as date format" do
|
214
220
|
@class.search_for('date < "1 week from now"').length.should == 6
|
215
221
|
end
|
@@ -9,54 +9,54 @@ describe ScopedSearch::RailsHelper do
|
|
9
9
|
let(:params) { HashWithIndifferentAccess.new(:controller => "resources", :action => "search") }
|
10
10
|
|
11
11
|
it "should generate a link with the order param set" do
|
12
|
-
should_receive(:url_for).with(
|
12
|
+
should_receive(:url_for).with({
|
13
13
|
"controller" => "resources",
|
14
14
|
"action" => "search",
|
15
15
|
"order" => "field ASC"
|
16
|
-
).and_return("/example")
|
16
|
+
}).and_return("/example")
|
17
17
|
|
18
18
|
sort("field")
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should generate a link with order param set to alternative default sorting order" do
|
22
|
-
should_receive(:url_for).with(
|
22
|
+
should_receive(:url_for).with({
|
23
23
|
"controller" => "resources",
|
24
24
|
"action" => "search",
|
25
25
|
"order" => "field DESC"
|
26
|
-
).and_return("/example")
|
26
|
+
}).and_return("/example")
|
27
27
|
|
28
28
|
sort("field", :default => "DESC")
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should generate a link with the order param inverted" do
|
32
|
-
should_receive(:url_for).with(
|
32
|
+
should_receive(:url_for).with({
|
33
33
|
"controller" => "resources",
|
34
34
|
"action" => "search",
|
35
35
|
"order" => "field DESC"
|
36
|
-
).and_return("/example")
|
36
|
+
}).and_return("/example")
|
37
37
|
|
38
38
|
params[:order] = "field ASC"
|
39
39
|
sort("field")
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should generate a link with other parameters retained" do
|
43
|
-
should_receive(:url_for).with(
|
43
|
+
should_receive(:url_for).with({
|
44
44
|
"controller" => "resources",
|
45
45
|
"action" => "search",
|
46
46
|
"walrus" => "unicorns",
|
47
47
|
"order" => "field ASC"
|
48
|
-
).and_return("/example")
|
48
|
+
}).and_return("/example")
|
49
49
|
|
50
50
|
params[:walrus] = "unicorns"
|
51
51
|
sort("field")
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should replace the current sorting order" do
|
55
|
-
should_receive(:url_for).with(
|
55
|
+
should_receive(:url_for).with({
|
56
56
|
"controller" => "resources",
|
57
57
|
"action" => "search",
|
58
58
|
"order" => "other ASC"
|
59
|
-
).and_return("/example")
|
59
|
+
}).and_return("/example")
|
60
60
|
|
61
61
|
params[:order] = "field ASC"
|
62
62
|
sort("other")
|
@@ -83,12 +83,12 @@ describe ScopedSearch::RailsHelper do
|
|
83
83
|
let(:ac_params) { double('ActionController::Parameters') }
|
84
84
|
|
85
85
|
it "should call to_h on passed params object" do
|
86
|
-
should_receive(:url_for).with(
|
86
|
+
should_receive(:url_for).with({
|
87
87
|
"controller" => "resources",
|
88
88
|
"action" => "search",
|
89
89
|
"walrus" => "unicorns",
|
90
90
|
"order" => "field ASC"
|
91
|
-
).and_return("/example")
|
91
|
+
}).and_return("/example")
|
92
92
|
|
93
93
|
params[:walrus] = "unicorns"
|
94
94
|
|
@@ -12,6 +12,7 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
12
12
|
@class = ScopedSearch::RSpec::Database.create_model(:bool => :boolean, :status => :integer) do |klass|
|
13
13
|
klass.scoped_search :on => :bool, :complete_value => {:yes => true, :no => false}
|
14
14
|
klass.scoped_search :on => :status, :complete_value => {:unknown => 0, :up => 1, :down => 2}
|
15
|
+
klass.scoped_search :on => :bool, :rename => :bool2, :complete_value => {:true => true, :false => false}
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
@@ -71,6 +72,11 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
71
72
|
it "should find two record with bool = false" do
|
72
73
|
@class.search_for('bool != yes').length.should == 2
|
73
74
|
end
|
75
|
+
|
76
|
+
it "should be able to search without value" do
|
77
|
+
@class.search_for('bool').length.should == 1
|
78
|
+
@class.search_for('bool2').length.should == 1
|
79
|
+
end
|
74
80
|
end
|
75
81
|
end
|
76
82
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scoped_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amos Benari
|
8
8
|
- Willem van Bergen
|
9
9
|
- Wes Hays
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-06-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -77,6 +77,7 @@ extra_rdoc_files:
|
|
77
77
|
- CONTRIBUTING.rdoc
|
78
78
|
- LICENSE
|
79
79
|
files:
|
80
|
+
- ".github/workflows/ruby.yml"
|
80
81
|
- ".gitignore"
|
81
82
|
- ".travis.yml"
|
82
83
|
- CHANGELOG.rdoc
|
@@ -89,6 +90,8 @@ files:
|
|
89
90
|
- Gemfile.activerecord52_with_activesupport52
|
90
91
|
- Gemfile.activerecord60
|
91
92
|
- Gemfile.activerecord60_with_activesupport60
|
93
|
+
- Gemfile.activerecord61
|
94
|
+
- Gemfile.activerecord61_with_activesupport61
|
92
95
|
- LICENSE
|
93
96
|
- README.rdoc
|
94
97
|
- Rakefile
|
@@ -141,7 +144,7 @@ homepage: https://github.com/wvanbergen/scoped_search/wiki
|
|
141
144
|
licenses:
|
142
145
|
- MIT
|
143
146
|
metadata: {}
|
144
|
-
post_install_message:
|
147
|
+
post_install_message:
|
145
148
|
rdoc_options:
|
146
149
|
- "--title"
|
147
150
|
- scoped_search
|
@@ -162,8 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
165
|
- !ruby/object:Gem::Version
|
163
166
|
version: '0'
|
164
167
|
requirements: []
|
165
|
-
rubygems_version: 3.
|
166
|
-
signing_key:
|
168
|
+
rubygems_version: 3.4.13
|
169
|
+
signing_key:
|
167
170
|
specification_version: 4
|
168
171
|
summary: Easily search you ActiveRecord models with a simple query language using
|
169
172
|
a named scope
|