scoped_search 4.1.9 → 4.1.10

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: 9c1453ebb8fe2391f71ea35171f2115ed89bb7920a1a042d86a4393fe218888c
4
- data.tar.gz: 61d2d0e948a952f7e955240747dae7e529103c5871ad3160cb2213574f0f155a
3
+ metadata.gz: f0f6f98982cba23ec69f2b1adaf0c44832abb19adad7a347d4d78c4b0fbb63a8
4
+ data.tar.gz: 114ea022f87208dc89b92247687d64c2a0146119afa33f2106b69507271ba210
5
5
  SHA512:
6
- metadata.gz: 04e61c564c6117d60b6f82b970df5c6c7a68362d828d89d1cf5d2bf7f6b7c9ea777cf641dbb2a21be895905305c0c7305105c9840d391aa702cd69eab706fd4d
7
- data.tar.gz: 842c31b1714558d8bd4578d47b87bca4fa4298617a16168b66a77e6ff06ee1f43406b30be3557a9c50222ba5effaa9c5eec27832839e75bb11faf085f95bb7bc
6
+ metadata.gz: 6a87832ba5990fd45b7116d374a9c2505c7f9fcf62b4364859986ae497b2aa6d3a0890b222b1ad6c07ea999d48b25fbc42303a63cdc8ce3f4ea3a23e1f049eeb
7
+ data.tar.gz: a5cd950d77712004cb649261f08a8e8e04169622b346de7c3b15b422dbae7343bf8211febbdb988cf390a43c5f4794c93e820b9bc440d4cc9130d7f3146464f9
@@ -0,0 +1,76 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on: [pull_request]
11
+
12
+ env:
13
+ TESTOPTS: --verbose
14
+
15
+ jobs:
16
+ test:
17
+ runs-on: ubuntu-latest
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby_version:
22
+ - 2.7.1
23
+ - 3.0.0
24
+ - ruby-head
25
+ - jruby-head
26
+ gemfile:
27
+ - Gemfile.activerecord52
28
+ - Gemfile.activerecord52_with_activesupport52
29
+ - Gemfile.activerecord60
30
+ - Gemfile.activerecord60_with_activesupport60
31
+ - Gemfile.activerecord61
32
+ - Gemfile.activerecord61_with_activesupport61
33
+
34
+ exclude:
35
+ - ruby_version: 2.7.1
36
+ gemfile: Gemfile.activerecord52
37
+ - ruby_version: 2.7.1
38
+ gemfile: Gemfile.activerecord52_with_activesupport52
39
+ - ruby_version: 3.0.0
40
+ gemfile: Gemfile.activerecord52
41
+ - ruby_version: 3.0.0
42
+ gemfile: Gemfile.activerecord52_with_activesupport52
43
+ - ruby_version: ruby-head
44
+ gemfile: Gemfile.activerecord52
45
+ - ruby_version: ruby-head
46
+ gemfile: Gemfile.activerecord52_with_activesupport52
47
+ services:
48
+ postgres:
49
+ image: postgres:12.1
50
+ ports: ['5432:5432']
51
+ options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
52
+ env:
53
+ POSTGRES_DB: scoped_search_test
54
+ mariadb:
55
+ image: mariadb:10
56
+ ports: ['3306:3306']
57
+ env:
58
+ MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
59
+ MYSQL_DATABASE: scoped_search_test
60
+
61
+ env:
62
+ BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
63
+
64
+ steps:
65
+ - uses: actions/checkout@v2
66
+ - name: Set up Ruby
67
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
68
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
69
+ uses: ruby/setup-ruby@v1
70
+ with:
71
+ ruby-version: ${{ matrix.ruby_version }}
72
+ bundler-cache: true
73
+ # - name: Install dependencies
74
+ # run: bundle install
75
+ - name: Run tests
76
+ run: bundle exec rake
data/.travis.yml CHANGED
@@ -22,6 +22,7 @@ rvm:
22
22
  - "2.5.1"
