actionset 0.9.2 → 0.10.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
  SHA1:
3
- metadata.gz: 6cb8d92535baa9047efc45d77b0b7093348eb0ab
4
- data.tar.gz: efc763790124d2130deb03b5a54656d4a8bc35cc
3
+ metadata.gz: 584c036e467d238b7179b811b0a07d3655319cbd
4
+ data.tar.gz: 2351259205c70c9263598e2028597feb2272f8cd
5
5
  SHA512:
6
- metadata.gz: b34b291f7d8ec64de74565e81c451c27b91819263fea54385cabbe08d0367a253e26e6ea52350f0429def47d5e1803cee7f8795e1b6d1368af2db4ed499997b0
7
- data.tar.gz: a15050e490ac28036860fe2d8c93ea4e856ee0814424fafec168f1042c078cde849fb4fb50eb8d0df4c7d4fc368519246646fa020012a3e7f8d054fb5800ade6
6
+ metadata.gz: e6dd37b7c4804b49ce9cfef0127af990574a835d656eef7635e5ff9864315cf2bd19ce4200e7035aa3f50ca4762167352de9fa36c29ba7fa4274b7a1a888dac3
7
+ data.tar.gz: 896564ca56c2bed5a0db6d398f44a6677529c70e0a3ff84d1424af2f391b8513380e2c752757efe9a86114a79f509b87b549dd03d151a319337145de4a09d792
@@ -1 +1 @@
1
- 2.4.1
1
+ 2.4.9
@@ -1,7 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.1
4
+ - 2.4.9
5
5
  before_install:
6
6
  - gem install bundler -v 1.15.4
7
7
  - export TZ=America/New_York
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ v 0.10.0
2
+ - Bump testing internals to Rails 5.2
3
+ - Fix deprecation notice on sorts.
4
+ - Prevent additional types from checking for empty strings in blank queries. These DB types will not support empty strings, so we do not need to check for those values (and doing so corrupts the SQL).
5
+ - Do not attach wildcards to boolean search values. They have no meaning when searching boolean fields and all get transformed to "true"
1
6
  v 0.9.2
2
7
  - allow for form-friendly filter parameters
