arel_toolkit 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +8 -6
- data/arel_toolkit.gemspec +1 -1
- data/gemfiles/active_record_6.gemfile.lock +4 -4
- data/gemfiles/arel_gems.gemfile.lock +4 -4
- data/gemfiles/default.gemfile.lock +4 -4
- data/lib/arel/extensions/delete_statement.rb +19 -14
- data/lib/arel/extensions/update_statement.rb +8 -22
- data/lib/arel_toolkit/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a61ce95fcd49278974796940a1c783448978fef075e83157ee95e2e7fce1d42d
|
4
|
+
data.tar.gz: bb0431b90908d911f52b0d3b02c1acac0f0223274b73aa53305cebe1bdb77bd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa03c27964e900c04f5af3178c7744eb8ef08a64537c1dc0594262cf4e5fffb1e0c5907ef891048bfa224f2d39f31fedc78aa7a8e0f03294af8193dc8c1e63c3
|
7
|
+
data.tar.gz: a2e1849d25ddaee84720b1ed10045a9fc6e0b926d555557f99c3498bdecb02de0eda06fb4a04f1f9a72a4f9b945a089b3ece8059cd04ad42f45d843446244b15
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.4.4](https://github.com/mvgijssel/arel_toolkit/tree/v0.4.4) (2021-02-11)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/mvgijssel/arel_toolkit/compare/v0.4.3...v0.4.4)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Bump nokogiri from 1.10.8 to 1.11.1 [\#171](https://github.com/mvgijssel/arel_toolkit/pull/171) ([dependabot[bot]](https://github.com/apps/dependabot))
|
10
|
+
|
11
|
+
**Fixed bugs:**
|
12
|
+
|
13
|
+
- Fix conditional update and delete statements in Rails 6 [\#170](https://github.com/mvgijssel/arel_toolkit/pull/170) ([mvgijssel](https://github.com/mvgijssel))
|
14
|
+
|
3
15
|
## [v0.4.3](https://github.com/mvgijssel/arel_toolkit/tree/v0.4.3) (2020-11-09)
|
4
16
|
|
5
17
|
[Full Changelog](https://github.com/mvgijssel/arel_toolkit/compare/v0.4.2...v0.4.3)
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
arel_toolkit (0.4.
|
4
|
+
arel_toolkit (0.4.4)
|
5
5
|
activerecord
|
6
6
|
pg (~> 1.1.4)
|
7
|
-
pg_query (~> 1.
|
7
|
+
pg_query (~> 1.3)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -88,13 +88,14 @@ GEM
|
|
88
88
|
lumberjack (1.0.13)
|
89
89
|
memory_profiler (0.9.14)
|
90
90
|
method_source (0.9.2)
|
91
|
-
mini_portile2 (2.
|
91
|
+
mini_portile2 (2.5.0)
|
92
92
|
minitest (5.14.1)
|
93
93
|
multi_json (1.14.1)
|
94
94
|
multipart-post (2.1.1)
|
95
95
|
nenv (0.3.0)
|
96
|
-
nokogiri (1.
|
97
|
-
mini_portile2 (~> 2.
|
96
|
+
nokogiri (1.11.1)
|
97
|
+
mini_portile2 (~> 2.5.0)
|
98
|
+
racc (~> 1.4)
|
98
99
|
notiffany (0.1.1)
|
99
100
|
nenv (~> 0.1)
|
100
101
|
shellany (~> 0.0)
|
@@ -104,7 +105,7 @@ GEM
|
|
104
105
|
parser (2.6.3.0)
|
105
106
|
ast (~> 2.4.0)
|
106
107
|
pg (1.1.4)
|
107
|
-
pg_query (1.
|
108
|
+
pg_query (1.3.0)
|
108
109
|
pry (0.12.2)
|
109
110
|
coderay (~> 1.1.0)
|
110
111
|
method_source (~> 0.9.0)
|
@@ -123,6 +124,7 @@ GEM
|
|
123
124
|
binding_of_caller (>= 0.7)
|
124
125
|
pry (>= 0.9.11)
|
125
126
|
public_suffix (4.0.1)
|
127
|
+
racc (1.5.2)
|
126
128
|
rainbow (3.0.0)
|
127
129
|
rake (13.0.1)
|
128
130
|
rake-compiler (1.0.7)
|
data/arel_toolkit.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_dependency 'activerecord'
|
29
29
|
spec.add_dependency 'pg', '~> 1.1.4'
|
30
|
-
spec.add_dependency 'pg_query', '~> 1.
|
30
|
+
spec.add_dependency 'pg_query', '~> 1.3'
|
31
31
|
|
32
32
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
33
33
|
spec.add_development_dependency 'dpl', '~> 1.10.11'
|
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
arel_toolkit (0.4.
|
4
|
+
arel_toolkit (0.4.3)
|
5
5
|
activerecord
|
6
6
|
pg (~> 1.1.4)
|
7
|
-
pg_query (~> 1.
|
7
|
+
pg_query (~> 1.3)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -104,7 +104,7 @@ GEM
|
|
104
104
|
parser (2.7.2.0)
|
105
105
|
ast (~> 2.4.1)
|
106
106
|
pg (1.1.4)
|
107
|
-
pg_query (1.
|
107
|
+
pg_query (1.3.0)
|
108
108
|
pry (0.12.2)
|
109
109
|
coderay (~> 1.1.0)
|
110
110
|
method_source (~> 0.9.0)
|
@@ -207,4 +207,4 @@ DEPENDENCIES
|
|
207
207
|
stackprof (~> 0.2)
|
208
208
|
|
209
209
|
BUNDLED WITH
|
210
|
-
2.
|
210
|
+
2.1.4
|
@@ -31,10 +31,10 @@ GIT
|
|
31
31
|
PATH
|
32
32
|
remote: ..
|
33
33
|
specs:
|
34
|
-
arel_toolkit (0.4.
|
34
|
+
arel_toolkit (0.4.3)
|
35
35
|
activerecord
|
36
36
|
pg (~> 1.1.4)
|
37
|
-
pg_query (~> 1.
|
37
|
+
pg_query (~> 1.3)
|
38
38
|
|
39
39
|
GEM
|
40
40
|
remote: https://rubygems.org/
|
@@ -154,7 +154,7 @@ GEM
|
|
154
154
|
ast (~> 2.4.0)
|
155
155
|
pg (1.1.4)
|
156
156
|
pg_array_parser (0.0.9)
|
157
|
-
pg_query (1.
|
157
|
+
pg_query (1.3.0)
|
158
158
|
pry (0.12.2)
|
159
159
|
coderay (~> 1.1.0)
|
160
160
|
method_source (~> 0.9.0)
|
@@ -281,4 +281,4 @@ DEPENDENCIES
|
|
281
281
|
stackprof (~> 0.2)
|
282
282
|
|
283
283
|
BUNDLED WITH
|
284
|
-
2.
|
284
|
+
2.1.4
|
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
arel_toolkit (0.4.
|
4
|
+
arel_toolkit (0.4.3)
|
5
5
|
activerecord
|
6
6
|
pg (~> 1.1.4)
|
7
|
-
pg_query (~> 1.
|
7
|
+
pg_query (~> 1.3)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -104,7 +104,7 @@ GEM
|
|
104
104
|
parser (2.6.3.0)
|
105
105
|
ast (~> 2.4.0)
|
106
106
|
pg (1.1.4)
|
107
|
-
pg_query (1.
|
107
|
+
pg_query (1.3.0)
|
108
108
|
pry (0.12.2)
|
109
109
|
coderay (~> 1.1.0)
|
110
110
|
method_source (~> 0.9.0)
|
@@ -205,4 +205,4 @@ DEPENDENCIES
|
|
205
205
|
stackprof (~> 0.2)
|
206
206
|
|
207
207
|
BUNDLED WITH
|
208
|
-
2.
|
208
|
+
2.1.4
|
@@ -9,11 +9,14 @@ module Arel
|
|
9
9
|
attr_accessor :using
|
10
10
|
attr_accessor :with
|
11
11
|
attr_accessor :returning
|
12
|
+
attr_accessor :orders
|
12
13
|
|
13
14
|
def initialize(relation = nil, wheres = [])
|
14
15
|
super
|
15
16
|
|
16
17
|
@returning = []
|
18
|
+
@orders = []
|
19
|
+
@using = []
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
@@ -30,24 +33,26 @@ module Arel
|
|
30
33
|
collector << ' '
|
31
34
|
end
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
if o.using
|
37
|
-
collector << ' USING '
|
38
|
-
collector = inject_join o.using, collector, ', '
|
39
|
-
end
|
36
|
+
if Gem.loaded_specs['activerecord'].version >= Gem::Version.new('6.0.0')
|
37
|
+
o = prepare_delete_statement(o)
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
if has_join_sources?(o)
|
40
|
+
collector << 'DELETE '
|
41
|
+
visit o.relation.left, collector
|
42
|
+
collector << ' FROM '
|
43
|
+
else
|
44
|
+
collector << 'DELETE FROM '
|
45
|
+
end
|
46
|
+
else
|
47
|
+
collector << 'DELETE FROM '
|
44
48
|
end
|
45
49
|
|
46
|
-
|
47
|
-
collector << ' RETURNING '
|
48
|
-
collector = inject_join o.returning, collector, ', '
|
49
|
-
end
|
50
|
+
collector = visit o.relation, collector
|
50
51
|
|
52
|
+
collect_nodes_for o.using, collector, ' USING ', ', '
|
53
|
+
collect_nodes_for o.wheres, collector, ' WHERE ', ' AND '
|
54
|
+
collect_nodes_for o.returning, collector, ' RETURNING ', ', '
|
55
|
+
collect_nodes_for o.orders, collector, ' ORDER BY '
|
51
56
|
maybe_visit o.limit, collector
|
52
57
|
end
|
53
58
|
# rubocop:enable Metrics/AbcSize
|
@@ -24,16 +24,17 @@ module Arel
|
|
24
24
|
|
25
25
|
module Visitors
|
26
26
|
class ToSql
|
27
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
28
27
|
# rubocop:disable Metrics/AbcSize
|
29
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
30
28
|
def visit_Arel_Nodes_UpdateStatement(o, collector)
|
31
29
|
if o.with
|
32
30
|
collector = visit o.with, collector
|
33
31
|
collector << ' '
|
34
32
|
end
|
35
33
|
|
36
|
-
wheres = if
|
34
|
+
wheres = if Gem.loaded_specs['activerecord'].version >= Gem::Version.new('6.0.0')
|
35
|
+
o = prepare_update_statement(o)
|
36
|
+
o.wheres
|
37
|
+
elsif o.orders.empty? && o.limit.nil?
|
37
38
|
o.wheres
|
38
39
|
else
|
39
40
|
[Nodes::In.new(o.key, [build_subselect(o.key, o)])]
|
@@ -41,31 +42,16 @@ module Arel
|
|
41
42
|
|
42
43
|
collector << 'UPDATE '
|
43
44
|
collector = visit o.relation, collector
|
44
|
-
unless o.values.empty?
|
45
|
-
collector << ' SET '
|
46
|
-
collector = inject_join o.values, collector, ', '
|
47
|
-
end
|
48
|
-
|
49
|
-
unless o.froms.empty?
|
50
|
-
collector << ' FROM '
|
51
|
-
collector = inject_join o.froms, collector, ', '
|
52
|
-
end
|
53
45
|
|
54
|
-
|
55
|
-
|
56
|
-
collector = inject_join wheres, collector, ' AND '
|
57
|
-
end
|
46
|
+
collect_nodes_for o.values, collector, ' SET '
|
47
|
+
collect_nodes_for o.froms, collector, ' FROM ', ', '
|
58
48
|
|
59
|
-
|
60
|
-
|
61
|
-
collector = inject_join o.returning, collector, ', '
|
62
|
-
end
|
49
|
+
collect_nodes_for wheres, collector, ' WHERE ', ' AND '
|
50
|
+
collect_nodes_for o.returning, collector, ' RETURNING ', ', '
|
63
51
|
|
64
52
|
collector
|
65
53
|
end
|
66
54
|
# rubocop:enable Metrics/AbcSize
|
67
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
68
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
69
55
|
end
|
70
56
|
|
71
57
|
class Dot
|
data/lib/arel_toolkit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arel_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- maarten
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: '1.3'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: '1.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|