arel_toolkit 0.4.3 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/coverage.yml +48 -0
- data/.github/workflows/test.yml +68 -0
- data/.gitignore +3 -1
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/Appraisals +4 -0
- data/CHANGELOG.md +49 -3
- data/Gemfile.lock +134 -84
- data/README.md +20 -3
- data/arel_toolkit.gemspec +3 -5
- data/bin/console +2 -1
- data/bin/setup +23 -2
- data/docker-compose.yml +11 -0
- data/gemfiles/active_record_6.gemfile +3 -3
- data/gemfiles/active_record_6.gemfile.lock +9 -7
- data/gemfiles/active_record_6_1.gemfile +7 -0
- data/gemfiles/active_record_6_1.gemfile.lock +263 -0
- data/gemfiles/arel_gems.gemfile.lock +9 -7
- data/gemfiles/default.gemfile.lock +9 -7
- data/lib/arel/enhance/context_enhancer/arel_table.rb +20 -0
- data/lib/arel/enhance/node.rb +20 -12
- data/lib/arel/enhance/visitor.rb +1 -1
- data/lib/arel/enhance.rb +2 -2
- data/lib/arel/extensions/conflict.rb +3 -3
- data/lib/arel/extensions/delete_statement.rb +19 -14
- data/lib/arel/extensions/infer.rb +2 -2
- data/lib/arel/extensions/insert_statement.rb +3 -3
- data/lib/arel/extensions/overlaps.rb +7 -1
- data/lib/arel/extensions/table.rb +7 -2
- data/lib/arel/extensions/transaction.rb +9 -9
- data/lib/arel/extensions/tree_manager.rb +0 -5
- data/lib/arel/extensions/update_statement.rb +8 -22
- data/lib/arel/sql_to_arel/pg_query_visitor/frame_options.rb +37 -5
- data/lib/arel/sql_to_arel/pg_query_visitor.rb +430 -521
- data/lib/arel/transformer/prefix_schema_name.rb +5 -3
- data/lib/arel/transformer.rb +0 -1
- data/lib/arel_toolkit/version.rb +1 -1
- metadata +15 -12
- data/.github/workflows/develop.yml +0 -90
- data/.github/workflows/master.yml +0 -67
- data/lib/arel/transformer/remove_active_record_info.rb +0 -40
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
arel_toolkit (0.4.
|
5
|
-
activerecord
|
4
|
+
arel_toolkit (0.4.7)
|
5
|
+
activerecord (>= 5.0.0)
|
6
6
|
pg (~> 1.1.4)
|
7
|
-
pg_query (~>
|
7
|
+
pg_query (~> 2.1)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
addressable (2.7.0)
|
24
24
|
public_suffix (>= 2.0.2, < 5.0)
|
25
25
|
ansi (1.5.0)
|
26
|
-
appraisal (2.
|
26
|
+
appraisal (2.4.1)
|
27
27
|
bundler
|
28
28
|
rake
|
29
29
|
thor (>= 0.14.0)
|
@@ -55,6 +55,7 @@ GEM
|
|
55
55
|
rainbow (>= 2.2.1)
|
56
56
|
rake (>= 10.0)
|
57
57
|
retriable (~> 3.0)
|
58
|
+
google-protobuf (3.19.4-x86_64-darwin)
|
58
59
|
guard (2.16.2)
|
59
60
|
formatador (>= 0.2.4)
|
60
61
|
listen (>= 2.7, < 4.0)
|
@@ -104,7 +105,8 @@ GEM
|
|
104
105
|
parser (2.7.2.0)
|
105
106
|
ast (~> 2.4.1)
|
106
107
|
pg (1.1.4)
|
107
|
-
pg_query (1.
|
108
|
+
pg_query (2.1.3)
|
109
|
+
google-protobuf (>= 3.19.2)
|
108
110
|
pry (0.12.2)
|
109
111
|
coderay (~> 1.1.0)
|
110
112
|
method_source (~> 0.9.0)
|
@@ -180,7 +182,7 @@ PLATFORMS
|
|
180
182
|
|
181
183
|
DEPENDENCIES
|
182
184
|
activerecord (~> 6.0.0)
|
183
|
-
appraisal (~> 2.
|
185
|
+
appraisal (~> 2.4.1)
|
184
186
|
approvals (~> 0.0.24)
|
185
187
|
arel_toolkit!
|
186
188
|
bundler (~> 2.0)
|
@@ -207,4 +209,4 @@ DEPENDENCIES
|
|
207
209
|
stackprof (~> 0.2)
|
208
210
|
|
209
211
|
BUNDLED WITH
|
210
|
-
2.
|
212
|
+
2.3.6
|
@@ -0,0 +1,263 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
arel_toolkit (0.4.7)
|
5
|
+
activerecord (>= 5.0.0)
|
6
|
+
pg (~> 1.1.4)
|
7
|
+
pg_query (~> 2.1)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activemodel (6.1.4.1)
|
13
|
+
activesupport (= 6.1.4.1)
|
14
|
+
activerecord (6.1.4.1)
|
15
|
+
activemodel (= 6.1.4.1)
|
16
|
+
activesupport (= 6.1.4.1)
|
17
|
+
activesupport (6.1.4.1)
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
|
+
i18n (>= 1.6, < 2)
|
20
|
+
minitest (>= 5.1)
|
21
|
+
tzinfo (~> 2.0)
|
22
|
+
zeitwerk (~> 2.3)
|
23
|
+
addressable (2.8.0)
|
24
|
+
public_suffix (>= 2.0.2, < 5.0)
|
25
|
+
ansi (1.5.0)
|
26
|
+
appraisal (2.4.1)
|
27
|
+
bundler
|
28
|
+
rake
|
29
|
+
thor (>= 0.14.0)
|
30
|
+
approvals (0.0.25)
|
31
|
+
nokogiri (~> 1.8)
|
32
|
+
thor (~> 1.0)
|
33
|
+
ast (2.4.2)
|
34
|
+
async (1.30.1)
|
35
|
+
console (~> 1.10)
|
36
|
+
nio4r (~> 2.3)
|
37
|
+
timers (~> 4.1)
|
38
|
+
async-http (0.56.5)
|
39
|
+
async (>= 1.25)
|
40
|
+
async-io (>= 1.28)
|
41
|
+
async-pool (>= 0.2)
|
42
|
+
protocol-http (~> 0.22.0)
|
43
|
+
protocol-http1 (~> 0.14.0)
|
44
|
+
protocol-http2 (~> 0.14.0)
|
45
|
+
async-http-faraday (0.11.0)
|
46
|
+
async-http (~> 0.42)
|
47
|
+
faraday
|
48
|
+
async-io (1.32.2)
|
49
|
+
async
|
50
|
+
async-pool (0.3.8)
|
51
|
+
async (>= 1.25)
|
52
|
+
binding_of_caller (1.0.0)
|
53
|
+
debug_inspector (>= 0.0.1)
|
54
|
+
coderay (1.1.3)
|
55
|
+
concurrent-ruby (1.1.9)
|
56
|
+
console (1.13.1)
|
57
|
+
fiber-local
|
58
|
+
database_cleaner (1.7.0)
|
59
|
+
debug_inspector (1.1.0)
|
60
|
+
diff-lcs (1.4.4)
|
61
|
+
docile (1.4.0)
|
62
|
+
dpl (1.10.16)
|
63
|
+
faraday (1.8.0)
|
64
|
+
faraday-em_http (~> 1.0)
|
65
|
+
faraday-em_synchrony (~> 1.0)
|
66
|
+
faraday-excon (~> 1.1)
|
67
|
+
faraday-httpclient (~> 1.0.1)
|
68
|
+
faraday-net_http (~> 1.0)
|
69
|
+
faraday-net_http_persistent (~> 1.1)
|
70
|
+
faraday-patron (~> 1.0)
|
71
|
+
faraday-rack (~> 1.0)
|
72
|
+
multipart-post (>= 1.2, < 3)
|
73
|
+
ruby2_keywords (>= 0.0.4)
|
74
|
+
faraday-em_http (1.0.0)
|
75
|
+
faraday-em_synchrony (1.0.0)
|
76
|
+
faraday-excon (1.1.0)
|
77
|
+
faraday-http-cache (2.2.0)
|
78
|
+
faraday (>= 0.8)
|
79
|
+
faraday-httpclient (1.0.1)
|
80
|
+
faraday-net_http (1.0.1)
|
81
|
+
faraday-net_http_persistent (1.2.0)
|
82
|
+
faraday-patron (1.0.0)
|
83
|
+
faraday-rack (1.0.0)
|
84
|
+
ffi (1.15.4)
|
85
|
+
fiber-local (1.0.0)
|
86
|
+
formatador (0.3.0)
|
87
|
+
github_changelog_generator (1.16.4)
|
88
|
+
activesupport
|
89
|
+
async (>= 1.25.0)
|
90
|
+
async-http-faraday
|
91
|
+
faraday-http-cache
|
92
|
+
multi_json
|
93
|
+
octokit (~> 4.6)
|
94
|
+
rainbow (>= 2.2.1)
|
95
|
+
rake (>= 10.0)
|
96
|
+
google-protobuf (3.19.4-x86_64-darwin)
|
97
|
+
guard (2.17.0)
|
98
|
+
formatador (>= 0.2.4)
|
99
|
+
listen (>= 2.7, < 4.0)
|
100
|
+
lumberjack (>= 1.0.12, < 2.0)
|
101
|
+
nenv (~> 0.1)
|
102
|
+
notiffany (~> 0.0)
|
103
|
+
pry (>= 0.9.12)
|
104
|
+
shellany (~> 0.0)
|
105
|
+
thor (>= 0.18.1)
|
106
|
+
guard-compat (1.2.1)
|
107
|
+
guard-rake (1.0.0)
|
108
|
+
guard
|
109
|
+
rake
|
110
|
+
guard-rspec (4.7.3)
|
111
|
+
guard (~> 2.1)
|
112
|
+
guard-compat (~> 1.1)
|
113
|
+
rspec (>= 2.99.0, < 4.0)
|
114
|
+
guard-rubocop (1.3.0)
|
115
|
+
guard (~> 2.0)
|
116
|
+
rubocop (~> 0.20)
|
117
|
+
hirb (0.7.3)
|
118
|
+
i18n (1.8.10)
|
119
|
+
concurrent-ruby (~> 1.0)
|
120
|
+
interception (0.5)
|
121
|
+
jaro_winkler (1.5.4)
|
122
|
+
json (2.5.1)
|
123
|
+
listen (3.7.0)
|
124
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
125
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
126
|
+
lumberjack (1.2.8)
|
127
|
+
memory_profiler (0.9.14)
|
128
|
+
method_source (0.9.2)
|
129
|
+
mini_portile2 (2.6.1)
|
130
|
+
minitest (5.14.4)
|
131
|
+
multi_json (1.15.0)
|
132
|
+
multipart-post (2.1.1)
|
133
|
+
nenv (0.3.0)
|
134
|
+
nio4r (2.5.8)
|
135
|
+
nokogiri (1.12.4)
|
136
|
+
mini_portile2 (~> 2.6.1)
|
137
|
+
racc (~> 1.4)
|
138
|
+
nokogiri (1.12.4-x86_64-darwin)
|
139
|
+
racc (~> 1.4)
|
140
|
+
notiffany (0.1.3)
|
141
|
+
nenv (~> 0.1)
|
142
|
+
shellany (~> 0.0)
|
143
|
+
octokit (4.21.0)
|
144
|
+
faraday (>= 0.9)
|
145
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
146
|
+
parallel (1.21.0)
|
147
|
+
parser (3.0.2.0)
|
148
|
+
ast (~> 2.4.1)
|
149
|
+
pg (1.1.4)
|
150
|
+
pg_query (2.1.3)
|
151
|
+
google-protobuf (>= 3.19.2)
|
152
|
+
protocol-hpack (1.4.2)
|
153
|
+
protocol-http (0.22.5)
|
154
|
+
protocol-http1 (0.14.2)
|
155
|
+
protocol-http (~> 0.22)
|
156
|
+
protocol-http2 (0.14.2)
|
157
|
+
protocol-hpack (~> 1.4)
|
158
|
+
protocol-http (~> 0.18)
|
159
|
+
pry (0.12.2)
|
160
|
+
coderay (~> 1.1.0)
|
161
|
+
method_source (~> 0.9.0)
|
162
|
+
pry-alias (0.0.1)
|
163
|
+
binding_of_caller
|
164
|
+
pry
|
165
|
+
pry-doc (1.2.0)
|
166
|
+
pry (~> 0.11)
|
167
|
+
yard (~> 0.9.11)
|
168
|
+
pry-nav (0.3.0)
|
169
|
+
pry (>= 0.9.10, < 0.13.0)
|
170
|
+
pry-rescue (1.5.2)
|
171
|
+
interception (>= 0.5)
|
172
|
+
pry (>= 0.12.0)
|
173
|
+
pry-stack_explorer (0.4.9.3)
|
174
|
+
binding_of_caller (>= 0.7)
|
175
|
+
pry (>= 0.9.11)
|
176
|
+
public_suffix (4.0.6)
|
177
|
+
racc (1.5.2)
|
178
|
+
rainbow (3.0.0)
|
179
|
+
rake (13.0.6)
|
180
|
+
rake-compiler (1.1.1)
|
181
|
+
rake
|
182
|
+
rb-fsevent (0.11.0)
|
183
|
+
rb-inotify (0.10.1)
|
184
|
+
ffi (~> 1.0)
|
185
|
+
rspec (3.10.0)
|
186
|
+
rspec-core (~> 3.10.0)
|
187
|
+
rspec-expectations (~> 3.10.0)
|
188
|
+
rspec-mocks (~> 3.10.0)
|
189
|
+
rspec-core (3.10.1)
|
190
|
+
rspec-support (~> 3.10.0)
|
191
|
+
rspec-expectations (3.10.1)
|
192
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
193
|
+
rspec-support (~> 3.10.0)
|
194
|
+
rspec-mocks (3.10.2)
|
195
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
196
|
+
rspec-support (~> 3.10.0)
|
197
|
+
rspec-support (3.10.2)
|
198
|
+
rubocop (0.71.0)
|
199
|
+
jaro_winkler (~> 1.5.1)
|
200
|
+
parallel (~> 1.10)
|
201
|
+
parser (>= 2.6)
|
202
|
+
rainbow (>= 2.2.2, < 4.0)
|
203
|
+
ruby-progressbar (~> 1.7)
|
204
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
205
|
+
ruby-progressbar (1.11.0)
|
206
|
+
ruby2_keywords (0.0.5)
|
207
|
+
sawyer (0.8.2)
|
208
|
+
addressable (>= 2.3.5)
|
209
|
+
faraday (> 0.8, < 2.0)
|
210
|
+
shellany (0.0.1)
|
211
|
+
simplecov (0.16.1)
|
212
|
+
docile (~> 1.1)
|
213
|
+
json (>= 1.8, < 3)
|
214
|
+
simplecov-html (~> 0.10.0)
|
215
|
+
simplecov-console (0.4.2)
|
216
|
+
ansi
|
217
|
+
hirb
|
218
|
+
simplecov
|
219
|
+
simplecov-html (0.10.2)
|
220
|
+
stackprof (0.2.17)
|
221
|
+
thor (1.1.0)
|
222
|
+
timers (4.3.3)
|
223
|
+
tzinfo (2.0.4)
|
224
|
+
concurrent-ruby (~> 1.0)
|
225
|
+
unicode-display_width (1.6.1)
|
226
|
+
yard (0.9.26)
|
227
|
+
zeitwerk (2.4.2)
|
228
|
+
|
229
|
+
PLATFORMS
|
230
|
+
aarch64-linux
|
231
|
+
x86_64-darwin-20
|
232
|
+
x86_64-darwin-21
|
233
|
+
|
234
|
+
DEPENDENCIES
|
235
|
+
activerecord (~> 6.1.0)
|
236
|
+
appraisal (~> 2.4.1)
|
237
|
+
approvals (~> 0.0.24)
|
238
|
+
arel_toolkit!
|
239
|
+
bundler (~> 2.0)
|
240
|
+
database_cleaner (~> 1.7.0)
|
241
|
+
dpl (~> 1.10.11)
|
242
|
+
github_changelog_generator (~> 1.15)
|
243
|
+
guard (~> 2.15)
|
244
|
+
guard-rake (~> 1.0.0)
|
245
|
+
guard-rspec (~> 4.7)
|
246
|
+
guard-rubocop (~> 1.3.0)
|
247
|
+
memory_profiler (~> 0.9)
|
248
|
+
pry
|
249
|
+
pry-alias
|
250
|
+
pry-doc
|
251
|
+
pry-nav
|
252
|
+
pry-rescue
|
253
|
+
pry-stack_explorer
|
254
|
+
rake (~> 13.0)
|
255
|
+
rake-compiler (~> 1.0)
|
256
|
+
rspec (~> 3.8)
|
257
|
+
rubocop (= 0.71.0)
|
258
|
+
simplecov (~> 0.16.1)
|
259
|
+
simplecov-console (~> 0.4.2)
|
260
|
+
stackprof (~> 0.2)
|
261
|
+
|
262
|
+
BUNDLED WITH
|
263
|
+
2.3.6
|
@@ -31,10 +31,10 @@ GIT
|
|
31
31
|
PATH
|
32
32
|
remote: ..
|
33
33
|
specs:
|
34
|
-
arel_toolkit (0.4.
|
35
|
-
activerecord
|
34
|
+
arel_toolkit (0.4.7)
|
35
|
+
activerecord (>= 5.0.0)
|
36
36
|
pg (~> 1.1.4)
|
37
|
-
pg_query (~>
|
37
|
+
pg_query (~> 2.1)
|
38
38
|
|
39
39
|
GEM
|
40
40
|
remote: https://rubygems.org/
|
@@ -66,7 +66,7 @@ GEM
|
|
66
66
|
addressable (2.7.0)
|
67
67
|
public_suffix (>= 2.0.2, < 5.0)
|
68
68
|
ansi (1.5.0)
|
69
|
-
appraisal (2.
|
69
|
+
appraisal (2.4.1)
|
70
70
|
bundler
|
71
71
|
rake
|
72
72
|
thor (>= 0.14.0)
|
@@ -101,6 +101,7 @@ GEM
|
|
101
101
|
rainbow (>= 2.2.1)
|
102
102
|
rake (>= 10.0)
|
103
103
|
retriable (~> 3.0)
|
104
|
+
google-protobuf (3.19.4-x86_64-darwin)
|
104
105
|
guard (2.15.0)
|
105
106
|
formatador (>= 0.2.4)
|
106
107
|
listen (>= 2.7, < 4.0)
|
@@ -154,7 +155,8 @@ GEM
|
|
154
155
|
ast (~> 2.4.0)
|
155
156
|
pg (1.1.4)
|
156
157
|
pg_array_parser (0.0.9)
|
157
|
-
pg_query (1.
|
158
|
+
pg_query (2.1.3)
|
159
|
+
google-protobuf (>= 3.19.2)
|
158
160
|
pry (0.12.2)
|
159
161
|
coderay (~> 1.1.0)
|
160
162
|
method_source (~> 0.9.0)
|
@@ -251,7 +253,7 @@ PLATFORMS
|
|
251
253
|
|
252
254
|
DEPENDENCIES
|
253
255
|
active_record_upsert!
|
254
|
-
appraisal (~> 2.
|
256
|
+
appraisal (~> 2.4.1)
|
255
257
|
approvals (~> 0.0.24)
|
256
258
|
arel_toolkit!
|
257
259
|
bundler (~> 2.0)
|
@@ -281,4 +283,4 @@ DEPENDENCIES
|
|
281
283
|
stackprof (~> 0.2)
|
282
284
|
|
283
285
|
BUNDLED WITH
|
284
|
-
2.
|
286
|
+
2.3.6
|
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
arel_toolkit (0.4.
|
5
|
-
activerecord
|
4
|
+
arel_toolkit (0.4.7)
|
5
|
+
activerecord (>= 5.0.0)
|
6
6
|
pg (~> 1.1.4)
|
7
|
-
pg_query (~>
|
7
|
+
pg_query (~> 2.1)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
addressable (2.7.0)
|
24
24
|
public_suffix (>= 2.0.2, < 5.0)
|
25
25
|
ansi (1.5.0)
|
26
|
-
appraisal (2.
|
26
|
+
appraisal (2.4.1)
|
27
27
|
bundler
|
28
28
|
rake
|
29
29
|
thor (>= 0.14.0)
|
@@ -55,6 +55,7 @@ GEM
|
|
55
55
|
rainbow (>= 2.2.1)
|
56
56
|
rake (>= 10.0)
|
57
57
|
retriable (~> 3.0)
|
58
|
+
google-protobuf (3.19.4-x86_64-darwin)
|
58
59
|
guard (2.15.0)
|
59
60
|
formatador (>= 0.2.4)
|
60
61
|
listen (>= 2.7, < 4.0)
|
@@ -104,7 +105,8 @@ 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 (2.1.3)
|
109
|
+
google-protobuf (>= 3.19.2)
|
108
110
|
pry (0.12.2)
|
109
111
|
coderay (~> 1.1.0)
|
110
112
|
method_source (~> 0.9.0)
|
@@ -178,7 +180,7 @@ PLATFORMS
|
|
178
180
|
ruby
|
179
181
|
|
180
182
|
DEPENDENCIES
|
181
|
-
appraisal (~> 2.
|
183
|
+
appraisal (~> 2.4.1)
|
182
184
|
approvals (~> 0.0.24)
|
183
185
|
arel_toolkit!
|
184
186
|
bundler (~> 2.0)
|
@@ -205,4 +207,4 @@ DEPENDENCIES
|
|
205
207
|
stackprof (~> 0.2)
|
206
208
|
|
207
209
|
BUNDLED WITH
|
208
|
-
2.
|
210
|
+
2.3.6
|
@@ -22,6 +22,10 @@ module Arel
|
|
22
22
|
node.parent.parent.object.is_a?(Arel::Nodes::JoinSource)
|
23
23
|
context[:range_variable] = true
|
24
24
|
|
25
|
+
elsif parent_object.is_a?(Arel::Nodes::TableAlias) &&
|
26
|
+
node.parent.parent.parent.object.is_a?(Arel::Nodes::JoinSource)
|
27
|
+
context[:range_variable] = true
|
28
|
+
|
25
29
|
# Using Arel::Table as SELECT ... FROM [<table>]
|
26
30
|
elsif parent_object.is_a?(Array) &&
|
27
31
|
node.parent.parent.object.is_a?(Arel::Nodes::JoinSource)
|
@@ -35,10 +39,26 @@ module Arel
|
|
35
39
|
node.parent.parent.parent.object.is_a?(Arel::Nodes::JoinSource)
|
36
40
|
context[:range_variable] = true
|
37
41
|
|
42
|
+
elsif parent_object.is_a?(Arel::Nodes::TableAlias) &&
|
43
|
+
node.parent.parent.object.is_a?(Arel::Attributes::Attribute)
|
44
|
+
context[:column_reference] = true
|
45
|
+
|
46
|
+
elsif parent_object.is_a?(Arel::Nodes::TableAlias) &&
|
47
|
+
node.parent.parent.parent.object.is_a?(Arel::Attributes::Attribute)
|
48
|
+
context[:column_reference] = true
|
49
|
+
|
38
50
|
# Using Arel::Table as SELECT ... INNER JOIN <table> ON TRUE
|
39
51
|
elsif parent_object.is_a?(Arel::Nodes::Join)
|
40
52
|
context[:range_variable] = true
|
41
53
|
|
54
|
+
elsif parent_object.is_a?(Arel::Nodes::TableAlias) &&
|
55
|
+
node.parent.parent.object.is_a?(Arel::Nodes::Join)
|
56
|
+
context[:range_variable] = true
|
57
|
+
|
58
|
+
elsif parent_object.is_a?(Arel::Nodes::TableAlias) &&
|
59
|
+
node.parent.parent.parent.object.is_a?(Arel::Nodes::Join)
|
60
|
+
context[:range_variable] = true
|
61
|
+
|
42
62
|
# Using Arel::Table as an attribute SELECT <table>.id ...
|
43
63
|
elsif parent_object.is_a?(Arel::Attributes::Attribute)
|
44
64
|
context[:column_reference] = true
|
data/lib/arel/enhance/node.rb
CHANGED
@@ -1,21 +1,15 @@
|
|
1
1
|
module Arel
|
2
2
|
module Enhance
|
3
3
|
class Node
|
4
|
+
attr_reader :local_path
|
4
5
|
attr_reader :object
|
5
6
|
attr_reader :parent
|
6
|
-
attr_reader :local_path
|
7
|
-
attr_reader :fields
|
8
|
-
attr_reader :children
|
9
7
|
attr_reader :root_node
|
10
|
-
attr_reader :context
|
11
8
|
|
12
9
|
def initialize(object)
|
13
10
|
@object = object
|
14
11
|
@root_node = self
|
15
|
-
@fields = []
|
16
|
-
@children = {}
|
17
12
|
@dirty = false
|
18
|
-
@context = {}
|
19
13
|
end
|
20
14
|
|
21
15
|
def inspect
|
@@ -25,7 +19,7 @@ module Arel
|
|
25
19
|
def value
|
26
20
|
return unless value?
|
27
21
|
|
28
|
-
|
22
|
+
fields.first
|
29
23
|
end
|
30
24
|
|
31
25
|
def each(&block)
|
@@ -58,7 +52,7 @@ module Arel
|
|
58
52
|
node.local_path = path_node
|
59
53
|
node.parent = self
|
60
54
|
node.root_node = root_node
|
61
|
-
|
55
|
+
children[path_node.value.to_s] = node
|
62
56
|
end
|
63
57
|
|
64
58
|
def to_sql(engine = Table.engine)
|
@@ -78,19 +72,19 @@ module Arel
|
|
78
72
|
end
|
79
73
|
|
80
74
|
def method_missing(name, *args, &block)
|
81
|
-
child =
|
75
|
+
child = children[name.to_s]
|
82
76
|
return super if child.nil?
|
83
77
|
|
84
78
|
child
|
85
79
|
end
|
86
80
|
|
87
81
|
def respond_to_missing?(method, include_private = false)
|
88
|
-
child =
|
82
|
+
child = children[method.to_s]
|
89
83
|
child.present? || super
|
90
84
|
end
|
91
85
|
|
92
86
|
def [](key)
|
93
|
-
|
87
|
+
children.fetch(key.to_s)
|
94
88
|
end
|
95
89
|
|
96
90
|
def child_at_path(path_items)
|
@@ -118,6 +112,18 @@ module Arel
|
|
118
112
|
the_path.compact
|
119
113
|
end
|
120
114
|
|
115
|
+
def children
|
116
|
+
@children ||= {}
|
117
|
+
end
|
118
|
+
|
119
|
+
def fields
|
120
|
+
@fields ||= []
|
121
|
+
end
|
122
|
+
|
123
|
+
def context
|
124
|
+
@context ||= {}
|
125
|
+
end
|
126
|
+
|
121
127
|
protected
|
122
128
|
|
123
129
|
attr_writer :local_path
|
@@ -211,6 +217,8 @@ module Arel
|
|
211
217
|
else
|
212
218
|
parent_object[local_path.value] = new_arel_node
|
213
219
|
end
|
220
|
+
elsif parent_object.is_a?(Arel::Nodes::TableAlias) && local_path.value == 'relation'
|
221
|
+
parent_object.instance_variable_set('@left', new_arel_node)
|
214
222
|
else
|
215
223
|
raise "Don't know how to replace `#{local_path.value}` in #{parent_object.inspect}"
|
216
224
|
end
|
data/lib/arel/enhance/visitor.rb
CHANGED
@@ -14,7 +14,7 @@ module Arel
|
|
14
14
|
@context_enhancers = context_enhancers
|
15
15
|
|
16
16
|
root_node = Arel::Enhance::Node.new(object)
|
17
|
-
accept_with_root(object, root_node)
|
17
|
+
accept_with_root(object, root_node, context_enhancers)
|
18
18
|
end
|
19
19
|
|
20
20
|
def accept_with_root(object, root_node, context_enhancers = DEFAULT_CONTEXT_ENHANCERS)
|
data/lib/arel/enhance.rb
CHANGED
@@ -9,9 +9,9 @@ module Arel
|
|
9
9
|
module Enhance
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.enhance(object)
|
12
|
+
def self.enhance(object, context_enhancers = Arel::Enhance::Visitor::DEFAULT_CONTEXT_ENHANCERS)
|
13
13
|
return object if object.is_a?(Arel::Enhance::Node)
|
14
14
|
|
15
|
-
Arel::Enhance::Visitor.new.accept(object)
|
15
|
+
Arel::Enhance::Visitor.new.accept(object, context_enhancers)
|
16
16
|
end
|
17
17
|
end
|
@@ -21,12 +21,12 @@ module Arel
|
|
21
21
|
visit(o.infer, collector) if o.infer
|
22
22
|
|
23
23
|
case o.action
|
24
|
-
when
|
24
|
+
when :ONCONFLICT_NOTHING
|
25
25
|
collector << 'DO NOTHING'
|
26
|
-
when
|
26
|
+
when :ONCONFLICT_UPDATE
|
27
27
|
collector << 'DO UPDATE SET '
|
28
28
|
else
|
29
|
-
raise "Unknown conflict clause `#{action}`"
|
29
|
+
raise "Unknown conflict clause `#{o.action}`"
|
30
30
|
end
|
31
31
|
|
32
32
|
o.values.any? && (inject_join o.values, collector, ', ')
|
@@ -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
|
@@ -13,13 +13,13 @@ module Arel
|
|
13
13
|
module Visitors
|
14
14
|
class ToSql
|
15
15
|
def visit_Arel_Nodes_Infer(o, collector)
|
16
|
-
if o.name
|
16
|
+
if o.name.present?
|
17
17
|
collector << 'ON CONSTRAINT '
|
18
18
|
collector << o.left
|
19
19
|
collector << ' '
|
20
20
|
end
|
21
21
|
|
22
|
-
if o.right
|
22
|
+
if o.right.present?
|
23
23
|
collector << '('
|
24
24
|
inject_join o.right, collector, ', '
|
25
25
|
collector << ') '
|