23
23
  - "2.6.0"
24
24
  - "2.7.1"
25
+ - "3.0.2"
25
26
  - ruby-head
26
27
  - jruby-19mode
27
28
  - jruby-head
@@ -34,6 +35,8 @@ gemfile:
34
35
  - Gemfile.activerecord52_with_activesupport52
35
36
  - Gemfile.activerecord60
36
37
  - Gemfile.activerecord60_with_activesupport60
38
+ - Gemfile.activerecord61
39
+ - Gemfile.activerecord61_with_activesupport61
37
40
 
38
41
  matrix:
39
42
  allow_failures:
@@ -77,6 +80,26 @@ matrix:
77
80
  gemfile: Gemfile.activerecord60_with_activesupport60
78
81
  - rvm: "2.4.0"
79
82
  gemfile: Gemfile.activerecord60_with_activesupport60
83
+ - rvm: "2.0"
84
+ gemfile: Gemfile.activerecord61
85
+ - rvm: "2.1"
86
+ gemfile: Gemfile.activerecord61
87
+ - rvm: "2.2.2"
88
+ gemfile: Gemfile.activerecord61
89
+ - rvm: "2.3.7"
90
+ gemfile: Gemfile.activerecord61
91
+ - rvm: "2.4.0"
92
+ gemfile: Gemfile.activerecord61
93
+ - rvm: "2.0"
94
+ gemfile: Gemfile.activerecord61_with_activesupport61
95
+ - rvm: "2.1"
96
+ gemfile: Gemfile.activerecord61_with_activesupport61
97
+ - rvm: "2.2.2"
98
+ gemfile: Gemfile.activerecord61_with_activesupport61
99
+ - rvm: "2.3.7"
100
+ gemfile: Gemfile.activerecord61_with_activesupport61
101
+ - rvm: "2.4.0"
102
+ gemfile: Gemfile.activerecord61_with_activesupport61
80
103
  - rvm: "2.7.1"
81
104
  gemfile: Gemfile.activerecord42
82
105
  - rvm: "2.7.1"
@@ -87,3 +110,13 @@ matrix:
87
110
  gemfile: Gemfile.activerecord52
88
111
  - rvm: "2.7.1"
89
112
  gemfile: Gemfile.activerecord52_with_activesupport52
113
+ - rvm: "3.0.2"
114
+ gemfile: Gemfile.activerecord42
115
+ - rvm: "3.0.2"
116
+ gemfile: Gemfile.activerecord50
117
+ - rvm: "3.0.2"
118
+ gemfile: Gemfile.activerecord51
119
+ - rvm: "3.0.2"
120
+ gemfile: Gemfile.activerecord52
121
+ - rvm: "3.0.2"
122
+ gemfile: Gemfile.activerecord52_with_activesupport52
data/CHANGELOG.rdoc CHANGED
@@ -6,7 +6,16 @@ Please add an entry to the "Unreleased changes" section in your pull requests.
6
6
 
7
7
  === Unreleased changes
8
8
 
