pg_search 1.0.0 → 1.0.1
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.md +4 -0
- data/lib/pg_search/scope_options.rb +1 -1
- data/lib/pg_search/version.rb +1 -1
- data/spec/integration/pg_search_spec.rb +62 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0dac0584f13909a05901de21df0de7ccee6312b
|
4
|
+
data.tar.gz: 5eafba8855a040b9bfea3ea7df2a6e9fadb7bb02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ff3d3978df858242d44590e1dfde3107c943e4496ce251b2d71663beb800b922a742d5c2dea65f017946630d34b63eef2c29b206514ce2debfabdb2a969d922
|
7
|
+
data.tar.gz: ebaea869e71b1c2239aaa8cb1d613623e6a41ce14628fc5afa96f210a0ee52dca39151ae0b156aca9fc6fe81cfc5dd9b75de561bd8d675bdbce01bae8463c8eb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# pg_search changelog
|
2
2
|
|
3
|
+
## 1.0.1
|
4
|
+
|
5
|
+
* Call `.unscoped` on relation used to build subquery, to eliminate unnecessary JOINs. (Markus Doits)
|
6
|
+
|
3
7
|
## 1.0.0
|
4
8
|
|
5
9
|
* Support more `ActiveRecord::Relation` methods, such as `#pluck` and `#select` by moving search-related operations to subquery.
|
data/lib/pg_search/version.rb
CHANGED
@@ -186,6 +186,68 @@ describe "an Active Record model which includes PgSearch" do
|
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
189
|
+
context "chained to a cross-table scope" do
|
190
|
+
with_model :House do
|
191
|
+
table do |t|
|
192
|
+
t.references :person
|
193
|
+
t.string :city
|
194
|
+
end
|
195
|
+
|
196
|
+
model do
|
197
|
+
belongs_to :person
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
with_model :Person do
|
202
|
+
table do |t|
|
203
|
+
t.string :name
|
204
|
+
end
|
205
|
+
|
206
|
+
model do
|
207
|
+
include PgSearch
|
208
|
+
has_many :houses
|
209
|
+
pg_search_scope :named, against: [:name]
|
210
|
+
scope :with_house_in_city, ->(city) {
|
211
|
+
joins(:houses).where(House.table_name.to_sym => {city: city})
|
212
|
+
}
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
it "works when the other scope is last" do
|
217
|
+
house_in_duluth = House.create!(city: "Duluth")
|
218
|
+
second_house_in_duluth = House.create!(city: "Duluth")
|
219
|
+
house_in_sheboygan = House.create!(city: "Sheboygan")
|
220
|
+
|
221
|
+
bob_in_duluth =
|
222
|
+
Person.create!(name: "Bob", houses: [house_in_duluth])
|
223
|
+
bob_in_sheboygan =
|
224
|
+
Person.create!(name: "Bob", houses: [house_in_sheboygan])
|
225
|
+
sally_in_duluth =
|
226
|
+
Person.create!(name: "Sally", houses: [second_house_in_duluth])
|
227
|
+
|
228
|
+
results = Person.named("bob").with_house_in_city("Duluth")
|
229
|
+
expect(results).to include bob_in_duluth
|
230
|
+
expect(results).not_to include [bob_in_sheboygan, sally_in_duluth]
|
231
|
+
end
|
232
|
+
|
233
|
+
it "works when the other scope is first" do
|
234
|
+
house_in_duluth = House.create!(city: "Duluth")
|
235
|
+
second_house_in_duluth = House.create!(city: "Duluth")
|
236
|
+
house_in_sheboygan = House.create!(city: "Sheboygan")
|
237
|
+
|
238
|
+
bob_in_duluth =
|
239
|
+
Person.create!(name: "Bob", houses: [house_in_duluth])
|
240
|
+
bob_in_sheboygan =
|
241
|
+
Person.create!(name: "Bob", houses: [house_in_sheboygan])
|
242
|
+
sally_in_duluth =
|
243
|
+
Person.create!(name: "Sally", houses: [second_house_in_duluth])
|
244
|
+
|
245
|
+
results = Person.with_house_in_city("Duluth").named("Bob")
|
246
|
+
expect(results).to include bob_in_duluth
|
247
|
+
expect(results).not_to include [bob_in_sheboygan, sally_in_duluth]
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
189
251
|
it "returns an empty array when a blank query is passed in" do
|
190
252
|
ModelWithPgSearch.create!(:content => 'foo')
|
191
253
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grant Hutchins
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|