pg_search 2.3.8 → 2.4.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +0 -6
  3. data/.github/workflows/codeql.yml +0 -1
  4. data/.gitignore +0 -1
  5. data/.standard.yml +1 -1
  6. data/CHANGELOG.md +70 -65
  7. data/CONTRIBUTING.md +1 -1
  8. data/LICENSE +1 -1
  9. data/README.md +2 -2
  10. data/doc/plans/2026-09-05-arel-stack.md +43 -0
  11. data/doc/plans/2026-09-06-arel-remaining-expressions.md +48 -0
  12. data/lib/pg_search/configuration/association.rb +37 -23
  13. data/lib/pg_search/configuration/column.rb +17 -12
  14. data/lib/pg_search/configuration/foreign_column.rb +3 -5
  15. data/lib/pg_search/features/dmetaphone.rb +3 -7
  16. data/lib/pg_search/features/feature.rb +8 -4
  17. data/lib/pg_search/features/trigram.rb +6 -20
  18. data/lib/pg_search/features/tsearch.rb +30 -36
  19. data/lib/pg_search/features.rb +2 -0
  20. data/lib/pg_search/migration/generator.rb +1 -5
  21. data/lib/pg_search/multisearch/rebuilder.rb +69 -65
  22. data/lib/pg_search/normalizer.rb +37 -18
  23. data/lib/pg_search/scope_options.rb +28 -52
  24. data/lib/pg_search/version.rb +1 -1
  25. data/pg_search.gemspec +4 -4
  26. data/spec/integration/associations_spec.rb +121 -0
  27. data/spec/integration/pg_search_spec.rb +48 -0
  28. data/spec/lib/pg_search/configuration/association_spec.rb +32 -58
  29. data/spec/lib/pg_search/configuration/column_spec.rb +73 -15
  30. data/spec/lib/pg_search/configuration/foreign_column_spec.rb +52 -20
  31. data/spec/lib/pg_search/features/dmetaphone_spec.rb +2 -2
  32. data/spec/lib/pg_search/features/trigram_spec.rb +3 -3
  33. data/spec/lib/pg_search/features/tsearch_spec.rb +8 -8
  34. data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +219 -229
  35. data/spec/lib/pg_search/multisearch_spec.rb +16 -16
  36. data/spec/lib/pg_search/normalizer_spec.rb +64 -11
  37. data/spec/lib/pg_search_spec.rb +2 -21
  38. metadata +8 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19d829bcebb6f71fe198f833221ac95046c86fc8a464050ee018480e811c17cc
4
- data.tar.gz: 20e57c883dda915b997ef6dbfe15244f8662c3900ee847538a1d1be358a4bc81
3
+ metadata.gz: d337f465568b2cbd9bd1339db2800ebd9f8e36440c826128de97047221ff696a
4
+ data.tar.gz: 925270bc694ea367614dbf45988b88bd1e8fd33d8c9bee48e0a8cc286866a584
5
5
  SHA512:
6
- metadata.gz: abd3ce5a816507a6cfe608fedea53d6c7fa4b104d1e85ea3e1e87b074d33160002fded3d2595aac5edfd43a6b59bfdffaf1cbc7a9ffdeace30bf5d01ae81af25
7
- data.tar.gz: '092545c6d541290cb8f089718d472f98167be48bd20d1f6efb922d8fe5f38f175131b8d79f291c6c6b6465fc39cea2f824c1141fb3689e9ef9dddef9e85376cb'
6
+ metadata.gz: 652c592fe592367e820d0608f0e8d8108d8d4b734e09690d732d224414919b4f8aba80b54e100bc0d4c7e9c265c907ad7c425a4118070163981e2180bcf83723
7
+ data.tar.gz: c52bb869600f87bbecaa584eef713a3b34d55668d6e632277730209fc65999361a4d4d8f4e831ff4bfbb1d9d9d0a6f03127f6b5469ae7bca524b6d68d9e133f2
@@ -6,8 +6,6 @@ on:
6
6
  - master
