db_text_search 0.2.2 → 0.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 +5 -5
- data/CHANGES.md +4 -0
- data/README.md +1 -1
- data/RELEASE-CHECKLIST.md +17 -0
- data/lib/db_text_search/case_insensitive.rb +7 -0
- data/lib/db_text_search/case_insensitive/abstract_adapter.rb +7 -0
- data/lib/db_text_search/case_insensitive/collate_nocase_adapter.rb +5 -0
- data/lib/db_text_search/case_insensitive/insensitive_column_adapter.rb +5 -0
- data/lib/db_text_search/case_insensitive/lower_adapter.rb +5 -0
- data/lib/db_text_search/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0d92c61c41829c38220d6a14b044338bc175bb6b86e65d65b09b9492a3d76e06
|
4
|
+
data.tar.gz: 4b0f2e640eaeeb1296bd22eece62b26cf052aea184c5a3f2c72492043b4f50d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c87b6c3b586d1cf9d00f39160f6def5082c50674b6409d66447715ed47374b7e2b9962ff5dd747639ec9057f94ae85ce66a07ac0dbd1aca7e272eb000af8784
|
7
|
+
data.tar.gz: a672e09f0f356771d7194e95c78826c8f24cb299c263e4ca894d55f5ad65c83d0f010f3ac24db12a0e118ddfd4b808fda83b3e39b0a8eb8b73a0ed0d72317c66
|
data/CHANGES.md
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
* Raises a more helpful error if the column is not found when calling
|
4
4
|
`DbTextSearch::CaseInsensitive`.
|
5
5
|
|
6
|
+
## v0.3.0
|
7
|
+
|
8
|
+
* * **Feature** Case insensitive sorting via the new `CaseInsensitive#column_for_order(asc_or_desc)` method. Use it like `SomeModel.some_scope.order(CaseInsensitive.new(SomeModel, :some_field).column_for_order(:asc))`
|
9
|
+
|
6
10
|
## v0.2.1
|
7
11
|
|
8
12
|
* Support for PostGIS adapters.
|
data/README.md
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
The checklist for releasing a new version of db_text_search.
|
2
|
+
|
3
|
+
Pre-requisites for the releaser:
|
4
|
+
|
5
|
+
* Push access to RubyGems.
|
6
|
+
|
7
|
+
Release checklist:
|
8
|
+
|
9
|
+
- [ ] Update gem version in `version.rb` and `README.md`.
|
10
|
+
- [ ] Update `CHANGELOG.md`.
|
11
|
+
- [ ] Wait for the Travis build to come back green.
|
12
|
+
- [ ] Tag the release and push it to rubygems:
|
13
|
+
|
14
|
+
```bash
|
15
|
+
rake release
|
16
|
+
```
|
17
|
+
- [ ] Copy the release notes from the changelog to [GitHub Releases](https://github.com/thredded/thredded/releases).
|
@@ -29,6 +29,13 @@ module DbTextSearch
|
|
29
29
|
@adapter.prefix(query)
|
30
30
|
end
|
31
31
|
|
32
|
+
# @param asc_or_desc [Symbol]
|
33
|
+
# @return [Arel::Collectors::SQLString] a string to be used within an `.order()`
|
34
|
+
def column_for_order(asc_or_desc)
|
35
|
+
fail 'Pass either :asc or :desc' unless %i[asc desc].include?(asc_or_desc)
|
36
|
+
@adapter.column_for_order(asc_or_desc)
|
37
|
+
end
|
38
|
+
|
32
39
|
# Adds a case-insensitive column to the given table.
|
33
40
|
# @param connection [ActiveRecord::ConnectionAdapters::AbstractAdapter]
|
34
41
|
# @param table_name [String, Symbol]
|
@@ -30,6 +30,13 @@ module DbTextSearch
|
|
30
30
|
fail 'abstract'
|
31
31
|
end
|
32
32
|
|
33
|
+
# @param asc_or_desc [Symbol]
|
34
|
+
# @return [Arel::Collectors::SQLString]
|
35
|
+
# @abstract
|
36
|
+
def column_for_order(asc_or_desc)
|
37
|
+
fail 'abstract'
|
38
|
+
end
|
39
|
+
|
33
40
|
# Add an index for case-insensitive string search.
|
34
41
|
#
|
35
42
|
# @param connection [ActiveRecord::ConnectionAdapters::AbstractAdapter]
|
@@ -22,6 +22,11 @@ module DbTextSearch
|
|
22
22
|
escaped_query
|
23
23
|
end
|
24
24
|
|
25
|
+
# (see AbstractAdapter#column_for_order)
|
26
|
+
def column_for_order(asc_or_desc)
|
27
|
+
Arel.sql("#{quoted_scope_column} COLLATE NOCASE #{asc_or_desc}")
|
28
|
+
end
|
29
|
+
|
25
30
|
# (see AbstractAdapter.add_index)
|
26
31
|
def self.add_index(connection, table_name, column_name, options = {})
|
27
32
|
# TODO: Switch to the native Rails solution once it's landed, as the current one requires SQL dump format.
|
@@ -16,6 +16,11 @@ module DbTextSearch
|
|
16
16
|
@scope.where "#{quoted_scope_column} LIKE ?", "#{sanitize_sql_like(query)}%"
|
17
17
|
end
|
18
18
|
|
19
|
+
# (see AbstractAdapter#column_for_order)
|
20
|
+
def column_for_order(asc_or_desc)
|
21
|
+
Arel.sql("#{quoted_scope_column} #{asc_or_desc}")
|
22
|
+
end
|
23
|
+
|
19
24
|
# (see AbstractAdapter.add_index)
|
20
25
|
def self.add_index(connection, table_name, column_name, options = {})
|
21
26
|
connection.add_index table_name, column_name, options
|
@@ -17,6 +17,11 @@ module DbTextSearch
|
|
17
17
|
@scope.where "LOWER(#{quoted_scope_column}) LIKE LOWER(?)", "#{sanitize_sql_like(query)}%"
|
18
18
|
end
|
19
19
|
|
20
|
+
# (see AbstractAdapter#column_for_order)
|
21
|
+
def column_for_order(asc_or_desc)
|
22
|
+
Arel.sql("LOWER(#{quoted_scope_column}) #{asc_or_desc}")
|
23
|
+
end
|
24
|
+
|
20
25
|
# (see AbstractAdapter.add_index)
|
21
26
|
def self.add_index(connection, table_name, column_name, options = {})
|
22
27
|
unsupported = -> { DbTextSearch.unsupported_adapter! connection }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db_text_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gleb Mazovetskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- CODE_OF_CONDUCT.md
|
157
157
|
- LICENSE.txt
|
158
158
|
- README.md
|
159
|
+
- RELEASE-CHECKLIST.md
|
159
160
|
- db_text_search.gemspec
|
160
161
|
- lib/db_text_search.rb
|
161
162
|
- lib/db_text_search/case_insensitive.rb
|
@@ -191,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
192
|
version: '0'
|
192
193
|
requirements: []
|
193
194
|
rubyforge_project:
|
194
|
-
rubygems_version: 2.
|
195
|
+
rubygems_version: 2.7.7
|
195
196
|
signing_key:
|
196
197
|
specification_version: 4
|
197
198
|
summary: A unified interface on top of ActiveRecord for SQLite, MySQL, and PostgreSQLfor
|