where_any 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/.gitignore +1 -0
- data/.rubocop.yml +4 -0
- data/Gemfile +0 -5
- data/bin/rspec +1 -1
- data/bin/rubocop +1 -1
- data/lib/where_any/version.rb +1 -1
- data/lib/where_any.rb +18 -2
- data/where_any.gemspec +6 -0
- metadata +73 -4
- data/Gemfile.lock +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2660b55e57253d50a6351dfdefc6d71c799d16f3526dd08eda9a47b5673f6370
|
4
|
+
data.tar.gz: 68c89d9bb75abf508d7ea9acb17651533787c795d1db4342cfabae5fdbe74a88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fe3bed82bfed43c3e564651883fe1bee31f863e38cb3a3e76ebb3d62ff6146c9c91add1dfc707437ecfcd4dcbba7db590f1355c8ec21469d4bcbd39f864b398
|
7
|
+
data.tar.gz: e7e87fde492f824c7d4d4778beb2ee85cc8faf262cf539e68a1e0557875675162ce3429a4caf7afef7c313ca448d3d335d1c53e6d225036fea650ed415c117af
|
data/.github/workflows/main.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/bin/rspec
CHANGED
@@ -15,7 +15,7 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
|
15
15
|
bundle_binstub = File.expand_path('bundle', __dir__)
|
16
16
|
|
17
17
|
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 300)
|
18
|
+
if File.read(bundle_binstub, 300).include?('This file was generated by Bundler')
|
19
19
|
load(bundle_binstub)
|
20
20
|
else
|
21
21
|
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
data/bin/rubocop
CHANGED
@@ -15,7 +15,7 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
|
15
15
|
bundle_binstub = File.expand_path('bundle', __dir__)
|
16
16
|
|
17
17
|
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 300)
|
18
|
+
if File.read(bundle_binstub, 300).include?('This file was generated by Bundler')
|
19
19
|
load(bundle_binstub)
|
20
20
|
else
|
21
21
|
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
data/lib/where_any/version.rb
CHANGED
data/lib/where_any.rb
CHANGED
@@ -42,10 +42,18 @@ module WhereAny
|
|
42
42
|
def where_any(column, values)
|
43
43
|
return none if values.blank?
|
44
44
|
|
45
|
+
if (includes_null = values.include?(nil))
|
46
|
+
values = values.compact
|
47
|
+
return where(column => nil) if values.empty?
|
48
|
+
end
|
49
|
+
|
45
50
|
arel_column = arel_table[column]
|
46
51
|
any_of_values = Arel::Nodes::NamedFunction.new('ANY', [bind_array(column, values)])
|
47
52
|
|
48
|
-
where(arel_column.eq(any_of_values))
|
53
|
+
scope = where(arel_column.eq(any_of_values))
|
54
|
+
scope = scope.or(where(column => nil)) if includes_null
|
55
|
+
|
56
|
+
scope
|
49
57
|
end
|
50
58
|
|
51
59
|
# @param column [String, Symbol]
|
@@ -54,9 +62,17 @@ module WhereAny
|
|
54
62
|
def where_none(column, values)
|
55
63
|
return all if values.blank?
|
56
64
|
|
65
|
+
if (includes_null = values.include?(nil))
|
66
|
+
values = values.compact
|
67
|
+
return where.not(column => nil) if values.empty?
|
68
|
+
end
|
69
|
+
|
57
70
|
arel_column = arel_table[column]
|
58
71
|
all_of_values = Arel::Nodes::NamedFunction.new('ALL', [bind_array(column, values)])
|
59
72
|
|
60
|
-
where(arel_column.not_eq(all_of_values))
|
73
|
+
scope = where(arel_column.not_eq(all_of_values))
|
74
|
+
scope = scope.where.not(column => nil) if includes_null
|
75
|
+
|
76
|
+
scope
|
61
77
|
end
|
62
78
|
end
|
data/where_any.gemspec
CHANGED
@@ -31,4 +31,10 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
# Uncomment to register a new dependency of your gem
|
33
33
|
spec.add_dependency 'activerecord', '>= 5.2.0', '< 8'
|
34
|
+
|
35
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
36
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
37
|
+
spec.add_development_dependency 'rubocop', '~> 1.23'
|
38
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.19'
|
39
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.6'
|
34
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: where_any
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minty Fresh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -30,6 +30,76 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '8'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '13.0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '13.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.10'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.10'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rubocop
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.23'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.23'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rubocop-performance
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.19'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.19'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rubocop-rspec
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2.6'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2.6'
|
33
103
|
description: Postgres ANY() and ALL() expressions for ActiveRecord.
|
34
104
|
email:
|
35
105
|
- 7896757+mintyfresh@users.noreply.github.com
|
@@ -42,7 +112,6 @@ files:
|
|
42
112
|
- ".rspec"
|
43
113
|
- ".rubocop.yml"
|
44
114
|
- Gemfile
|
45
|
-
- Gemfile.lock
|
46
115
|
- README.md
|
47
116
|
- Rakefile
|
48
117
|
- bin/console
|
@@ -74,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
143
|
- !ruby/object:Gem::Version
|
75
144
|
version: '0'
|
76
145
|
requirements: []
|
77
|
-
rubygems_version: 3.
|
146
|
+
rubygems_version: 3.4.13
|
78
147
|
signing_key:
|
79
148
|
specification_version: 4
|
80
149
|
summary: Postgres ANY() and ALL() expressions for ActiveRecord.
|
data/Gemfile.lock
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
where_any (0.1.1)
|
5
|
-
activerecord (>= 5.2.0, < 8)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activemodel (7.0.4)
|
11
|
-
activesupport (= 7.0.4)
|
12
|
-
activerecord (7.0.4)
|
13
|
-
activemodel (= 7.0.4)
|
14
|
-
activesupport (= 7.0.4)
|
15
|
-
activesupport (7.0.4)
|
16
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (>= 1.6, < 2)
|
18
|
-
minitest (>= 5.1)
|
19
|
-
tzinfo (~> 2.0)
|
20
|
-
ast (2.4.2)
|
21
|
-
concurrent-ruby (1.1.10)
|
22
|
-
diff-lcs (1.4.4)
|
23
|
-
i18n (1.12.0)
|
24
|
-
concurrent-ruby (~> 1.0)
|
25
|
-
minitest (5.16.3)
|
26
|
-
parallel (1.21.0)
|
27
|
-
parser (3.0.3.2)
|
28
|
-
ast (~> 2.4.1)
|
29
|
-
rainbow (3.0.0)
|
30
|
-
rake (13.0.6)
|
31
|
-
regexp_parser (2.2.0)
|
32
|
-
rexml (3.2.5)
|
33
|
-
rspec (3.10.0)
|
34
|
-
rspec-core (~> 3.10.0)
|
35
|
-
rspec-expectations (~> 3.10.0)
|
36
|
-
rspec-mocks (~> 3.10.0)
|
37
|
-
rspec-core (3.10.1)
|
38
|
-
rspec-support (~> 3.10.0)
|
39
|
-
rspec-expectations (3.10.1)
|
40
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
-
rspec-support (~> 3.10.0)
|
42
|
-
rspec-mocks (3.10.2)
|
43
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
-
rspec-support (~> 3.10.0)
|
45
|
-
rspec-support (3.10.3)
|
46
|
-
rubocop (1.23.0)
|
47
|
-
parallel (~> 1.10)
|
48
|
-
parser (>= 3.0.0.0)
|
49
|
-
rainbow (>= 2.2.2, < 4.0)
|
50
|
-
regexp_parser (>= 1.8, < 3.0)
|
51
|
-
rexml
|
52
|
-
rubocop-ast (>= 1.12.0, < 2.0)
|
53
|
-
ruby-progressbar (~> 1.7)
|
54
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
55
|
-
rubocop-ast (1.15.0)
|
56
|
-
parser (>= 3.0.1.1)
|
57
|
-
rubocop-rspec (2.6.0)
|
58
|
-
rubocop (~> 1.19)
|
59
|
-
ruby-progressbar (1.11.0)
|
60
|
-
tzinfo (2.0.5)
|
61
|
-
concurrent-ruby (~> 1.0)
|
62
|
-
unicode-display_width (2.1.0)
|
63
|
-
|
64
|
-
PLATFORMS
|
65
|
-
x86_64-linux
|
66
|
-
|
67
|
-
DEPENDENCIES
|
68
|
-
rake (~> 13.0)
|
69
|
-
rspec (~> 3.0)
|
70
|
-
rubocop (~> 1.23)
|
71
|
-
rubocop-rspec (~> 2.6)
|
72
|
-
where_any!
|
73
|
-
|
74
|
-
BUNDLED WITH
|
75
|
-
2.2.17
|