7
7
  - github-actions
8
8
  pull_request:
9
- branches:
10
- - master
11
9
  schedule:
12
10
  - cron: "0 18 * * 6" # Saturdays at 12pm CST
13
11
  workflow_dispatch:
@@ -46,7 +44,6 @@ jobs:
46
44
  matrix:
47
45
  ruby-version: ["3.3", "3.4", "4.0"]
48
46
  active-record:
49
- - { label: "7.2", env: "ACTIVE_RECORD_VERSION=~> 7.2.0" }
50
47
  - { label: "8.0", env: "ACTIVE_RECORD_VERSION=~> 8.0.0" }
51
48
  - { label: "8.1", env: "ACTIVE_RECORD_VERSION=~> 8.1.0" }
52
49
  allow-failure: [false]
@@ -60,9 +57,6 @@ jobs:
60
57
  - ruby-version: "4.0"
61
58
  active-record: { label: "8-0-stable", env: "ACTIVE_RECORD_BRANCH=8-0-stable" }
62
59
  allow-failure: true
63
- - ruby-version: "4.0"
64
- active-record: { label: "7-2-stable", env: "ACTIVE_RECORD_BRANCH=7-2-stable" }
65
- allow-failure: true
66
60
  - ruby-version: "ruby-head"
67
61
  active-record: { label: "8.1", env: "ACTIVE_RECORD_VERSION=~> 8.1.0" }
68
62
  allow-failure: true
@@ -15,7 +15,6 @@ on:
15
15
  push:
16
16
  branches: [ "master" ]
17
17
  pull_request:
18
- branches: [ "master" ]
19
18
  schedule:
20
19
  - cron: '28 0 * * 1'
21
20
 