9
- - Nothing yet
9
+ === Version 4.1.10
10
+
11
+ - Fix querying through associations in Rails 6.1 (undefined method join_keys) (#201)
12
+ - Fix query generation when going through STI associations (#211)
13
+ - Properly support Ruby 3
14
+ - Add support for postgres citext type
15
+
16
+ === Version 4.1.9
17
+ - Fix querying on nested has-many associations (#196)
18
+ - Abide "has_many ..., primary_key" overrides in relation searches
10
19
 
11
20
  === Version 4.1.8
12
21
 
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'actionview', '~> 6.1.0'
5
+ gem 'activerecord', '~> 6.1.0'
6
+
7
+ platforms :jruby do
8
+ gem 'activerecord-jdbcsqlite3-adapter'
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ gem 'activerecord-jdbcpostgresql-adapter'
11
+ end
12
+
13
+ platforms :ruby do
14
+ gem 'sqlite3', '~> 1.4'
15
+ gem 'mysql2', '> 0.5'
16
+ gem 'pg', '>= 0.18', '< 2.0'
17
+ end
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'actionview', '~> 6.1.0'
5
+ gem 'activerecord', '~> 6.1.0'
6
+ gem 'activesupport', '~> 6.1.0'
7
+
8
+ platforms :jruby do
9
+ gem 'activerecord-jdbcsqlite3-adapter'
10
+ gem 'activerecord-jdbcmysql-adapter'
11
+ gem 'activerecord-jdbcpostgresql-adapter'
12
+ end
13
+
14
+ platforms :ruby do
15
+ gem 'sqlite3', '~> 1.4'
16
+ gem 'mysql2', '> 0.5'
17
+ gem 'pg', '>= 0.18', '< 2.0'
18
+ end
@@ -157,7 +157,7 @@ module ScopedSearch
157
157
 
158
158
  # Returns true if this is a textual column.
159
159
  def textual?
160
- [:string, :text].include?(type)
160
+ [:string, :text, :citext].include?(type)
161
161
  end
162
162
 
163
163
  def uuid?
@@ -172,7 +172,7 @@ module ScopedSearch
172
172
  # Returns the default search operator for this field.
173
173
  def default_operator
174
174
  @default_operator ||= case type
175
- when :string, :text then :like
175
+ when :string, :text, :citext then :like
176
176
  else :eq
177
177
  end
178
178
  end
@@ -266,7 +266,7 @@ module ScopedSearch
266
266
  def default_fields_for(value, operator = nil)
267
267
 
268
268
  column_types = [:virtual]
269
- column_types += [:string, :text] if [nil, :like, :unlike, :ne, :eq].include?(operator)
269
+ column_types += [:string, :text, :citext] if [nil, :like, :unlike, :ne, :eq].include?(operator)
270
270
  column_types += [:double, :float, :decimal] if value =~ NUMERICAL_REGXP
271
271
  column_types += [:integer] if value =~ INTEGER_REGXP
272
272
  column_types += [:uuid] if value =~ UUID_REGXP
@@ -305,8 +305,8 @@ module ScopedSearch
305
305
  end
306
306
 
307
307
  # Defines a new search field for this search definition.
308
- def define(*args)
309
- Field.new(self, *args)
308
+ def define(*args, **kwargs)
309
+ Field.new(self, *args, **kwargs)
310
310
  end
311
311
 
312
312
  # Returns a reflection for a given klass and name
@@ -38,7 +38,9 @@ module ScopedSearch
38
38
 
39
39
  # Initializes the instance by setting the relevant parameters
40
40
  def initialize(definition, ast, profile)
41
- @definition, @ast, @definition.profile = definition, ast, profile
41
+ @definition = definition
42
+ @ast = ast
43
+ @definition.profile = profile
42
44
  end
43
45
 
44
46
  # Actually builds the find parameters hash that should be used in the search_for
@@ -287,15 +289,20 @@ module ScopedSearch
287
289
  connection = many_class.connection
288
290
  sql = connection.quote_table_name(many_class.table_name)
289
291
  join_reflections = nested_has_many(many_class, field.relation)
290
- table_names = [many_class.table_name] + join_reflections.map(&:table_name)
292
+ table_names = [[many_class.table_name, many_class.sti_name.tableize]] + join_reflections.map(&:table_name)
291
293
 
292
294
  join_reflections.zip(table_names.zip(join_reflections.drop(1))).reduce(sql) do |acc, (reflection, (previous_table, next_reflection))|
293
- klass = reflection.method(:join_keys).arity == 1 ? [reflection.klass] : [] # ActiveRecord <5.2 workaround
294
- fk1, pk1 = reflection.join_keys(*klass).values # We are joining the tables "in reverse", so the PK and FK are swapped
295
-
295
+ fk1, pk1 = if reflection.respond_to?(:join_keys)
296
+ klass = reflection.method(:join_keys).arity == 1 ? [reflection.klass] : [] # ActiveRecord <5.2 workaround
297
+ reflection.join_keys(*klass).values # We are joining the tables "in reverse", so the PK and FK are swapped
298
+ else
299
+ [reflection.join_primary_key, reflection.join_foreign_key] #ActiveRecord 6.1
300
+ end
301
+
302
+ previous_table, sti_name = previous_table
296
303
  # primary and foreign keys + optional conditions for the joins
297
304
  join_condition = if with_polymorphism?(reflection)
298
- field.reflection_conditions(definition.reflection_by_name(next_reflection.klass, previous_table))
305
+ field.reflection_conditions(definition.reflection_by_name(next_reflection.klass, sti_name || previous_table))
299
306
  else
300
307
  ''
301
308
  end
@@ -1,3 +1,3 @@
1
1
  module ScopedSearch
2
- VERSION = "4.1.9"
2
+ VERSION = "4.1.10"
3
3
  end
data/lib/scoped_search.rb CHANGED
@@ -34,9 +34,9 @@ module ScopedSearch
34
34
 
35
35
  definitions.each do |definition|
36
36
  if definition[:on].kind_of?(Array)
37
- definition[:on].each { |field| self.scoped_search_definition.define(definition.merge(:on => field)) }
37
+ definition[:on].each { |field| self.scoped_search_definition.define(**definition.merge(:on => field)) }
38
38
  else
39
- self.scoped_search_definition.define(definition)
39
+ self.scoped_search_definition.define(**definition)
40
40
  end
41
41
  end
42
42
  return self.scoped_search_definition
@@ -4,7 +4,7 @@ sqlite:
4
4
 
5
5
  mysql:
6
6
  adapter: jdbcmysql
7
- host: localhost
7
+ host: 127.0.0.1
8
8
  username: root
9
9
  database: scoped_search_test
10
10
 
@@ -4,7 +4,7 @@ sqlite:
4
4
 
5
5
  mysql:
6
6
  adapter: mysql2
7
- host: localhost
7
+ host: 127.0.0.1
8
8
  port: 3306
9
9
  username: root
10
10
  database: scoped_search_test
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scoped_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.9
4
+ version: 4.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amos Benari
8
8
  - Willem van Bergen
9
9
  - Wes Hays
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-08-24 00:00:00.000000000 Z
13
+ date: 2021-11-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -77,6 +77,7 @@ extra_rdoc_files:
77
77
  - CONTRIBUTING.rdoc
78
78
  - LICENSE
79
79
  files:
80
+ - ".github/workflows/ruby.yml"
80
81
  - ".gitignore"
81
82
  - ".travis.yml"
82
83
  - CHANGELOG.rdoc
@@ -89,6 +90,8 @@ files:
89
90
  - Gemfile.activerecord52_with_activesupport52
90
91
  - Gemfile.activerecord60
91
92
  - Gemfile.activerecord60_with_activesupport60
93
+ - Gemfile.activerecord61
94
+ - Gemfile.activerecord61_with_activesupport61
92
95
  - LICENSE
93
96
  - README.rdoc
94
97
  - Rakefile
@@ -141,7 +144,7 @@ homepage: https://github.com/wvanbergen/scoped_search/wiki
141
144
  licenses:
142
145
  - MIT
143
146
  metadata: {}
144
- post_install_message:
147
+ post_install_message:
145
148
  rdoc_options:
146
149
  - "--title"
147
150
  - scoped_search
@@ -162,8 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
165
  - !ruby/object:Gem::Version
163
166
  version: '0'
164
167
  requirements: []
165
- rubygems_version: 3.0.3
166
- signing_key:
168
+ rubygems_version: 3.1.2
169
+ signing_key:
167
170
  specification_version: 4
168
171
  summary: Easily search you ActiveRecord models with a simple query language using
169
172
  a named scope