3
8
  ```
@@ -8,170 +8,181 @@ PATH
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (5.1.7)
12
- actionpack (= 5.1.7)
11
+ actioncable (5.2.4.2)
12
+ actionpack (= 5.2.4.2)
13
13
  nio4r (~> 2.0)
14
- websocket-driver (~> 0.6.1)
15
- actionmailer (5.1.7)
16
- actionpack (= 5.1.7)
17
- actionview (= 5.1.7)
18
- activejob (= 5.1.7)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailer (5.2.4.2)
16
+ actionpack (= 5.2.4.2)
17
+ actionview (= 5.2.4.2)
18
+ activejob (= 5.2.4.2)
19
19
  mail (~> 2.5, >= 2.5.4)
20
20
  rails-dom-testing (~> 2.0)
21
- actionpack (5.1.7)
22
- actionview (= 5.1.7)
23
- activesupport (= 5.1.7)
24
- rack (~> 2.0)
21
+ actionpack (5.2.4.2)
22
+ actionview (= 5.2.4.2)
23
+ activesupport (= 5.2.4.2)
24
+ rack (~> 2.0, >= 2.0.8)
25
25
  rack-test (>= 0.6.3)
26
26
  rails-dom-testing (~> 2.0)
27
27
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
- actionview (5.1.7)
29
- activesupport (= 5.1.7)
28
+ actionview (5.2.4.2)
29
+ activesupport (= 5.2.4.2)
30
30
  builder (~> 3.1)
31
31
  erubi (~> 1.4)
32
32
  rails-dom-testing (~> 2.0)
33
33
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
- activejob (5.1.7)
35
- activesupport (= 5.1.7)
34
+ activejob (5.2.4.2)
35
+ activesupport (= 5.2.4.2)
36
36
  globalid (>= 0.3.6)
37
- activemodel (5.1.7)
38
- activesupport (= 5.1.7)
39
- activerecord (5.1.7)
40
- activemodel (= 5.1.7)
41
- activesupport (= 5.1.7)
42
- arel (~> 8.0)
43
- activesupport (5.1.7)
37
+ activemodel (5.2.4.2)
38
+ activesupport (= 5.2.4.2)
39
+ activerecord (5.2.4.2)
40
+ activemodel (= 5.2.4.2)
41
+ activesupport (= 5.2.4.2)
42
+ arel (>= 9.0)
43
+ activestorage (5.2.4.2)
44
+ actionpack (= 5.2.4.2)
45
+ activerecord (= 5.2.4.2)
46
+ marcel (~> 0.3.1)
47
+ activesupport (5.2.4.2)
44
48
  concurrent-ruby (~> 1.0, >= 1.0.2)
45
49
  i18n (>= 0.7, < 2)
46
50
  minitest (~> 5.1)
47
51
  tzinfo (~> 1.1)
48
- addressable (2.6.0)
49
- public_suffix (>= 2.0.2, < 4.0)
52
+ addressable (2.7.0)
53
+ public_suffix (>= 2.0.2, < 5.0)
50
54
  ansi (1.5.0)
51
- arel (8.0.0)
55
+ arel (9.0.0)
52
56
  ast (2.4.0)
53
- builder (3.2.3)
54
- capybara (3.19.0)
57
+ builder (3.2.4)
58
+ capybara (3.31.0)
55
59
  addressable
56
60
  mini_mime (>= 0.1.3)
57
61
  nokogiri (~> 1.8)
58
62
  rack (>= 1.6.0)
59
63
  rack-test (>= 0.6.3)
60
- regexp_parser (~> 1.2)
64
+ regexp_parser (~> 1.5)
61
65
  xpath (~> 3.2)
62
- codecov (0.1.14)
66
+ codecov (0.1.16)
63
67
  json
64
68
  simplecov
65
69
  url
66
- combustion (1.1.0)
70
+ combustion (1.1.2)
67
71
  activesupport (>= 3.0.0)
68
72
  railties (>= 3.0.0)
69
73
  thor (>= 0.14.6)
70
- concurrent-ruby (1.1.5)
71
- crass (1.0.4)
72
- database_cleaner (1.7.0)
74
+ concurrent-ruby (1.1.6)
75
+ crass (1.0.6)
76
+ database_cleaner (1.8.3)
73
77
  diff-lcs (1.3)
74
- docile (1.3.1)
75
- erubi (1.8.0)
76
- factory_bot (5.0.2)
78
+ docile (1.3.2)
79
+ erubi (1.9.0)
80
+ factory_bot (5.1.1)
77
81
  activesupport (>= 4.2.0)
78
- faker (1.9.3)
79
- i18n (>= 0.7)
82
+ faker (2.10.2)
83
+ i18n (>= 1.6, < 2)
80
84
  globalid (0.4.2)
81
85
  activesupport (>= 4.2.0)
82
- hirb (0.7.3)
83
- i18n (1.6.0)
86
+ i18n (1.8.2)
84
87
  concurrent-ruby (~> 1.0)
85
- jaro_winkler (1.5.2)
86
- json (2.2.0)
87
- loofah (2.2.3)
88
+ jaro_winkler (1.5.4)
89
+ json (2.3.0)
90
+ loofah (2.5.0)
88
91
  crass (~> 1.0.2)
89
92
  nokogiri (>= 1.5.9)
90
93
  mail (2.7.1)
91
94
  mini_mime (>= 0.1.1)
92
- method_source (0.9.2)
93
- mini_mime (1.0.1)
95
+ marcel (0.3.3)
96
+ mimemagic (~> 0.3.2)
97
+ method_source (1.0.0)
98
+ mimemagic (0.3.4)
99
+ mini_mime (1.0.2)
94
100
  mini_portile2 (2.4.0)
95
- minitest (5.11.3)
96
- nio4r (2.3.1)
97
- nokogiri (1.10.3)
101
+ minitest (5.14.0)
102
+ nio4r (2.5.2)
103
+ nokogiri (1.10.9)
98
104
  mini_portile2 (~> 2.4.0)
99
- parallel (1.17.0)
100
- parser (2.6.3.0)
105
+ parallel (1.19.1)
106
+ parser (2.7.0.4)
101
107
  ast (~> 2.4.0)
102
- public_suffix (3.0.3)
103
- rack (2.0.7)
108
+ polyamorous (2.3.0)
109
+ activerecord (>= 5.0)
110
+ public_suffix (4.0.3)
111
+ rack (2.2.2)
104
112
  rack-test (1.1.0)
105
113
  rack (>= 1.0, < 3)
106
- rails (5.1.7)
107
- actioncable (= 5.1.7)
108
- actionmailer (= 5.1.7)
109
- actionpack (= 5.1.7)
110
- actionview (= 5.1.7)
111
- activejob (= 5.1.7)
112
- activemodel (= 5.1.7)
113
- activerecord (= 5.1.7)
114
- activesupport (= 5.1.7)
114
+ rails (5.2.4.2)
115
+ actioncable (= 5.2.4.2)
116
+ actionmailer (= 5.2.4.2)
117
+ actionpack (= 5.2.4.2)
118
+ actionview (= 5.2.4.2)
119
+ activejob (= 5.2.4.2)
120
+ activemodel (= 5.2.4.2)
121
+ activerecord (= 5.2.4.2)
122
+ activestorage (= 5.2.4.2)
123
+ activesupport (= 5.2.4.2)
115
124
  bundler (>= 1.3.0)
116
- railties (= 5.1.7)
125
+ railties (= 5.2.4.2)
117
126
  sprockets-rails (>= 2.0.0)
118
127
  rails-dom-testing (2.0.3)
119
128
  activesupport (>= 4.2.0)
120
129
  nokogiri (>= 1.6)
121
- rails-html-sanitizer (1.0.4)
122
- loofah (~> 2.2, >= 2.2.2)
123
- railties (5.1.7)
124
- actionpack (= 5.1.7)
125
- activesupport (= 5.1.7)
130
+ rails-html-sanitizer (1.3.0)
131
+ loofah (~> 2.3)
132
+ railties (5.2.4.2)
133
+ actionpack (= 5.2.4.2)
134
+ activesupport (= 5.2.4.2)
126
135
  method_source
127
136
  rake (>= 0.8.7)
128
- thor (>= 0.18.1, < 2.0)
137
+ thor (>= 0.19.0, < 2.0)
129
138
  rainbow (3.0.0)
130
- rake (12.3.2)
131
- ransack (2.1.1)
139
+ rake (13.0.1)
140
+ ransack (2.3.0)
132
141
  actionpack (>= 5.0)
133
142
  activerecord (>= 5.0)
134
143
  activesupport (>= 5.0)
135
144
  i18n
136
- regexp_parser (1.4.0)
137
- rspec (3.8.0)
138
- rspec-core (~> 3.8.0)
139
- rspec-expectations (~> 3.8.0)
140
- rspec-mocks (~> 3.8.0)
141
- rspec-core (3.8.0)
142
- rspec-support (~> 3.8.0)
143
- rspec-expectations (3.8.3)
145
+ polyamorous (= 2.3.0)
146
+ regexp_parser (1.7.0)
147
+ rexml (3.2.4)
148
+ rspec (3.9.0)
149
+ rspec-core (~> 3.9.0)
150
+ rspec-expectations (~> 3.9.0)
151
+ rspec-mocks (~> 3.9.0)
152
+ rspec-core (3.9.1)
153
+ rspec-support (~> 3.9.1)
154
+ rspec-expectations (3.9.1)
144
155
  diff-lcs (>= 1.2.0, < 2.0)
145
- rspec-support (~> 3.8.0)
146
- rspec-mocks (3.8.0)
156
+ rspec-support (~> 3.9.0)
157
+ rspec-mocks (3.9.1)
147
158
  diff-lcs (>= 1.2.0, < 2.0)
148
- rspec-support (~> 3.8.0)
149
- rspec-rails (3.8.2)
159
+ rspec-support (~> 3.9.0)
160
+ rspec-rails (3.9.1)
150
161
  actionpack (>= 3.0)
151
162
  activesupport (>= 3.0)
152
163
  railties (>= 3.0)
153
- rspec-core (~> 3.8.0)
154
- rspec-expectations (~> 3.8.0)
155
- rspec-mocks (~> 3.8.0)
156
- rspec-support (~> 3.8.0)
157
- rspec-support (3.8.0)
158
- rubocop (0.68.1)
164
+ rspec-core (~> 3.9.0)
165
+ rspec-expectations (~> 3.9.0)
166
+ rspec-mocks (~> 3.9.0)
167
+ rspec-support (~> 3.9.0)
168
+ rspec-support (3.9.2)
169
+ rubocop (0.80.1)
159
170
  jaro_winkler (~> 1.5.1)
160
171
  parallel (~> 1.10)
161
- parser (>= 2.5, != 2.5.1.1)
172
+ parser (>= 2.7.0.1)
162
173
  rainbow (>= 2.2.2, < 4.0)
174
+ rexml
163
175
  ruby-progressbar (~> 1.7)
164
- unicode-display_width (>= 1.4.0, < 1.6)
165
- ruby-progressbar (1.10.0)
166
- simplecov (0.16.1)
176
+ unicode-display_width (>= 1.4.0, < 1.7)
177
+ ruby-progressbar (1.10.1)
178
+ simplecov (0.18.5)
167
179
  docile (~> 1.1)
168
- json (>= 1.8, < 3)
169
- simplecov-html (~> 0.10.0)
170
- simplecov-console (0.4.2)
180
+ simplecov-html (~> 0.11)
181
+ simplecov-console (0.7.2)
171
182
  ansi
172
- hirb
173
183
  simplecov
174
- simplecov-html (0.10.2)
184
+ terminal-table
185
+ simplecov-html (0.12.2)
175
186
  sprockets (3.7.2)
176
187
  concurrent-ruby (~> 1.0)
177
188
  rack (> 1, < 3)
@@ -179,16 +190,18 @@ GEM
179
190
  actionpack (>= 4.0)
180
191
  activesupport (>= 4.0)
181
192
  sprockets (>= 3.0.0)
182
- sqlite3 (1.4.1)
183
- thor (0.20.3)
193
+ sqlite3 (1.4.2)
194
+ terminal-table (1.8.0)
195
+ unicode-display_width (~> 1.1, >= 1.1.1)
196
+ thor (1.0.1)
184
197
  thread_safe (0.3.6)
185
- tzinfo (1.2.5)
198
+ tzinfo (1.2.7)
186
199
  thread_safe (~> 0.1)
187
- unicode-display_width (1.5.0)
200
+ unicode-display_width (1.6.1)
188
201
  url (0.3.2)
189
- websocket-driver (0.6.5)
202
+ websocket-driver (0.7.1)
190
203
  websocket-extensions (>= 0.1.0)
191
- websocket-extensions (0.1.3)
204
+ websocket-extensions (0.1.4)
192
205
  xpath (3.2.0)
193
206
  nokogiri (~> 1.8)
194
207
 
@@ -206,7 +219,7 @@ DEPENDENCIES
206
219
  database_cleaner
207
220
  factory_bot
208
221
  faker
209
- rails (~> 5.1.0)
222
+ rails (~> 5.2.0)
210
223
  rake
211
224
  ransack
212
225
  rspec
@@ -217,4 +230,4 @@ DEPENDENCIES
217
230
  sqlite3
218
231
 
219
232
  BUNDLED WITH
220
- 2.0.1
233
+ 2.1.4
data/Rakefile CHANGED
@@ -8,6 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
8
8
  task :full_spec do
9
9
  ENV['COVERAGE'] = 'true'
10
10
  ENV['INSPECT_FAILURE'] = 'true'
11
+ ENV['LOGICALLY_EXHAUSTIVE_REQUEST_SPECS'] = 'true'
11
12
  Rake::Task['spec'].invoke
12
13
  end
13
14
 
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
6
  Gem::Specification.new do |spec|
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.name = 'actionset'
9
- spec.version = '0.9.2'
9
+ spec.version = '0.10.0'
10
10
  spec.authors = ['Stephen Margheim']
11
11
  spec.email = ['stephen.margheim@gmail.com']
12
12
 
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'database_cleaner'
33
33
  spec.add_development_dependency 'factory_bot'
34
34
  spec.add_development_dependency 'faker'
35
- spec.add_development_dependency 'rails', '~> 5.1.0'
35
+ spec.add_development_dependency 'rails', '~> 5.2.0'
36
36
  spec.add_development_dependency 'rake'
37
37
  spec.add_development_dependency 'ransack'
38
38
  spec.add_development_dependency 'rspec'
@@ -27,6 +27,10 @@ class ActiveSet
27
27
  @arel_column = arel_column
28
28
  end
29
29
 
30
+ def arel_column_name
31
+ arel_table[@attribute_instruction.attribute].name
32
+ end
33
+
30
34
  def attribute_model
31
35
  return @set.klass if @attribute_instruction.associations_array.empty?
32
36
  return @attribute_model if defined? @attribute_model
@@ -38,14 +42,6 @@ class ActiveSet
38
42
  end
39
43
  end
40
44
 
41
- private
42
-
43
- def arel_type
44
- attribute_model
45
- &.columns_hash[@attribute_instruction.attribute]
46
- &.type
47
- end
48
-
49
45
  def arel_table
50
46
  # This is to work around an bug in ActiveRecord,
51
47
  # where BINARY fields aren't found properly when using
@@ -57,6 +53,14 @@ class ActiveSet
57
53
  end
58
54
  end
59
55
 
56
+ private
57
+
58
+ def arel_type
59
+ attribute_model
60
+ &.columns_hash[@attribute_instruction.attribute]
61
+ &.type
62
+ end
63
+
60
64
  def case_insensitive_operation?
61
65
  @attribute_instruction.case_insensitive? && arel_type.presence_in(%i[string text])
62
66
  end
@@ -15,7 +15,7 @@ class ActiveSet
15
15
  end
16
16
  end
17
17
  BLANK_TRANSFORMER = proc do |type:, **_ctx|
18
- if type.presence_in %i[date float integer]
18
+ if type.presence_in %i[date float integer time datetime boolean]
19
19
  [nil]
20
20
  else
21
21
  Constants::BLANK_VALUES
@@ -34,6 +34,7 @@ class ActiveSet
34
34
  next sql.map { |str| START_MATCHER_TRANSFORMER.call(sql: str, type: type, **ctx) } if sql.respond_to?(:map)
35
35
 
36
36
  str = MATCHER_TRANSFORMER.call(sql: sql, type: type, **ctx)
37
+ next str if ['boolean'].include? type.to_s
37
38
 
38
39
  str + '%'
39
40
  end
@@ -41,6 +42,7 @@ class ActiveSet
41
42
  next sql.map { |str| END_MATCHER_TRANSFORMER.call(sql: str, type: type, **ctx) } if sql.respond_to?(:map)
42
43
 
43
44
  str = MATCHER_TRANSFORMER.call(sql: sql, type: type, **ctx)
45
+ next str if ['boolean'].include? type.to_s
44
46
 
45
47
  '%' + str
46
48
  end
@@ -48,6 +50,7 @@ class ActiveSet
48
50
  next sql.map { |str| CONTAIN_MATCHER_TRANSFORMER.call(sql: str, type: type, **ctx) } if sql.respond_to?(:map)
49
51
 
50
52
  str = MATCHER_TRANSFORMER.call(sql: sql, type: type, **ctx)
53
+ next str if ['boolean'].include? type.to_s
51
54
 
52
55
  '%' + str + '%'
53
56
  end
@@ -54,7 +54,9 @@ class ActiveSet
54
54
  arel_column = set_instruction.arel_column
55
55
  arel_direction = direction_operator(set_instruction.value)
56
56
 
57
- attribute_model.order(nil_sorter_for(arel_column, arel_direction))
57
+ attribute_model.order(Arel.sql(nil_sorter_for(set_instruction.arel_table,
58
+ set_instruction.arel_column_name,
59
+ arel_direction)))
58
60
  .order(arel_column.send(arel_direction))
59
61
  end
60
62
 
@@ -64,14 +66,22 @@ class ActiveSet
64
66
  :asc
65
67
  end
66
68
 
67
- def nil_sorter_for(column, direction)
68
- nil_sorter_operator = if ActiveSet.configuration.on_asc_sort_nils_come == :last
69
- direction == :asc ? :eq : :not_eq
70
- else
71
- direction == :asc ? :not_eq : :eq
72
- end
69
+ def nil_sorter_for(model, column, direction)
70
+ "CASE WHEN #{model.table_name}.#{column} IS NULL #{nil_sorter_then_statement(direction)}"
71
+ end
72
+
73
+ def nil_sorter_then_statement(direction)
74
+ first = 'THEN 0 ELSE 1 END'
75
+ last = 'THEN 1 ELSE 0 END'
76
+ if ActiveSet.configuration.on_asc_sort_nils_come == :last
77
+ return last if direction == :asc
73
78
 
74
- column.send(nil_sorter_operator, nil)
79
+ return first
80
+ else
81
+ return first if direction == :asc
82
+
83
+ return last
84
+ end
75
85
  end
76
86
  end
77
87
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionset
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-07 00:00:00.000000000 Z
11
+ date: 2020-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 5.1.0
145
+ version: 5.2.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 5.1.0
152
+ version: 5.2.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rake
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -332,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
332
  version: '0'
333
333
  requirements: []
334
334
  rubyforge_project:
335
- rubygems_version: 2.6.11
335
+ rubygems_version: 2.6.14.4
336
336
  signing_key:
337
337
  specification_version: 4
338
338
  summary: A toolkit for working with collections.