activerecord-setops 0.1.4 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +25 -11
- data/CHANGELOG.md +14 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +53 -44
- data/README.md +37 -0
- data/activerecord-setops.gemspec +1 -6
- data/lib/active_record/setops.rb +3 -4
- data/lib/active_record/setops/version.rb +1 -1
- data/lib/activerecord-setops.rb +1 -0
- metadata +10 -90
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74a900ef6d935b4b3cfb29f33cc5d4eeac0de51ea13f552d23401e8de845d73c
|
4
|
+
data.tar.gz: e4325d04937f9555d669d55fc90f487bbd85d0cf32a0cd1fc3585ffa2f91ab0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3d7d3ae1244d66744308e410dc4fe4f477da96c1eb191c7477305a4543c9f0e6354360db433efe023badd260ba8269941070b82108ff1279d4ee4a7f0e79312
|
7
|
+
data.tar.gz: d9796791c1efb1aa3edd8fcbc6b8a32ab1dadaf168d125aec9708c67ffea6c2e484d6a7222ba053f100965ac363ebdb6fec4b8746c2dc2299c14d5ef13b03efd
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,21 +1,35 @@
|
|
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
|
+
|
1
8
|
name: Ruby
|
2
9
|
|
3
|
-
on:
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
4
15
|
|
5
16
|
jobs:
|
6
|
-
|
17
|
+
test:
|
7
18
|
|
8
19
|
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.6', '2.7', '3.0']
|
9
23
|
|
10
24
|
steps:
|
11
25
|
- uses: actions/checkout@v2
|
12
|
-
- name: Set up Ruby
|
13
|
-
|
26
|
+
- name: Set up Ruby
|
27
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
+
# uses: ruby/setup-ruby@v1
|
30
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
14
31
|
with:
|
15
|
-
ruby-version:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
gem install bundler
|
20
|
-
bundle install --jobs 4 --retry 3
|
21
|
-
bundle exec rake
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
34
|
+
- name: Run tests
|
35
|
+
run: bundle exec rake
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
@@ -4,3 +4,10 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in activerecord-setoperations.gemspec
|
6
6
|
gemspec
|
7
|
+
|
8
|
+
gem 'gen-test', github: 'delonnewman/gen-test'
|
9
|
+
gem 'contracts-gen', github: 'delonnewman/contracts-gen'
|
10
|
+
|
11
|
+
gem 'activerecord', '~> 6.1.2'
|
12
|
+
gem 'activesupport', '~> 6.1.2'
|
13
|
+
gem 'sqlite3', '~> 1.4.2'
|
data/Gemfile.lock
CHANGED
@@ -1,71 +1,80 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/delonnewman/contracts-gen
|
3
|
+
revision: 48f5d08cf2df0f2f21df887b77022b5793c7017e
|
4
|
+
specs:
|
5
|
+
contracts-gen (0.2.0)
|
6
|
+
contracts (~> 0.16.0)
|
7
|
+
faker (~> 1.9.6)
|
8
|
+
gen-test (~> 0.2)
|
9
|
+
|
10
|
+
GIT
|
11
|
+
remote: https://github.com/delonnewman/gen-test
|
12
|
+
revision: 3279faed9301ac6f7accf137d58ff6dae124b834
|
13
|
+
specs:
|
14
|
+
gen-test (0.2.0)
|
15
|
+
faker (~> 1.9.6)
|
16
|
+
regexp-examples (~> 1.5.0)
|
17
|
+
|
1
18
|
PATH
|
2
19
|
remote: .
|
3
20
|
specs:
|
4
|
-
activerecord-setops (0.1
|
21
|
+
activerecord-setops (1.0.1)
|
5
22
|
|
6
23
|
GEM
|
7
24
|
remote: https://rubygems.org/
|
8
25
|
specs:
|
9
|
-
activemodel (
|
10
|
-
activesupport (=
|
11
|
-
activerecord (
|
12
|
-
activemodel (=
|
13
|
-
activesupport (=
|
14
|
-
|
15
|
-
activesupport (5.2.4.3)
|
26
|
+
activemodel (6.1.3)
|
27
|
+
activesupport (= 6.1.3)
|
28
|
+
activerecord (6.1.3)
|
29
|
+
activemodel (= 6.1.3)
|
30
|
+
activesupport (= 6.1.3)
|
31
|
+
activesupport (6.1.3)
|
16
32
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (>=
|
18
|
-
minitest (
|
19
|
-
tzinfo (~>
|
20
|
-
|
21
|
-
concurrent-ruby (1.1.
|
33
|
+
i18n (>= 1.6, < 2)
|
34
|
+
minitest (>= 5.1)
|
35
|
+
tzinfo (~> 2.0)
|
36
|
+
zeitwerk (~> 2.3)
|
37
|
+
concurrent-ruby (1.1.8)
|
22
38
|
contracts (0.16.0)
|
23
|
-
|
24
|
-
contracts (~> 0.16.0)
|
25
|
-
faker (~> 1.9.6)
|
26
|
-
gen-test (~> 0.1.0)
|
27
|
-
diff-lcs (1.3)
|
39
|
+
diff-lcs (1.4.4)
|
28
40
|
faker (1.9.6)
|
29
41
|
i18n (>= 0.7)
|
30
|
-
|
31
|
-
faker (~> 1.9.6)
|
32
|
-
regexp-examples (~> 1.5.0)
|
33
|
-
i18n (1.8.2)
|
42
|
+
i18n (1.8.7)
|
34
43
|
concurrent-ruby (~> 1.0)
|
35
|
-
minitest (5.14.
|
36
|
-
rake (13.0.
|
44
|
+
minitest (5.14.4)
|
45
|
+
rake (13.0.3)
|
37
46
|
regexp-examples (1.5.1)
|
38
|
-
rspec (3.
|
39
|
-
rspec-core (~> 3.
|
40
|
-
rspec-expectations (~> 3.
|
41
|
-
rspec-mocks (~> 3.
|
42
|
-
rspec-core (3.
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-expectations (3.
|
47
|
+
rspec (3.10.0)
|
48
|
+
rspec-core (~> 3.10.0)
|
49
|
+
rspec-expectations (~> 3.10.0)
|
50
|
+
rspec-mocks (~> 3.10.0)
|
51
|
+
rspec-core (3.10.1)
|
52
|
+
rspec-support (~> 3.10.0)
|
53
|
+
rspec-expectations (3.10.1)
|
45
54
|
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
-
rspec-support (~> 3.
|
47
|
-
rspec-mocks (3.
|
55
|
+
rspec-support (~> 3.10.0)
|
56
|
+
rspec-mocks (3.10.1)
|
48
57
|
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.
|
50
|
-
rspec-support (3.
|
58
|
+
rspec-support (~> 3.10.0)
|
59
|
+
rspec-support (3.10.1)
|
51
60
|
sqlite3 (1.4.2)
|
52
|
-
|
53
|
-
|
54
|
-
|
61
|
+
tzinfo (2.0.4)
|
62
|
+
concurrent-ruby (~> 1.0)
|
63
|
+
zeitwerk (2.4.2)
|
55
64
|
|
56
65
|
PLATFORMS
|
57
66
|
ruby
|
58
67
|
|
59
68
|
DEPENDENCIES
|
60
|
-
activerecord (
|
69
|
+
activerecord (~> 6.1.2)
|
61
70
|
activerecord-setops!
|
62
|
-
activesupport (
|
63
|
-
bundler (~> 1
|
64
|
-
contracts-gen
|
65
|
-
gen-test
|
71
|
+
activesupport (~> 6.1.2)
|
72
|
+
bundler (~> 2.1)
|
73
|
+
contracts-gen!
|
74
|
+
gen-test!
|
66
75
|
rake (~> 13.0)
|
67
76
|
rspec (~> 3.0)
|
68
77
|
sqlite3 (~> 1.4.2)
|
69
78
|
|
70
79
|
BUNDLED WITH
|
71
|
-
|
80
|
+
2.2.3
|
data/README.md
CHANGED
@@ -38,7 +38,44 @@ Or install it yourself as:
|
|
38
38
|
|
39
39
|
$ gem install activerecord-setops
|
40
40
|
|
41
|
+
# Non-Installation
|
42
|
+
|
43
|
+
If you'd like the functionality, but would prefer to avoid yet another dependency, please fill free to paste the following code into your nearest lib directory, I'm certain it's not perfect but it has been [tested](spec/active_record/setops_spec.rb) with Rails 5, and is being used in production.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
module ActiveRecord
|
47
|
+
class Relation
|
48
|
+
def union(other)
|
49
|
+
binary_operation(Arel::Nodes::Union, other)
|
50
|
+
end
|
51
|
+
alias | union
|
52
|
+
|
53
|
+
def union_all(other)
|
54
|
+
binary_operation(Arel::Nodes::UnionAll, other)
|
55
|
+
end
|
56
|
+
alias + union_all
|
57
|
+
|
58
|
+
def intersect(other)
|
59
|
+
binary_operation(Arel::Nodes::Intersect, other)
|
60
|
+
end
|
61
|
+
alias & intersect
|
62
|
+
|
63
|
+
def difference(other)
|
64
|
+
binary_operation(Arel::Nodes::Except, other)
|
65
|
+
end
|
66
|
+
alias - difference
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def binary_operation(op_class, other)
|
71
|
+
@klass.unscoped.from(Arel::Nodes::TableAlias.new(op_class.new(self.arel.ast, other.arel.ast), @klass.arel_table.name))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
41
77
|
# See Also
|
42
78
|
|
43
79
|
- [Sequel](http://sequel.jeremyevans.net)
|
44
80
|
- [SQL Set Operations](https://en.wikipedia.org/wiki/Set_operations_(SQL))
|
81
|
+
- [active_record_union](https://github.com/brianhempel/active_record_union)
|
data/activerecord-setops.gemspec
CHANGED
@@ -36,12 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
37
|
spec.require_paths = ["lib"]
|
38
38
|
|
39
|
-
spec.add_development_dependency "bundler", "~> 1
|
39
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
40
40
|
spec.add_development_dependency "rake", "~> 13.0"
|
41
41
|
spec.add_development_dependency "rspec", "~> 3.0"
|
42
|
-
spec.add_development_dependency "gen-test", "~> 0.1.1"
|
43
|
-
spec.add_development_dependency "contracts-gen", "~> 0.1.1"
|
44
|
-
spec.add_development_dependency "activerecord", [">= 5.2.4.3", "< 6"]
|
45
|
-
spec.add_development_dependency "activesupport", [">= 5.2.4.3", "< 6"]
|
46
|
-
spec.add_development_dependency "sqlite3", "~> 1.4.2"
|
47
42
|
end
|
data/lib/active_record/setops.rb
CHANGED
@@ -8,22 +8,21 @@ module ActiveRecord
|
|
8
8
|
binary_operation(Arel::Nodes::Union, other)
|
9
9
|
end
|
10
10
|
alias | union
|
11
|
-
alias + union
|
12
11
|
|
13
12
|
def union_all(other)
|
14
13
|
binary_operation(Arel::Nodes::UnionAll, other)
|
15
14
|
end
|
15
|
+
alias + union_all
|
16
16
|
|
17
17
|
def intersect(other)
|
18
18
|
binary_operation(Arel::Nodes::Intersect, other)
|
19
19
|
end
|
20
20
|
alias & intersect
|
21
21
|
|
22
|
-
def
|
22
|
+
def difference(other)
|
23
23
|
binary_operation(Arel::Nodes::Except, other)
|
24
24
|
end
|
25
|
-
alias difference
|
26
|
-
alias - except
|
25
|
+
alias - difference
|
27
26
|
|
28
27
|
private
|
29
28
|
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'active_record/setops'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-setops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Delon Newman
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,88 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: gen-test
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.1
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.1
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: contracts-gen
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 0.1.1
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 0.1.1
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: activerecord
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 5.2.4.3
|
90
|
-
- - "<"
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: '6'
|
93
|
-
type: :development
|
94
|
-
prerelease: false
|
95
|
-
version_requirements: !ruby/object:Gem::Requirement
|
96
|
-
requirements:
|
97
|
-
- - ">="
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: 5.2.4.3
|
100
|
-
- - "<"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '6'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: activesupport
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - ">="
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 5.2.4.3
|
110
|
-
- - "<"
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: '6'
|
113
|
-
type: :development
|
114
|
-
prerelease: false
|
115
|
-
version_requirements: !ruby/object:Gem::Requirement
|
116
|
-
requirements:
|
117
|
-
- - ">="
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version: 5.2.4.3
|
120
|
-
- - "<"
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: '6'
|
123
|
-
- !ruby/object:Gem::Dependency
|
124
|
-
name: sqlite3
|
125
|
-
requirement: !ruby/object:Gem::Requirement
|
126
|
-
requirements:
|
127
|
-
- - "~>"
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version: 1.4.2
|
130
|
-
type: :development
|
131
|
-
prerelease: false
|
132
|
-
version_requirements: !ruby/object:Gem::Requirement
|
133
|
-
requirements:
|
134
|
-
- - "~>"
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version: 1.4.2
|
137
55
|
description: Union, Intersection, and Difference operations for ActiveRecord
|
138
56
|
email:
|
139
57
|
- contact@delonnewman.name
|
@@ -144,6 +62,7 @@ files:
|
|
144
62
|
- ".github/workflows/ruby.yml"
|
145
63
|
- ".gitignore"
|
146
64
|
- ".rspec"
|
65
|
+
- CHANGELOG.md
|
147
66
|
- Gemfile
|
148
67
|
- Gemfile.lock
|
149
68
|
- LICENSE.txt
|
@@ -152,6 +71,7 @@ files:
|
|
152
71
|
- activerecord-setops.gemspec
|
153
72
|
- lib/active_record/setops.rb
|
154
73
|
- lib/active_record/setops/version.rb
|
74
|
+
- lib/activerecord-setops.rb
|
155
75
|
homepage: https://github.com/delonnewman/activerecord-setops#readme
|
156
76
|
licenses:
|
157
77
|
- MIT
|
@@ -161,7 +81,7 @@ metadata:
|
|
161
81
|
source_code_uri: https://github.com/delonnewman/activerecord-setops
|
162
82
|
changelog_uri: https://github.com/delonnewman/activerecord-setops#changelog
|
163
83
|
documentation_uri: https://www.rubydoc.info/gems/activerecord-setops
|
164
|
-
post_install_message:
|
84
|
+
post_install_message:
|
165
85
|
rdoc_options: []
|
166
86
|
require_paths:
|
167
87
|
- lib
|
@@ -176,8 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
96
|
- !ruby/object:Gem::Version
|
177
97
|
version: '0'
|
178
98
|
requirements: []
|
179
|
-
rubygems_version: 3.
|
180
|
-
signing_key:
|
99
|
+
rubygems_version: 3.1.4
|
100
|
+
signing_key:
|
181
101
|
specification_version: 4
|
182
102
|
summary: Set operations for ActiveRecord
|
183
103
|
test_files: []
|