data/.gitignore CHANGED
@@ -7,5 +7,4 @@
7
7
  /pkg/*
8
8
  /tmp/
9
9
  Gemfile.lock
10
- doc
11
10
  tags
data/.standard.yml CHANGED
@@ -3,4 +3,4 @@ ruby_version: 3.3
3
3
  plugins:
4
4
  - standard-performance
5
5
  - standard-rails:
6
- target_rails_version: 7.2
6
+ target_rails_version: 8.0
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # pg_search changelog
2
2
 
3
- ## 2.3.8
3
+ ## 2.4.0 - 2026-09-07
4
+
5
+ * Drop support for Active Record 7.2
6
+ * Replace internal SQL-string manipulation with composable Arel operations while preserving all existing use cases
7
+
8
+ ## 2.3.8 - 2026-08-10
4
9
 
5
10
  * Drop support for Ruby 3.0, 3.1, and 3.2
6
11
  * Drop support for Active Record 6.1, 7.0, and 7.1
@@ -12,7 +17,7 @@
12
17
  * Quote custom primary key and inheritance column identifiers in multisearch rebuild SQL
13
18
  * Improve documentation (Olli)
14
19
 
15
- ## 2.3.7
20
+ ## 2.3.7 - 2024-08-11
16
21
 
17
22
  * Drop support for Ruby 2.6 and 2.7
18
23
  * Drop support for Active Record 6.0 and earlier
@@ -23,7 +28,7 @@
23
28
  * add support for Arel::Nodes::SqlLiteral columns (Kyle Fazzari)
24
29
  * Improve documentation (Prima Aulia Gusta, Ross Baird, Andy Atkinson)
25
30
 
26
- ## 2.3.6
31
+ ## 2.3.6 - 2022-01-07
27
32
 
28
33
  * Drop support for Ruby 2.5
29
34
  * Support Ruby 3.1
@@ -32,186 +37,186 @@
32
37
  * Optionally disable transaction when rebuilding documents (Travis Hunter)
33
38
  * Preserve columns when chaining ::with_pg_search_highlight (jcsanti)
34
39
 
35
- ## 2.3.5
40
+ ## 2.3.5 - 2020-11-16
36
41
 
37
42
  * Add table of contents to README (Barry Woolgar)
38
43
  * Add support for Active Record 6.1
39
44
 
40
- ## 2.3.4
45
+ ## 2.3.4 - 2020-10-10
41
46
 
42
47
  * Fix issue when setting various options directly on the `PgSearch` module while
43
48
  running with a threaded web server, such as Puma. (Anton Rieder)
44
49
 
45
- ## 2.3.3
50
+ ## 2.3.3 - 2020-09-20
46
51
 
47
52
  * Drop support for Ruby < 2.5.
48
53
  * Use keyword argument for `clean_up` setting in `PgSearch::Multisearch.rebuild`.
49
54
 
50
- ## 2.3.2
55
+ ## 2.3.2 - 2020-01-13
51
56
 
52
57
  * Autoload `PgSearch::Document` to prevent it from being loaded in projects that are not using multi-search.
53
58
  * Rebuilder should use `update_pg_search_document` if `additional_attributes` is set. (David Ramalho)
54
59
 
55
- ## 2.3.1
60
+ ## 2.3.1 - 2019-12-22
56
61
 
57
62
  * Drop support for Active Record < 5.2.
58
63
  * Do not load railtie unless Rails::Railtie is defined, to avoid problem when loading alongside Action Mailer. (Adam Schwartz)
59
64
 
60
- ## 2.3.0
65
+ ## 2.3.0 - 2019-07-13
61
66
 
62
67
  * Extract `PgSearch::Model` module.
63
68
  * Deprecate `include PgSearch`. Use `include PgSearch::Model` instead.
64
69
 
65
- ## 2.2.0
70
+ ## 2.2.0 - 2019-05-26
66
71
 
67
72
  * Add `word_similarity` option to trigram search. (Severin Räz)
68
73
 
69
- ## 2.1.7
74
+ ## 2.1.7 - 2019-04-20
70
75
 
71
76
  * Restore link to GitHub repository to original location.
72
77
 
73
- ## 2.1.6
78
+ ## 2.1.6 - 2019-04-18
74
79
 
75
80
  * Update link to GitHub repository to new location.
76
81
 
77
- ## 2.1.5
82
+ ## 2.1.5 - 2019-04-08
78
83
 
79
84
  * Drop support for Ruby < 2.4.
80
85
 
81
- ## 2.1.4
86
+ ## 2.1.4 - 2019-01-26
82
87
 
83
88
  * Drop support for Ruby < 2.3.
84
89
  * Use `update` instead of deprecated `update_attributes`.
85
90
  * Remove explicit Arel dependency to better support Active Record 6 beta.
86
91
 
87
- ## 2.1.3
92
+ ## 2.1.3 - 2018-12-09
88
93
 
89
94
  * Drop support for Ruby < 2.2
90
95
  * Disallow left/right single quotation marks in tsquery. (Fabian Schwahn) (#382)
91
96
  * Do not attempt to save an already-destroyed `PgSearch::Document`. (Oleg Dashevskii, Vokhmin Aleksei V) (#353)
92
97
  * Quote column name when rebuilding. (Jed Levin) (#379)
93
98
 
94
- ## 2.1.2
99
+ ## 2.1.2 - 2017-12-25
95
100
 
96
101
  * Silence warnings in Rails 5.2.0.beta2. (Kevin Deisz)
97
102
 
98
- ## 2.1.1
103
+ ## 2.1.1 - 2017-09-20
99
104
 
100
105
  * Support snake_case `ts_headline` options again. (with deprecation warning)
101
106
 
102
- ## 2.1.0
107
+ ## 2.1.0 - 2017-07-29
103
108
 
104
109
  * Allow `ts_headline` options to be passed to `:highlight`. (Ian Heisters)
105
110
  * Wait to load `PgSearch::Document` until after Active Record has loaded. (Logan Leger)
106
111
  * Add Rails version to generated migrations. (Erik Eide)
107
112
 
108
- ## 2.0.1
113
+ ## 2.0.1 - 2016-12-20
109
114
 
110
115
  * Remove require for generator that no longer exists. (Joshua Bartlett)
111
116
 
112
- ## 2.0.0
117
+ ## 2.0.0 - 2016-12-19
113
118
 
114
119
  * Drop support for PostgreSQL < 9.2.
115
120
  * Drop support for Active Record < 4.2.
116
121
  * Drop support for Ruby < 2.1.
117
122
  * Improve performance of has_one and belongs_to associations. (Peter Postma)
118
123
 
119
- ## 1.0.6
124
+ ## 1.0.6 - 2016-05-22
120
125
 
121
126
  * Add support for highlighting the matching portion of a search result. (Jose Galisteo)
122
127
  * Add `:update_if` option to control when PgSearch::Document gets updated. (Adam Becker)
123
128
  * Add `:additional_attributes` option for adding additional attributes to PgSearch::Document
124
129
 
125
- ## 1.0.5
130
+ ## 1.0.5 - 2015-08-30
126
131
 
127
132
  * Clean up rank table aliasing. (Adam Milligan)
128
133
  * Fix issue when using `#with_pg_search_rank` across a join. (Reid Lynch)
129
134
 
130
- ## 1.0.4
135
+ ## 1.0.4 - 2015-06-14
131
136
 
132
137
  * Assert valid options for features. (Janko Marohnić)
133
138
  * Enable chaining of pg_search scopes. (Nicolas Buduroi)
134
139
 
135
- ## 1.0.3
140
+ ## 1.0.3 - 2015-05-11
136
141
 
137
142
  * Support STI models using a custom inheritance column. (Nick Doiron)
138
143
 
139
- ## 1.0.2
144
+ ## 1.0.2 - 2015-05-04
140
145
 
141
146
  * Don’t use SQL to rebuild search documents when models are multisearchable against dynamic methods and not just columns. Iterate over each record with `find_each` instead.
142
147
 
143
- ## 1.0.1
148
+ ## 1.0.1 - 2015-05-02
144
149
 
145
150
  * Call `.unscoped` on relation used to build subquery, to eliminate unnecessary JOINs. (Markus Doits)
146
151
 
147
- ## 1.0.0
152
+ ## 1.0.0 - 2015-04-19
148
153
 
149
154
  * Support more `ActiveRecord::Relation` methods, such as `#pluck` and `#select` by moving search-related operations to subquery.
150
155
  * Generate index by default in migration for `pg_search_documents` table.
151
156
  * Start officially using [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html).
152
157
 
153
- ## 0.7.9
158
+ ## 0.7.9 - 2015-02-04
154
159
 
155
160
  * Improve support for single table inheritance (STI) models. (Ewan McDougall)
156
161
 
157
- ## 0.7.8
162
+ ## 0.7.8 - 2014-09-06
158
163
 
159
164
  * Stop inadvertently including binstubs for guard and rspec.
160
165
 
161
- ## 0.7.7
166
+ ## 0.7.7 - 2014-09-05
162
167
 
163
168
  * Fix future compatibility with Active Record 4.2.
164
169
 
165
- ## 0.7.6
170
+ ## 0.7.6 - 2014-07-16
166
171
 
167
172
  * Fix migration generator in Rails 3. (Andrew Marshall and Nora Lin)
168
173
  * Add `:only` option for limiting search fields per feature. (Jonathan Greenberg)
169
174
 
170
- ## 0.7.5
175
+ ## 0.7.5 - 2014-07-15
171
176
 
172
177
  * Add option to make feature available only for sorting. (Brent Wheeldon)
173
178
 
174
- ## 0.7.4
179
+ ## 0.7.4 - 2014-05-19
175
180
 
176
181
  * Fix which STI class name is used for searchable_type for PgSearch::Document. (Ewan McDougall)
177
182
  * Add support for non-standard primary keys. (Matt Beedle)
178
183
 
179
- ## 0.7.3
184
+ ## 0.7.3 - 2014-01-26
180
185
 
181
186
  * Allow simultaneously searching using `:associated_against` and `:tsvector_column` (Adam Becker)
182
187
 
183
- ## 0.7.2
188
+ ## 0.7.2 - 2013-11-20
184
189
 
185
190
  * Add :threshold option for configuring how permissive trigram searches are.
186
191
 
187
- ## 0.7.1
192
+ ## 0.7.1 - 2013-11-20
188
193
 
189
194
  * Fix issue with {:using => :trigram, :ignoring => :accents} that generated
190
195
  bad SQL. (Steven Harman)
191
196
 
192
- ## 0.7.0
197
+ ## 0.7.0 - 2013-07-05
193
198
 
194
199
  * Start requiring Ruby 1.9.2 or later.
195
200
 
196
- ## 0.6.4
201
+ ## 0.6.4 - 2013-05-26
197
202
 
198
203
  * Fix issue with using more than two features in the same scope.
199
204
 
200
- ## 0.6.3
205
+ ## 0.6.3 - 2013-05-12
201
206
 
202
207
  * Fix issues and deprecations for Active Record 4.0.0.rc1.
203
208
 
204
- ## 0.6.2
209
+ ## 0.6.2 - 2013-04-20
205
210
 
206
211
  * Add workaround for issue with how ActiveRecord relations handle Arel OR
207
212
  nodes.
208
213
 
209
- ## 0.6.1
214
+ ## 0.6.1 - 2013-04-08
210
215
 
211
216
  * Fix issue with Arel::InfixOperation that prevented #count from working,
212
217
  breaking pagination.
213
218
 
214
- ## 0.6.0
219
+ ## 0.6.0 - 2013-04-02
215
220
 
216
221
  * Drop support for Active Record 3.0.
217
222
  * Address warnings in Ruby 2.0.
@@ -221,49 +226,49 @@
221
226
  * Support named schemas in pg_search:multisearch:rebuild. (Victor Olteanu)
222
227
 
223
228
 
224
- ## 0.5.7
229
+ ## 0.5.7 - 2012-10-07
225
230
 
226
231
  * Fix issue with eager loading now that the Scope class has been removed.
227
232
  (Piotr Murach)
228
233
 
229
234
 
230
- ## 0.5.6
235
+ ## 0.5.6 - 2012-09-29
231
236
 
232
237
  * PgSearch#multisearchable accepts :if and :unless for conditional inclusion
233
238
  in search documents table. (Francois Harbec)
234
239
  * Stop using array_to_string() in SQL since it is not indexable.
235
240
 
236
241
 
237
- ## 0.5.5
242
+ ## 0.5.5 - 2012-09-16
238
243
 
239
244
  * Fix bug with single table inheritance.
240
245
  * Allow option for specifying an alternate function for unaccent().
241
246
 
242
247
 
243
- ## 0.5.4
248
+ ## 0.5.4 - 2012-09-07
244
249
 
245
250
  * Fix bug in associated_against join clause when search scope is chained
246
251
  after other scopes.
247
252
  * Fix autoloading of PgSearch::VERSION constant.
248
253
 
249
254
 
250
- ## 0.5.3
255
+ ## 0.5.3 - 2012-09-06
251
256
 
252
257
  * Prevent multiple attempts to create pg_search_document within a single
253
258
  transaction. (JT Archie & Trace Wax)
254
259
 
255
260
 
256
- ## 0.5.2
261
+ ## 0.5.2 - 2012-09-06
257
262
 
258
263
  * Don't save twice if pg_search_document is missing on update.
259
264
 
260
265
 
261
- ## 0.5.1
266
+ ## 0.5.1 - 2012-08-01
262
267
 
263
268
  * Add ability to override multisearch rebuild SQL.
264
269
 
265
270
 
266
- ## 0.5
271
+ ## 0.5 - 2012-05-13
267
272
 
268
273
  * Convert migration rake tasks into generators.
269
274
  * Use rake task arguments for multisearch rebuild instead of environment
@@ -271,7 +276,7 @@
271
276
  * Always cast columns to text.
272
277
 
273
278
 
274
- ## 0.4.2
279
+ ## 0.4.2 - 2012-05-09
275
280
 
276
281
  * Fill in timestamps correctly when rebuilding multisearch documents.
277
282
  (Barton McGuire)
@@ -281,7 +286,7 @@
281
286
  * Fix issue with :associated_against and non-text columns.
282
287
 
283
288
 
284
- ## 0.4.1
289
+ ## 0.4.1 - 2012-02-13
285
290
 
286
291
  * Fix Active Record 3.2 deprecation warnings. (Steven Harman)
287
292
 
@@ -289,18 +294,18 @@
289
294
  defined.
290
295
 
291
296
 
292
- ## 0.4
297
+ ## 0.4 - 2011-12-15
293
298
 
294
299
  * Add ability to search again tsvector columns. (Kris Hicks)
295
300
 
296
301
 
297
- ## 0.3.4
302
+ ## 0.3.4 - 2011-11-25
298
303
 
299
304
  * Fix issue with {:using => {:tsearch => {:prefix => true}}} and hyphens.
300
305
  * Get tests running against PostgreSQL 9.1 by using CREATE EXTENSION
301
306
 
302
307
 
303
- ## 0.3.3
308
+ ## 0.3.3 - 2011-10-22
304
309
 
305
310
  * Backport array_agg() aggregate function to PostgreSQL 8.3 and earlier.
306
311
  This fixes :associated_against searches.
@@ -310,18 +315,18 @@
310
315
  earlier.
311
316
 
312
317
 
313
- ## 0.3.2
318
+ ## 0.3.2 - 2011-10-18
314
319
 
315
320
  * Fix :prefix search in PostgreSQL 8.x
316
321
  * Disable {:ignoring => :accents} in PostgreSQL 8.x
317
322
 
318
323
 
319
- ## 0.3.1
324
+ ## 0.3.1 - 2011-09-08
320
325
 
321
326
  * Fix syntax error in generated dmetaphone migration. (Max De Marzi)
322
327
 
323
328
 
324
- ## 0.3
329
+ ## 0.3 - 2011-09-06
325
330
 
326
331
  * Drop Active Record 2.0 support.
327
332
  * Add PgSearch.multisearch for cross-model searching.
@@ -331,16 +336,16 @@
331
336
  * Add :any_word option to :tsearch which uses OR between query terms instead
332
337
  of AND. (Fernando Espinosa)
333
338
 
334
- ## 0.2.2
339
+ ## 0.2.2 - 2013-07-08
335
340
 
336
341
  * Fix a compatibility issue between Ruby 1.8.7 and 1.9.3 when using Rails 2
337
342
  (James Badger)
338
343
 
339
- ## 0.2.1
344
+ ## 0.2.1 - 2011-12-15
340
345
 
341
346
  * Backport support for searching against tsvector columns (Kris Hicks)
342
347
 
343
- ## 0.2
348
+ ## 0.2 - 2011-05-11
344
349
 
345
350
  * Set dictionary to :simple by default for :tsearch. Before it was unset,
346
351
  which would fall back to PostgreSQL's default dictionary, usually
@@ -349,22 +354,22 @@
349
354
  * Improve performance of :associated_against by only doing one INNER JOIN
350
355
  per association
351
356
 
352
- ## 0.1.1
357
+ ## 0.1.1 - 2011-01-20
353
358
 
354
359
  * Fix a bug with dmetaphone searches containing " w " (which dmetaphone maps
355
360
  to an empty string)
356
361
 
357
- ## 0.1
362
+ ## 0.1 - 2011-01-18
358
363
 
359
364
  * Change API to {:ignoring => :accents} from {:normalizing => :diacritics}
360
365
  * Improve documentation
361
366
  * Fix bug where :associated_against would not work without an :against
362
367
  present
363
368
 
364
- ## 0.0.2
369
+ ## 0.0.2 - 2011-01-14
365
370
 
366
371
  * Fix gem ownership.
367
372
 
368
- ## 0.0.1
373
+ ## 0.0.1 - 2011-01-14
369
374
 
370
375
  * Initial release.
data/CONTRIBUTING.md CHANGED
@@ -12,7 +12,7 @@ Don't be discouraged if the maintainers ask you to change your code. We are alwa
12
12
 
13
13
  Our automated tests start by updating all gems to their latest version. This is by design, because we want to be proactive about compatibility with other libraries. You can do the same by running `bundle update` at any time. To test against a specific version of Active Record, you can set the `ACTIVE_RECORD_VERSION` environment variable.
14
14
 
15
- $ ACTIVE_RECORD_VERSION=5.0 bundle update
15
+ $ ACTIVE_RECORD_VERSION="~> 8.0.0" bundle update
16
16
 
17
17
  Run the tests by running `bundle exec rake`, or `bin/rake` if you use Bundler binstubs.
18
18
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010–2022 Casebook, PBC <http://www.casebook.net>
1
+ Copyright (c) 2010–2026 Casebook, PBC <http://www.casebook.net>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -14,7 +14,7 @@ Read the blog post introducing PgSearch at https://tanzu.vmware.com/content/blog
14
14
  ## REQUIREMENTS
15
15
 
16
16
  - Ruby 3.3+
17
- - Active Record 7.2+
17
+ - Active Record 8.0+
18
18
  - PostgreSQL 9.2+
19
19
  - [PostgreSQL extensions](https://github.com/Casecommons/pg_search/wiki/Installing-PostgreSQL-Extensions) for certain features
20
20
 
@@ -1220,5 +1220,5 @@ for discussing pg_search and other Casebook PBC open source projects.
1220
1220
 
1221
1221
  ## LICENSE
1222
1222
 
1223
- Copyright © 2010–2022 [Casebook PBC](http://www.casebook.net).
1223
+ Copyright © 2010–2026 [Casebook PBC](http://www.casebook.net).
1224
1224
  Licensed under the MIT license, see [LICENSE](/LICENSE) file.
@@ -0,0 +1,43 @@
1
+ # Incremental Arel migration
2
+
3
+ Replace useful SQL-string construction with composable Arel expressions in five
4
+ small, independently mergeable changes. Complete elimination of interpolation is
5
+ not required. Each change includes its own caller adaptations and tests; no later
6
+ change should be needed to make an earlier one work.
7
+
8
+ Use `to_arel` for expressions and `to_sql` for rendered SQL strings. Keep behavior
9
+ unchanged, including trusted SQL expressions and custom ordering. Preserve the
10
+ existing rank-join alias handling. Prefer named immutable values (`Data.define`)
11
+ for structured records, while retaining arrays for genuine expression lists.
12
+
13
+ ## Review and test each layer
14
+
15
+ Before changing code, assess existing coverage and characterize the relevant
16
+ behavior. Demonstrate failing coverage for new contracts or missing regressions,
17
+ then implement the narrow change. Test SQL execution against PostgreSQL, not just
18
+ rendered strings. Run focused examples, the full suite, and Standard for every
19
+ layer. Review correctness, coverage quality, and unnecessary complexity before
20
+ publishing it.
21
+
22
+ Exercise expression behavior through `to_arel`. Keep `to_sql` coverage focused on
23
+ its rendering-adapter contract, so eventually removing it does not discard the
24
+ behavioral coverage or require duplicating that coverage across both interfaces.
25
+
26
+ - [x] **Column expressions:** add explicit Arel conversions for normal and foreign
27
+ columns, preserving string conversions. Cover NULLs, casts, quoted identifiers,
28
+ and trusted JSON expressions.
29
+ - [x] **Association queries:** build aggregated projections and joins with Arel.
30
+ Cover association types, missing associations, aggregation, and alias collisions.
31
+ - [x] **Rank selection and ordering:** convert projections and ordering without
32
+ replacing the existing rank-join fix. Cover selected ranks, tie-breaking,
33
+ custom ordering, associations, and chained scopes.
34
+ - [x] **Feature expressions and normalization:** compose search expressions as
35
+ nodes while preserving sanitization. Cover blank queries, quotes and accents,
36
+ prefix/negation, weighted and stored vectors, highlighting, and other features.
37
+ - [x] **Multisearch rebuilds:** convert useful statement components without forcing
38
+ every fixed SQL fragment into Arel. Cover actual rebuilds, STI, NULL content,
39
+ multiple columns, and custom identifiers.
40
+
41
+ Record remaining interpolation after the stack as deferred work, not a release
42
+ gate. Keep unrelated cleanup, historical planning artifacts, and obsolete
43
+ compatibility code out of these changes.
@@ -0,0 +1,48 @@
1
+ # Remaining Arel expression construction
2
+
3
+ Continuation of the approved [Arel stack](2026-09-05-arel-stack.md), authorized
4
+ for autonomous follow-through while the earlier PRs are reviewed. Preserve
5
+ those PR heads; publish new independently green layers above #587.
6
+
7
+ ## Contract
8
+
9
+ Replace remaining SQL-construction interpolation and avoidable raw SQL fragments
10
+ with composable expressions, without changing query behavior or existing
11
+ String-returning adapter contracts.
12
+ Do not rewrite ordinary messages, generated names, or PostgreSQL headline-option
13
+ data merely to eliminate Ruby interpolation. No new database functions/migrations.
14
+
15
+ - [x] **Query projections and vectors:** convert ScopeOptions star/highlight/rank
16
+ projections and qualified primary-key rendering, plus TSearch's stored-vector
17
+ references. Preserve explicit select behavior, trusted custom SQL, chained
18
+ aliases, quoted identifiers, and synthetic rank references without accidentally
19
+ applying model attribute aliases.
20
+ - [x] **Column source references:** replace full_name interpolation and the
21
+ aggregate's String-to-Arel round trip with a coherent source-attribute
22
+ expression. Preserve the distinction between a foreign column's original
23
+ association source and its derived search-document alias, non-coalesced
24
+ aggregation, and the existing full_name/to_sql String interfaces.
25
+ - [x] **Quoted values:** replace hand-quoted data and quote/render/wrap patterns
26
+ with quoted-value nodes: separators, empty strings, regex arguments, model
27
+ names, and timestamps. Preserve actual data, escaping, NULL behavior, and the
28
+ shared timestamp. Do not confuse a SQL type token or empty SQL fragment with
29
+ a string value.
30
+ - [x] **Expression boundaries:** preserve Arel attributes through normalization
31
+ instead of coercing their Ruby inspection into SQL; remove avoidable internal
32
+ render-and-wrap cycles for primary keys and default ranking. Preserve the
33
+ documented custom SQL inputs and legacy String adapters at their boundaries.
34
+ Investigate empty-expression fragments before changing their semantics.
35
+ - [x] **Final audit:** verify remaining interpolation/raw SQL is intentional
36
+ syntax, data serialization, or trusted escape-hatch input; report residue
37
+ rather than hiding it.
38
+
39
+ ## Verification and delivery
40
+
41
+ Characterize meaningful missing behavior before refactoring; no private-helper
42
+ specs or test-only visibility subclasses. Simplify touched fixture setup using
43
+ normal schema names and Rails conventions. Prefer public database behavior over
44
+ additional SQL golden matrices. Run relevant specs and bin/rake independently
45
+ for each layer, including the existing pinned Rails-main environment; require
46
+ one focused independent review per layer and green hosted CI.
47
+
48
+ Check each item with its owning code.