pg_search 0.7.6 → 0.7.7
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/.travis.yml +3 -1
- data/CHANGELOG.md +5 -1
- data/Guardfile +1 -1
- data/bin/guard +16 -0
- data/bin/rspec +16 -0
- data/lib/pg_search/compatibility.rb +8 -0
- data/lib/pg_search/features/tsearch.rb +11 -5
- data/lib/pg_search/migration/templates/create_pg_search_documents.rb.erb +1 -1
- data/lib/pg_search/version.rb +1 -1
- data/spec/integration/pg_search_spec.rb +5 -5
- data/spec/lib/pg_search/document_spec.rb +3 -3
- data/spec/lib/pg_search/multisearch_spec.rb +1 -1
- data/spec/lib/pg_search/normalizer_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 165dd9636ca6fe145f0c619c1223f9c5d120d8de
|
4
|
+
data.tar.gz: 2aec51ab9d72cf504dc8c8af979ca30c57f4a19a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e80100d386747b57fb18be03e4de9fe04561f58cc0a3dc687971542d41e9491d0daab9f278e19b6672c36d00cab5adfab8c66e45a97cc706c72848891dd512d7
|
7
|
+
data.tar.gz: 13b258daf15ced5f205560cda4a1b451d07544e1ca687090e98a996dace0aeedc61a71b7397fd9e43d18ee8b2084669583e047183cce6224d6f33123f97a1bbc
|
data/.travis.yml
CHANGED
@@ -3,13 +3,14 @@ language: ruby
|
|
3
3
|
rvm:
|
4
4
|
- 1.9.3
|
5
5
|
- 2.0.0
|
6
|
-
- 2.1.
|
6
|
+
- 2.1.2
|
7
7
|
- jruby-19mode
|
8
8
|
|
9
9
|
env:
|
10
10
|
- ACTIVE_RECORD_BRANCH="master"
|
11
11
|
- ACTIVE_RECORD_BRANCH="4-1-stable"
|
12
12
|
- ACTIVE_RECORD_BRANCH="4-0-stable"
|
13
|
+
- ACTIVE_RECORD_VERSION="~> 4.2.0.beta1"
|
13
14
|
- ACTIVE_RECORD_VERSION="~> 4.1.0"
|
14
15
|
- ACTIVE_RECORD_VERSION="~> 4.0.0"
|
15
16
|
- ACTIVE_RECORD_VERSION="~> 3.2.0"
|
@@ -21,6 +22,7 @@ matrix:
|
|
21
22
|
- env: ACTIVE_RECORD_BRANCH="master"
|
22
23
|
- env: ACTIVE_RECORD_BRANCH="4-1-stable"
|
23
24
|
- env: ACTIVE_RECORD_BRANCH="4-0-stable"
|
25
|
+
- env: ACTIVE_RECORD_VERSION="~> 4.2.0.beta1"
|
24
26
|
|
25
27
|
before_script:
|
26
28
|
- "psql -c 'create database pg_search_test;' -U postgres >/dev/null"
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# pg_search changelog
|
2
2
|
|
3
|
+
## 0.7.7
|
4
|
+
|
5
|
+
* Fix future compatibility with Active Record 4.2.
|
6
|
+
|
3
7
|
## 0.7.6
|
4
8
|
|
5
9
|
* Fix migration generator in Rails 3. (Andrew Marshall and Nora Lin)
|
6
|
-
* Add
|
10
|
+
* Add `:only` option for limiting search fields per feature. (Jonathan Greenberg)
|
7
11
|
|
8
12
|
## 0.7.5
|
9
13
|
|
data/Guardfile
CHANGED
data/bin/guard
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'guard' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('guard', 'guard')
|
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "pg_search/compatibility"
|
1
2
|
require "active_support/core_ext/module/delegation"
|
2
3
|
|
3
4
|
module PgSearch
|
@@ -27,17 +28,22 @@ module PgSearch
|
|
27
28
|
|
28
29
|
DISALLOWED_TSQUERY_CHARACTERS = /['?\\:]/
|
29
30
|
|
30
|
-
def tsquery_for_term(
|
31
|
-
sanitized_term =
|
31
|
+
def tsquery_for_term(unsanitized_term)
|
32
|
+
sanitized_term = unsanitized_term.gsub(DISALLOWED_TSQUERY_CHARACTERS, " ")
|
32
33
|
|
33
34
|
term_sql = Arel.sql(normalize(connection.quote(sanitized_term)))
|
34
35
|
|
35
36
|
# After this, the SQL expression evaluates to a string containing the term surrounded by single-quotes.
|
36
37
|
# If :prefix is true, then the term will also have :* appended to the end.
|
37
|
-
terms = [
|
38
|
+
terms = [
|
39
|
+
Compatibility.build_quoted("' "),
|
40
|
+
term_sql,
|
41
|
+
Compatibility.build_quoted(" '"),
|
42
|
+
(Compatibility.build_quoted(":*") if options[:prefix])
|
43
|
+
].compact
|
38
44
|
|
39
45
|
tsquery_sql = terms.inject do |memo, term|
|
40
|
-
Arel::Nodes::InfixOperation.new("||", memo, term)
|
46
|
+
Arel::Nodes::InfixOperation.new("||", memo, Compatibility.build_quoted(term))
|
41
47
|
end
|
42
48
|
|
43
49
|
Arel::Nodes::NamedFunction.new(
|
@@ -84,7 +90,7 @@ module PgSearch
|
|
84
90
|
end
|
85
91
|
|
86
92
|
def dictionary
|
87
|
-
options[:dictionary] || :simple
|
93
|
+
Compatibility.build_quoted(options[:dictionary] || :simple)
|
88
94
|
end
|
89
95
|
|
90
96
|
def arel_wrap(sql_string)
|
data/lib/pg_search/version.rb
CHANGED
@@ -256,7 +256,7 @@ describe "an Active Record model which includes PgSearch" do
|
|
256
256
|
context "when the column is not text" do
|
257
257
|
with_model :ModelWithTimestamps do
|
258
258
|
table do |t|
|
259
|
-
t.timestamps
|
259
|
+
t.timestamps null: false
|
260
260
|
end
|
261
261
|
|
262
262
|
model do
|
@@ -1012,7 +1012,7 @@ describe "an Active Record model which includes PgSearch" do
|
|
1012
1012
|
expect(PgSearch::Document).to receive(:search).with(query).and_return(relation)
|
1013
1013
|
end
|
1014
1014
|
|
1015
|
-
it {
|
1015
|
+
it { is_expected.to eq(relation) }
|
1016
1016
|
end
|
1017
1017
|
|
1018
1018
|
context "with PgSearch.multisearch_options set to a Hash" do
|
@@ -1031,7 +1031,7 @@ describe "an Active Record model which includes PgSearch" do
|
|
1031
1031
|
|
1032
1032
|
let!(:soundalike_record) { MultisearchableModel.create!(:title => 'foning') }
|
1033
1033
|
let(:query) { "Phoning" }
|
1034
|
-
it {
|
1034
|
+
it { is_expected.to include(soundalike_record) }
|
1035
1035
|
end
|
1036
1036
|
|
1037
1037
|
context "with PgSearch.multisearch_options set to a Proc" do
|
@@ -1064,12 +1064,12 @@ describe "an Active Record model which includes PgSearch" do
|
|
1064
1064
|
|
1065
1065
|
context "with soundalike true" do
|
1066
1066
|
let(:soundalike) { true }
|
1067
|
-
it {
|
1067
|
+
it { is_expected.to include(soundalike_record) }
|
1068
1068
|
end
|
1069
1069
|
|
1070
1070
|
context "with soundalike false" do
|
1071
1071
|
let(:soundalike) { false }
|
1072
|
-
it {
|
1072
|
+
it { is_expected.not_to include(soundalike_record) }
|
1073
1073
|
end
|
1074
1074
|
end
|
1075
1075
|
|
@@ -11,7 +11,7 @@ describe PgSearch::Document do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
it {
|
14
|
+
it { is_expected.to be_an(ActiveRecord::Base) }
|
15
15
|
|
16
16
|
describe "callbacks" do
|
17
17
|
describe "before_validation" do
|
@@ -34,7 +34,7 @@ describe PgSearch::Document do
|
|
34
34
|
|
35
35
|
describe '#content' do
|
36
36
|
subject { super().content }
|
37
|
-
it {
|
37
|
+
it { is_expected.to eq(text) }
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -48,7 +48,7 @@ describe PgSearch::Document do
|
|
48
48
|
|
49
49
|
describe '#content' do
|
50
50
|
subject { super().content }
|
51
|
-
it {
|
51
|
+
it { is_expected.to eq("1 2") }
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -7,7 +7,7 @@ describe PgSearch::Normalizer do
|
|
7
7
|
context "when passed an Arel node" do
|
8
8
|
it "wraps the expression in unaccent()" do
|
9
9
|
config = double("config", :ignore => [:accents], :postgresql_version => 90000)
|
10
|
-
node = Arel::Nodes::NamedFunction.new("foo", ["bar"])
|
10
|
+
node = Arel::Nodes::NamedFunction.new("foo", [PgSearch::Compatibility.build_quoted("bar")])
|
11
11
|
|
12
12
|
normalizer = PgSearch::Normalizer.new(config)
|
13
13
|
expect(normalizer.add_normalization(node)).to eq("unaccent(foo('bar'))")
|
@@ -16,7 +16,7 @@ describe PgSearch::Normalizer do
|
|
16
16
|
context "when a custom unaccent function is specified" do
|
17
17
|
it "wraps the expression in that function" do
|
18
18
|
allow(PgSearch).to receive(:unaccent_function).and_return("my_unaccent")
|
19
|
-
node = Arel::Nodes::NamedFunction.new("foo", ["bar"])
|
19
|
+
node = Arel::Nodes::NamedFunction.new("foo", [PgSearch::Compatibility.build_quoted("bar")])
|
20
20
|
|
21
21
|
config = double("config", :ignore => [:accents], :postgresql_version => 90000)
|
22
22
|
|
data/spec/spec_helper.rb
CHANGED
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: 0.7.
|
4
|
+
version: 0.7.7
|
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: 2014-
|
12
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -114,7 +114,9 @@ description: PgSearch builds Active Record named scopes that take advantage of P
|
|
114
114
|
email:
|
115
115
|
- gems@nertzy.com
|
116
116
|
- casecommons-dev@googlegroups.com
|
117
|
-
executables:
|
117
|
+
executables:
|
118
|
+
- guard
|
119
|
+
- rspec
|
118
120
|
extensions: []
|
119
121
|
extra_rdoc_files: []
|
120
122
|
files:
|
@@ -129,6 +131,8 @@ files:
|
|
129
131
|
- LICENSE
|
130
132
|
- README.md
|
131
133
|
- Rakefile
|
134
|
+
- bin/guard
|
135
|
+
- bin/rspec
|
132
136
|
- lib/pg_search.rb
|
133
137
|
- lib/pg_search/compatibility.rb
|
134
138
|
- lib/pg_search/configuration.rb
|