textacular 5.4.0 → 5.5.0

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
  SHA256:
3
- metadata.gz: d2f44e73cb226a66719aca4bdfb54732d7fc4bb2fe7af548b49aad5c81d97cfe
4
- data.tar.gz: 7d43ad7e191607aef9c521d5218afd98df5bc5cfa98d84cb8189db9026cc44de
3
+ metadata.gz: 974b8a8209d44a134f421db20f9ae6338c03057d8bcf26ce1e0c40778a29d6bf
4
+ data.tar.gz: 422c096f881919e53eaaab5f530e26e0e5aeffe33a4c8646bcb7f3b367dc9084
5
5
  SHA512:
6
- metadata.gz: 0f8ba724deeb6e82160fea018b012592fd0a407231b81467ba6c52e6f921e9792aeb6653a8adbcf5c6618a5559e434ffd717e13174e21dd04eca8c2fece472fb
7
- data.tar.gz: b84dfe00f5fd93a8735e3ce37847056fb82fa1ec583b59fa03cfbb411993fc33430e05ffe57986cded34c165261615edc3c524203da2a326d20fd0e3c9dcbc0a
6
+ metadata.gz: ab93dff1128025cc4615d29c819d104a9300bdbb0a88d9cc588940a1f630922a201b9f11449d610ba5cadc5ae85c2e761c0ad3ff5b8cb7a85f1fd3dd15acf744
7
+ data.tar.gz: 2102ea9936a087f18ed4945ddb4213e93acb70dc4bc8d3281489664fda2968b635e024636f0f2112f0fa8fc7a13b5d2b7e728aa200ac7663b681ae287b7e6b5d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 5.5.0
6
+
7
+ * ActiveRecord 7.0 compatibility
8
+
5
9
  ## 5.4.0
6
10
 
7
11
  * ActiveRecord 6.1 compatibility
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- git 'git://github.com/rails/rails.git', branch: 'master' do
5
+ git 'git://github.com/rails/rails.git', branch: 'main' do
6
6
  gem 'activerecord'
7
7
  end
8
8
 
data/README.md CHANGED
@@ -25,20 +25,18 @@ extending ActiveRecord with scopes making search easy and fun!
25
25
 
26
26
  ### Quick Start
27
27
 
28
- #### Rails 3, Rails 4
29
-
30
28
  In the project's Gemfile add
31
29
 
32
30
  ```ruby
33
- gem 'textacular', '~> 4.0'
31
+ gem 'textacular', '~> 5.0'
34
32
  ```
35
33
 
36
- #### Rails > 5.0
34
+ #### Rails 3, Rails 4
37
35
 
38
36
  In the project's Gemfile add
39
37
 
40
38
  ```ruby
41
- gem 'textacular', '~> 5.0'
39
+ gem 'textacular', '~> 4.0'
42
40
  ```
43
41
 
44
42
  #### ActiveRecord outside of Rails
@@ -164,29 +162,20 @@ migration add code like the following:
164
162
 
165
163
  #### For basic_search
166
164
  ```ruby
167
- execute "
168
- create index on email_logs using gin(to_tsvector('english', subject));
169
- create index on email_logs using gin(to_tsvector('english', email_address));"
165
+ add_index :email_logs, %{to_tsvector('english', subject)}, using: :gin
166
+ add_index :email_logs, %{to_tsvector('english', email_address)}, using: :gin
170
167
  ```
171
168
 
172
169
  #### For fuzzy_search
173
170
  ```ruby
174
- execute "
175
- CREATE INDEX trgm_subject_indx ON users USING gist (subject gist_trgm_ops);
176
- CREATE INDEX trgm_email_address_indx ON users USING gist (email_address gist_trgm_ops);
171
+ add_index :email_logs, :subject, using: :gist, opclass: :gist_trgm_ops
172
+ add_index :email_logs, :email_address, using: :gist, opclass: :gist_trgm_ops
177
173
  ```
178
174
 
179
175
  In the above example, the table email_logs has two text columns that we search against, subject and email_address.
180
176
  You will need to add an index for every text/string column you query against, or else Postgresql will revert to a
181
177
  full table scan instead of using the indexes.
182
178
 
183
- If you create these indexes, you should also switch to sql for your schema_format in `config/application.rb`:
184
-
185
- ```ruby
186
- config.active_record.schema_format = :sql
187
- ```
188
-
189
-
190
179
  ## REQUIREMENTS:
191
180
 
192
181
  * ActiveRecord
@@ -1,5 +1,5 @@
1
1
  module Textacular
2
- VERSION = '5.4.0'
2
+ VERSION = '5.5.0'
3
3
 
4
4
  def self.version
5
5
  VERSION
data/lib/textacular.rb CHANGED
@@ -124,7 +124,11 @@ module Textacular
124
124
  end
125
125
 
126
126
  def fuzzy_condition_string(table_name, column, search_term)
127
- "(#{table_name}.#{column}::text % #{search_term})"
127
+ # At this point, search_term is already quoted and query ready. Insert % between the quotes and the actual string.
128
+ search_term = search_term.gsub(/^(['"])/, '\1%')
129
+ search_term = search_term.gsub(/(['"])$/, '%\1')
130
+
131
+ "(#{table_name}.#{column}::text ILIKE #{search_term})"
128
132
  end
129
133
 
130
134
 
@@ -289,6 +289,12 @@ RSpec.describe Textacular do
289
289
  end
290
290
  end
291
291
  end
292
+
293
+ describe "#fuzzy_search" do
294
+ it "works if column contains multiple space delimited strings" do
295
+ expect(GameExtendedWithTextacular.fuzzy_search(title: 'mar')).to eq([mario])
296
+ end
297
+ end
292
298
  end
293
299
  end
294
300
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textacular
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0
4
+ version: 5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Hamill
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-12-31 00:00:00.000000000 Z
14
+ date: 2021-12-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: pg
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '5.0'
121
121
  - - "<"
122
122
  - !ruby/object:Gem::Version
123
- version: '6.2'
123
+ version: '7.1'
124
124
  type: :runtime
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ dependencies:
130
130
  version: '5.0'
131
131
  - - "<"
132
132
  - !ruby/object:Gem::Version
133
- version: '6.2'
133
+ version: '7.1'
134
134
  description: |-
135
135
  Textacular exposes full text search capabilities from PostgreSQL, extending
136
136
  ActiveRecord with scopes making search easy and fun!
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  requirements: []
197
- rubygems_version: 3.0.3
197
+ rubygems_version: 3.1.4
198
198
  signing_key:
199
199
  specification_version: 4
200
200
  summary: Textacular exposes full text search capabilities from PostgreSQL