scoped_search 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +7 -0
- data/lib/scoped_search/auto_complete_builder.rb +9 -3
- data/lib/scoped_search/definition.rb +1 -1
- data/lib/scoped_search/query_language/tokenizer.rb +1 -1
- data/lib/scoped_search/version.rb +1 -1
- data/spec/integration/auto_complete_spec.rb +20 -2
- data/spec/integration/uuid_query_spec.rb +2 -1
- metadata +4 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdc9b9ee45ee99807b1c22a0da4cef71c6ce539292213ee47c012c020f866368
|
4
|
+
data.tar.gz: 5b4b0acd6e86a3f3e3c940f537a854c193983ebf57019687eac6bf5b33728b42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 395e4bf94443d76d67c642fe27f92eaf14b2d240b23c5f784e412cfec811cb1900041ea04388ea4c086a2184cb1c771c6f1f4bf6a1ede7a8065920c2fbb7ab41
|
7
|
+
data.tar.gz: 3662b759dde0bb5c9584de7e9fc2cfdf22ae2244c6889f1c88b343950ad5ff0b8ad51b2b07505e05d0eb59a51efbb887ef6dabd80343fbceb99859528f8c6cb0
|
data/CHANGELOG.rdoc
CHANGED
@@ -6,6 +6,13 @@ Please add an entry to the "Unreleased changes" section in your pull requests.
|
|
6
6
|
|
7
7
|
=== Unreleased changes
|
8
8
|
|
9
|
+
=== Version 4.3.0
|
10
|
+
|
11
|
+
- Prevent scoped_search from modifying an empty string on newer rubies (#229)
|
12
|
+
- Autocomplete now wraps all strings in quotes, not just those containing whitespace (#230)
|
13
|
+
- UUID search is now case insensitive (#232)
|
14
|
+
- Autocomplete now honors scopes set on associations (#231)
|
15
|
+
|
9
16
|
=== Version 4.1.10
|
10
17
|
|
11
18
|
- Fix querying through associations in Rails 6.1 (undefined method join_keys) (#201)
|
@@ -215,12 +215,18 @@ module ScopedSearch
|
|
215
215
|
.distinct
|
216
216
|
.map(&field.field)
|
217
217
|
.compact
|
218
|
-
.map { |v| v.
|
218
|
+
.map { |v| v.is_a?(String) ? "\"#{v.gsub('"', '\"')}\"" : v }
|
219
219
|
end
|
220
220
|
|
221
221
|
def completer_scope(field)
|
222
|
-
|
223
|
-
scope =
|
222
|
+
scope = field.klass
|
223
|
+
scope = scope.completer_scope(@options) if scope.respond_to?(:completer_scope)
|
224
|
+
|
225
|
+
if field.klass != field.definition.klass
|
226
|
+
reflection = field.definition.reflection_by_name(field.definition.klass, field.relation)
|
227
|
+
scope = scope.instance_exec(&reflection.scope) if reflection.try(:has_scope?)
|
228
|
+
end
|
229
|
+
|
224
230
|
scope.respond_to?(:reorder) ? scope.reorder(Arel.sql(field.quoted_field)) : scope.scoped(:order => field.quoted_field)
|
225
231
|
end
|
226
232
|
|
@@ -260,7 +260,7 @@ module ScopedSearch
|
|
260
260
|
|
261
261
|
NUMERICAL_REGXP = /^\-?\d+(\.\d+)?$/
|
262
262
|
INTEGER_REGXP = /^\-?\d+$/
|
263
|
-
UUID_REGXP = /^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/
|
263
|
+
UUID_REGXP = /^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i
|
264
264
|
|
265
265
|
# Returns a list of appropriate fields to search in given a search keyword and operator.
|
266
266
|
def default_fields_for(value, operator = nil)
|
@@ -69,7 +69,7 @@ module ScopedSearch::QueryLanguage::Tokenizer
|
|
69
69
|
# Tokenizes a keyword that is quoted using double quotes. Allows escaping
|
70
70
|
# of double quote characters by backslashes.
|
71
71
|
def tokenize_quoted_keyword(&block)
|
72
|
-
keyword =
|
72
|
+
keyword = String.new
|
73
73
|
until next_char.nil? || current_char == '"'
|
74
74
|
keyword << (current_char == "\\" ? next_char : current_char)
|
75
75
|
end
|
@@ -41,6 +41,10 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
ActiveRecord::Migration.create_table(:bazs, :force => true) do |t|
|
45
|
+
t.integer :foo_id
|
46
|
+
end
|
47
|
+
|
44
48
|
class ::Bar < ActiveRecord::Base
|
45
49
|
belongs_to :foo
|
46
50
|
end
|
@@ -65,6 +69,12 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
65
69
|
scoped_search :on => :other_c, :relation => :bars, :rename => 'bars.other_c'.to_sym
|
66
70
|
end
|
67
71
|
|
72
|
+
class ::Baz < ActiveRecord::Base
|
73
|
+
belongs_to :foo, -> { where(string: 'foo') }
|
74
|
+
|
75
|
+
scoped_search :on => :string, :relation => :foo, :complete_value => true
|
76
|
+
end
|
77
|
+
|
68
78
|
class ::Infoo < ::Foo
|
69
79
|
end
|
70
80
|
|
@@ -83,9 +93,11 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
83
93
|
after(:all) do
|
84
94
|
ActiveRecord::Migration.drop_table(:foos)
|
85
95
|
ActiveRecord::Migration.drop_table(:bars)
|
96
|
+
ActiveRecord::Migration.drop_table(:bazs)
|
86
97
|
|
87
98
|
Object.send :remove_const, :Foo
|
88
99
|
Object.send :remove_const, :Bar
|
100
|
+
Object.send :remove_const, :Baz
|
89
101
|
Object.send :remove_const, :Infoo
|
90
102
|
|
91
103
|
ScopedSearch::RSpec::Database.close_connection
|
@@ -169,10 +181,10 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
169
181
|
end
|
170
182
|
|
171
183
|
it "should complete values should contain baz" do
|
172
|
-
Foo.complete_for('explicit = ').should contain('explicit = baz')
|
184
|
+
Foo.complete_for('explicit = ').should contain('explicit = "baz"')
|
173
185
|
end
|
174
186
|
|
175
|
-
it "should complete values with quotes where
|
187
|
+
it "should complete values with quotes where value is a string" do
|
176
188
|
Foo.complete_for('alias = ').should contain('alias = "temp \"2\""')
|
177
189
|
end
|
178
190
|
end
|
@@ -267,5 +279,11 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
267
279
|
Foo.complete_for('int =', value_filter: { qux_id: 99 }).should == []
|
268
280
|
end
|
269
281
|
end
|
282
|
+
|
283
|
+
context 'autocompleting with scopes' do
|
284
|
+
it 'should honor the scope' do
|
285
|
+
::Baz.complete_for('string =').should == ['string = foo']
|
286
|
+
end
|
287
|
+
end
|
270
288
|
end
|
271
289
|
end
|
@@ -43,8 +43,9 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
43
43
|
@class.search_for("uuid != #{@record3.uuid}").length.should == 2
|
44
44
|
end
|
45
45
|
|
46
|
-
it "should find a record by just specifying the uuid" do
|
46
|
+
it "should find a record by just specifying the uuid (case insensitive)" do
|
47
47
|
@class.search_for(@record1.uuid).first.uuid.should == @record1.uuid
|
48
|
+
@class.search_for(@record1.uuid.upcase).first.uuid.should == @record1.uuid
|
48
49
|
end
|
49
50
|
|
50
51
|
it "should not find a record if the uuid is not a valid uuid" do
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scoped_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amos Benari
|
8
8
|
- Willem van Bergen
|
9
9
|
- Wes Hays
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 1980-01-01 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: activerecord
|
@@ -142,10 +141,10 @@ email:
|
|
142
141
|
executables: []
|
143
142
|
extensions: []
|
144
143
|
extra_rdoc_files:
|
145
|
-
- README.rdoc
|
146
144
|
- CHANGELOG.rdoc
|
147
145
|
- CONTRIBUTING.rdoc
|
148
146
|
- LICENSE
|
147
|
+
- README.rdoc
|
149
148
|
files:
|
150
149
|
- ".github/workflows/ruby.yml"
|
151
150
|
- ".gitignore"
|
@@ -214,7 +213,6 @@ homepage: https://github.com/wvanbergen/scoped_search/wiki
|
|
214
213
|
licenses:
|
215
214
|
- MIT
|
216
215
|
metadata: {}
|
217
|
-
post_install_message:
|
218
216
|
rdoc_options:
|
219
217
|
- "--title"
|
220
218
|
- scoped_search
|
@@ -235,8 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
233
|
- !ruby/object:Gem::Version
|
236
234
|
version: '0'
|
237
235
|
requirements: []
|
238
|
-
rubygems_version: 3.
|
239
|
-
signing_key:
|
236
|
+
rubygems_version: 3.6.9
|
240
237
|
specification_version: 4
|
241
238
|
summary: Easily search you ActiveRecord models with a simple query language using
|
242
239
|
a named scope
|