activerecord-setops 0.1.3 → 1.0.0
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 -43
- data/README.md +37 -0
- data/activerecord-setops.gemspec +1 -5
- 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 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70c39529d33485dd3cbcd0820870cdd8d73e2db9d70acab7ca84d4e50f3e539b
|
4
|
+
data.tar.gz: ffacade3e925a20c850be2c25be1a36e2a31d0aebcf81ac7ae9f40b61627f23a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ac1cb5ca6ba34b0851221d54750af0670d995c972ac251e4372aeed4c5789473afbf1fae4561e157bb6192e13eeec915162bd7a3b98b33b727f28531393025e
|
7
|
+
data.tar.gz: 52bffa93df07b8cf7b47d3cec8ca881f8da646955ccf85e8f7b472e03609859895e15137d44868c1c1dd1c5d41699235f195e6a082bb7bfd1e96c0354c67266b
|
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', '>= 5.2'
|
12
|
+
gem 'activesupport', '>= 5.2'
|
13
|
+
gem 'sqlite3', '~> 1.4.2'
|
data/Gemfile.lock
CHANGED
@@ -1,70 +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.
|
21
|
+
activerecord-setops (1.0.0)
|
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.1)
|
26
|
+
activemodel (6.1.1)
|
27
|
+
activesupport (= 6.1.1)
|
28
|
+
activerecord (6.1.1)
|
29
|
+
activemodel (= 6.1.1)
|
30
|
+
activesupport (= 6.1.1)
|
31
|
+
activesupport (6.1.1)
|
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.3)
|
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 (>= 5.2)
|
61
70
|
activerecord-setops!
|
62
|
-
|
63
|
-
|
64
|
-
gen
|
71
|
+
activesupport (>= 5.2)
|
72
|
+
bundler (~> 2.1)
|
73
|
+
contracts-gen!
|
74
|
+
gen-test!
|
65
75
|
rake (~> 13.0)
|
66
76
|
rspec (~> 3.0)
|
67
77
|
sqlite3 (~> 1.4.2)
|
68
78
|
|
69
79
|
BUNDLED WITH
|
70
|
-
|
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,11 +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.0"
|
45
|
-
spec.add_development_dependency "sqlite3", "~> 1.4.2"
|
46
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.
|
4
|
+
version: 1.0.0
|
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-01-21 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,62 +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.0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '5.0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: sqlite3
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 1.4.2
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 1.4.2
|
111
55
|
description: Union, Intersection, and Difference operations for ActiveRecord
|
112
56
|
email:
|
113
57
|
- contact@delonnewman.name
|
@@ -118,6 +62,7 @@ files:
|
|
118
62
|
- ".github/workflows/ruby.yml"
|
119
63
|
- ".gitignore"
|
120
64
|
- ".rspec"
|
65
|
+
- CHANGELOG.md
|
121
66
|
- Gemfile
|
122
67
|
- Gemfile.lock
|
123
68
|
- LICENSE.txt
|
@@ -126,6 +71,7 @@ files:
|
|
126
71
|
- activerecord-setops.gemspec
|
127
72
|
- lib/active_record/setops.rb
|
128
73
|
- lib/active_record/setops/version.rb
|
74
|
+
- lib/activerecord-setops.rb
|
129
75
|
homepage: https://github.com/delonnewman/activerecord-setops#readme
|
130
76
|
licenses:
|
131
77
|
- MIT
|
@@ -135,7 +81,7 @@ metadata:
|
|
135
81
|
source_code_uri: https://github.com/delonnewman/activerecord-setops
|
136
82
|
changelog_uri: https://github.com/delonnewman/activerecord-setops#changelog
|
137
83
|
documentation_uri: https://www.rubydoc.info/gems/activerecord-setops
|
138
|
-
post_install_message:
|
84
|
+
post_install_message:
|
139
85
|
rdoc_options: []
|
140
86
|
require_paths:
|
141
87
|
- lib
|
@@ -150,8 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
96
|
- !ruby/object:Gem::Version
|
151
97
|
version: '0'
|
152
98
|
requirements: []
|
153
|
-
rubygems_version: 3.
|
154
|
-
signing_key:
|
99
|
+
rubygems_version: 3.2.3
|
100
|
+
signing_key:
|
155
101
|
specification_version: 4
|
156
102
|
summary: Set operations for ActiveRecord
|
157
103
|
test_files: []
|