activerecord-refined 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +14 -0
- data/.rubocop.yml +393 -0
- data/Gemfile +5 -3
- data/README.md +254 -74
- data/Rakefile +31 -3
- data/activerecord-refined.gemspec +29 -15
- data/benchmark/query_building.rb +11 -11
- data/examples/aggregations.rb +13 -11
- data/examples/complex_joins.rb +12 -10
- data/examples/ctes.rb +22 -20
- data/examples/expressions.rb +79 -44
- data/examples/json.rb +77 -38
- data/examples/postgresql.rb +64 -53
- data/examples/predicates.rb +35 -33
- data/examples/subqueries.rb +20 -18
- data/examples/windows.rb +23 -21
- data/examples/writes.rb +26 -24
- data/lib/active_record/refined/ast.rb +862 -272
- data/lib/active_record/refined.rb +260 -180
- data/lib/activerecord-refined/version.rb +3 -1
- data/lib/activerecord-refined.rb +8 -5
- data/test/test_block_syntax.rb +879 -323
- data/test/test_helper.rb +56 -39
- metadata +130 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a60a269c60ae8fbcb1cad6a7b505a11f4b80b90eaa2248c5ed86b0b356de408d
|
|
4
|
+
data.tar.gz: 19455d0abec51c30a6bfb80cde89b39fc0449d783a5c9ba6b2caef3bf10f056b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e043783aae9f67e169bfde1510346333920a982ce9b91048812724e23103aba6cb9e30636778db03a74a625c46e6af36370d06527783a6281aed3ff40eb00bc3
|
|
7
|
+
data.tar.gz: f410cc81e87248c1556e44f95c1dc9e31e6e9e49b8b4d47c9c2e2f570b8c6363e3aeef64b554e76e41d25c144f243545f61fe126eb26c7311ccc36469976bd96
|
data/.github/workflows/test.yml
CHANGED
|
@@ -7,6 +7,20 @@ on:
|
|
|
7
7
|
pull_request:
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
|
+
rubocop:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
env:
|
|
13
|
+
BUNDLE_WITHOUT: db
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v5
|
|
16
|
+
- uses: ruby/setup-ruby@v1
|
|
17
|
+
with:
|
|
18
|
+
# Linting needs no Proc#refined, but bundler reads the gemspec's
|
|
19
|
+
# required_ruby_version and 4.1.0.dev leaves head the only fit.
|
|
20
|
+
ruby-version: head
|
|
21
|
+
bundler-cache: true
|
|
22
|
+
- run: bundle exec rubocop
|
|
23
|
+
|
|
10
24
|
sqlite:
|
|
11
25
|
runs-on: ubuntu-latest
|
|
12
26
|
env:
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- rubocop-minitest
|
|
3
|
+
- rubocop-packaging
|
|
4
|
+
- rubocop-performance
|
|
5
|
+
- rubocop-rails
|
|
6
|
+
- rubocop-md
|
|
7
|
+
|
|
8
|
+
AllCops:
|
|
9
|
+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
|
10
|
+
# to ignore them, so only the ones explicitly set in this file are enabled.
|
|
11
|
+
DisabledByDefault: true
|
|
12
|
+
SuggestExtensions: false
|
|
13
|
+
# Inferring from the gemspec would stumble over 4.1.0.dev, so say it plainly.
|
|
14
|
+
TargetRubyVersion: 4.1
|
|
15
|
+
Exclude:
|
|
16
|
+
- "**/tmp/**/*"
|
|
17
|
+
- "**/vendor/**/*"
|
|
18
|
+
- "**/node_modules/**/*"
|
|
19
|
+
- "pkg/**/*"
|
|
20
|
+
# A site rather than the library, and partly vendored from wasmify-rails.
|
|
21
|
+
- "sandbox/**/*"
|
|
22
|
+
|
|
23
|
+
Performance:
|
|
24
|
+
Exclude:
|
|
25
|
+
- '**/test/**/*'
|
|
26
|
+
|
|
27
|
+
Rails/IndexBy:
|
|
28
|
+
Enabled: true
|
|
29
|
+
|
|
30
|
+
Rails/IndexWith:
|
|
31
|
+
Enabled: true
|
|
32
|
+
|
|
33
|
+
# Prefer &&/|| over and/or.
|
|
34
|
+
Style/AndOr:
|
|
35
|
+
Enabled: true
|
|
36
|
+
|
|
37
|
+
Layout/ClosingHeredocIndentation:
|
|
38
|
+
Enabled: true
|
|
39
|
+
|
|
40
|
+
Layout/ClosingParenthesisIndentation:
|
|
41
|
+
Enabled: true
|
|
42
|
+
|
|
43
|
+
# Align comments with method definitions.
|
|
44
|
+
Layout/CommentIndentation:
|
|
45
|
+
Enabled: true
|
|
46
|
+
|
|
47
|
+
Layout/DefEndAlignment:
|
|
48
|
+
Enabled: true
|
|
49
|
+
|
|
50
|
+
Layout/ElseAlignment:
|
|
51
|
+
Enabled: true
|
|
52
|
+
|
|
53
|
+
# Align `end` with the matching keyword or starting expression except for
|
|
54
|
+
# assignments, where it should be aligned with the LHS.
|
|
55
|
+
Layout/EndAlignment:
|
|
56
|
+
Enabled: true
|
|
57
|
+
EnforcedStyleAlignWith: variable
|
|
58
|
+
AutoCorrect: true
|
|
59
|
+
|
|
60
|
+
Layout/EndOfLine:
|
|
61
|
+
Enabled: true
|
|
62
|
+
|
|
63
|
+
Layout/EmptyLineAfterMagicComment:
|
|
64
|
+
Enabled: true
|
|
65
|
+
|
|
66
|
+
Layout/EmptyLinesAroundAccessModifier:
|
|
67
|
+
Enabled: true
|
|
68
|
+
EnforcedStyle: only_before
|
|
69
|
+
|
|
70
|
+
Layout/EmptyLinesAroundBlockBody:
|
|
71
|
+
Enabled: true
|
|
72
|
+
|
|
73
|
+
# In a regular class definition, no empty lines around the body.
|
|
74
|
+
Layout/EmptyLinesAroundClassBody:
|
|
75
|
+
Enabled: true
|
|
76
|
+
|
|
77
|
+
# In a regular method definition, no empty lines around the body.
|
|
78
|
+
Layout/EmptyLinesAroundMethodBody:
|
|
79
|
+
Enabled: true
|
|
80
|
+
|
|
81
|
+
# In a regular module definition, no empty lines around the body.
|
|
82
|
+
Layout/EmptyLinesAroundModuleBody:
|
|
83
|
+
Enabled: true
|
|
84
|
+
|
|
85
|
+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
|
86
|
+
Style/HashSyntax:
|
|
87
|
+
Enabled: true
|
|
88
|
+
EnforcedShorthandSyntax: either
|
|
89
|
+
|
|
90
|
+
# Method definitions after `private` or `protected` isolated calls need one
|
|
91
|
+
# extra level of indentation.
|
|
92
|
+
Layout/IndentationConsistency:
|
|
93
|
+
Enabled: true
|
|
94
|
+
EnforcedStyle: indented_internal_methods
|
|
95
|
+
Exclude:
|
|
96
|
+
- '**/*.md'
|
|
97
|
+
|
|
98
|
+
# Two spaces, no tabs (for indentation).
|
|
99
|
+
Layout/IndentationWidth:
|
|
100
|
+
Enabled: true
|
|
101
|
+
|
|
102
|
+
Layout/LeadingCommentSpace:
|
|
103
|
+
Enabled: true
|
|
104
|
+
|
|
105
|
+
Layout/SpaceAfterColon:
|
|
106
|
+
Enabled: true
|
|
107
|
+
|
|
108
|
+
Layout/SpaceAfterComma:
|
|
109
|
+
Enabled: true
|
|
110
|
+
|
|
111
|
+
Layout/SpaceAfterSemicolon:
|
|
112
|
+
Enabled: true
|
|
113
|
+
|
|
114
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
|
115
|
+
Enabled: true
|
|
116
|
+
|
|
117
|
+
Layout/SpaceAroundKeyword:
|
|
118
|
+
Enabled: true
|
|
119
|
+
|
|
120
|
+
Layout/SpaceAroundOperators:
|
|
121
|
+
Enabled: true
|
|
122
|
+
|
|
123
|
+
Layout/SpaceBeforeComma:
|
|
124
|
+
Enabled: true
|
|
125
|
+
|
|
126
|
+
Layout/SpaceBeforeComment:
|
|
127
|
+
Enabled: true
|
|
128
|
+
|
|
129
|
+
Layout/SpaceBeforeFirstArg:
|
|
130
|
+
Enabled: true
|
|
131
|
+
|
|
132
|
+
Style/DefWithParentheses:
|
|
133
|
+
Enabled: true
|
|
134
|
+
|
|
135
|
+
# Defining a method with parameters needs parentheses.
|
|
136
|
+
Style/MethodDefParentheses:
|
|
137
|
+
Enabled: true
|
|
138
|
+
|
|
139
|
+
Style/ExplicitBlockArgument:
|
|
140
|
+
Enabled: true
|
|
141
|
+
|
|
142
|
+
Style/FrozenStringLiteralComment:
|
|
143
|
+
Enabled: true
|
|
144
|
+
EnforcedStyle: always
|
|
145
|
+
Exclude:
|
|
146
|
+
- '**/*.md'
|
|
147
|
+
|
|
148
|
+
Style/MutableConstant:
|
|
149
|
+
Enabled: true
|
|
150
|
+
EnforcedStyle: literals
|
|
151
|
+
Exclude:
|
|
152
|
+
- '**/*.md'
|
|
153
|
+
|
|
154
|
+
Style/MapToHash:
|
|
155
|
+
Enabled: true
|
|
156
|
+
|
|
157
|
+
Style/RedundantFreeze:
|
|
158
|
+
Enabled: true
|
|
159
|
+
|
|
160
|
+
# Use `foo {}` not `foo{}`.
|
|
161
|
+
Layout/SpaceBeforeBlockBraces:
|
|
162
|
+
Enabled: true
|
|
163
|
+
|
|
164
|
+
# Use `foo { bar }` not `foo {bar}`.
|
|
165
|
+
Layout/SpaceInsideBlockBraces:
|
|
166
|
+
Enabled: true
|
|
167
|
+
EnforcedStyleForEmptyBraces: space
|
|
168
|
+
|
|
169
|
+
# Use `{ a: 1 }` not `{a:1}`.
|
|
170
|
+
Layout/SpaceInsideHashLiteralBraces:
|
|
171
|
+
Enabled: true
|
|
172
|
+
|
|
173
|
+
Layout/SpaceInsideParens:
|
|
174
|
+
Enabled: true
|
|
175
|
+
|
|
176
|
+
# Check quotes usage according to lint rule below.
|
|
177
|
+
Style/StringLiterals:
|
|
178
|
+
Enabled: true
|
|
179
|
+
EnforcedStyle: double_quotes
|
|
180
|
+
|
|
181
|
+
# Detect hard tabs, no hard tabs.
|
|
182
|
+
Layout/IndentationStyle:
|
|
183
|
+
Enabled: true
|
|
184
|
+
|
|
185
|
+
# Empty lines should not have any spaces.
|
|
186
|
+
Layout/TrailingEmptyLines:
|
|
187
|
+
Enabled: true
|
|
188
|
+
|
|
189
|
+
# No trailing whitespace.
|
|
190
|
+
Layout/TrailingWhitespace:
|
|
191
|
+
Enabled: true
|
|
192
|
+
|
|
193
|
+
# Use quotes for string literals when they are enough.
|
|
194
|
+
Style/RedundantPercentQ:
|
|
195
|
+
Enabled: true
|
|
196
|
+
|
|
197
|
+
Lint/NestedMethodDefinition:
|
|
198
|
+
Enabled: true
|
|
199
|
+
|
|
200
|
+
Lint/AmbiguousOperator:
|
|
201
|
+
Enabled: true
|
|
202
|
+
|
|
203
|
+
Lint/AmbiguousRegexpLiteral:
|
|
204
|
+
Enabled: true
|
|
205
|
+
|
|
206
|
+
Lint/Debugger:
|
|
207
|
+
Enabled: true
|
|
208
|
+
DebuggerRequires:
|
|
209
|
+
- debug
|
|
210
|
+
|
|
211
|
+
Lint/DuplicateRequire:
|
|
212
|
+
Enabled: true
|
|
213
|
+
|
|
214
|
+
Lint/DuplicateMagicComment:
|
|
215
|
+
Enabled: true
|
|
216
|
+
|
|
217
|
+
Lint/DuplicateMethods:
|
|
218
|
+
Enabled: true
|
|
219
|
+
|
|
220
|
+
Lint/ErbNewArguments:
|
|
221
|
+
Enabled: true
|
|
222
|
+
|
|
223
|
+
Lint/EnsureReturn:
|
|
224
|
+
Enabled: true
|
|
225
|
+
|
|
226
|
+
Lint/MissingCopEnableDirective:
|
|
227
|
+
Enabled: true
|
|
228
|
+
|
|
229
|
+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
|
230
|
+
Lint/RequireParentheses:
|
|
231
|
+
Enabled: true
|
|
232
|
+
|
|
233
|
+
Lint/RedundantCopDisableDirective:
|
|
234
|
+
Enabled: true
|
|
235
|
+
|
|
236
|
+
Lint/RedundantCopEnableDirective:
|
|
237
|
+
Enabled: true
|
|
238
|
+
|
|
239
|
+
Lint/RedundantRequireStatement:
|
|
240
|
+
Enabled: true
|
|
241
|
+
|
|
242
|
+
Lint/RedundantStringCoercion:
|
|
243
|
+
Enabled: true
|
|
244
|
+
|
|
245
|
+
Lint/RedundantSafeNavigation:
|
|
246
|
+
Enabled: true
|
|
247
|
+
|
|
248
|
+
Lint/UriEscapeUnescape:
|
|
249
|
+
Enabled: true
|
|
250
|
+
|
|
251
|
+
Lint/UselessAssignment:
|
|
252
|
+
Enabled: true
|
|
253
|
+
|
|
254
|
+
Lint/DeprecatedClassMethods:
|
|
255
|
+
Enabled: true
|
|
256
|
+
|
|
257
|
+
Lint/InterpolationCheck:
|
|
258
|
+
Enabled: true
|
|
259
|
+
Exclude:
|
|
260
|
+
- '**/test/**/*'
|
|
261
|
+
|
|
262
|
+
Lint/SafeNavigationChain:
|
|
263
|
+
Enabled: true
|
|
264
|
+
|
|
265
|
+
Style/EvalWithLocation:
|
|
266
|
+
Enabled: true
|
|
267
|
+
Exclude:
|
|
268
|
+
- '**/test/**/*'
|
|
269
|
+
|
|
270
|
+
Style/ParenthesesAroundCondition:
|
|
271
|
+
Enabled: true
|
|
272
|
+
|
|
273
|
+
Style/HashTransformKeys:
|
|
274
|
+
Enabled: true
|
|
275
|
+
|
|
276
|
+
Style/HashTransformValues:
|
|
277
|
+
Enabled: true
|
|
278
|
+
|
|
279
|
+
Style/RedundantBegin:
|
|
280
|
+
Enabled: true
|
|
281
|
+
|
|
282
|
+
Style/RedundantReturn:
|
|
283
|
+
Enabled: true
|
|
284
|
+
AllowMultipleReturnValues: true
|
|
285
|
+
|
|
286
|
+
Style/RedundantRegexpEscape:
|
|
287
|
+
Enabled: true
|
|
288
|
+
|
|
289
|
+
Style/Semicolon:
|
|
290
|
+
Enabled: true
|
|
291
|
+
AllowAsExpressionSeparator: true
|
|
292
|
+
|
|
293
|
+
# Prefer Foo.method over Foo::method
|
|
294
|
+
Style/ColonMethodCall:
|
|
295
|
+
Enabled: true
|
|
296
|
+
|
|
297
|
+
Style/TrivialAccessors:
|
|
298
|
+
Enabled: true
|
|
299
|
+
|
|
300
|
+
# Prefer a = b || c over a = b ? b : c
|
|
301
|
+
Style/RedundantCondition:
|
|
302
|
+
Enabled: true
|
|
303
|
+
|
|
304
|
+
Style/RedundantDoubleSplatHashBraces:
|
|
305
|
+
Enabled: true
|
|
306
|
+
|
|
307
|
+
Style/OpenStructUse:
|
|
308
|
+
Enabled: true
|
|
309
|
+
|
|
310
|
+
Style/ArrayIntersect:
|
|
311
|
+
Enabled: true
|
|
312
|
+
|
|
313
|
+
Style/KeywordArgumentsMerging:
|
|
314
|
+
Enabled: true
|
|
315
|
+
|
|
316
|
+
Performance/BindCall:
|
|
317
|
+
Enabled: true
|
|
318
|
+
|
|
319
|
+
Performance/FlatMap:
|
|
320
|
+
Enabled: true
|
|
321
|
+
|
|
322
|
+
Performance/MapCompact:
|
|
323
|
+
Enabled: true
|
|
324
|
+
|
|
325
|
+
# Off, unlike Rails: select {}.map {} here is almost always Active Record's
|
|
326
|
+
# select -- the query DSL -- and filter_map would break it, which the cop
|
|
327
|
+
# cannot tell from Enumerable's.
|
|
328
|
+
Performance/SelectMap:
|
|
329
|
+
Enabled: false
|
|
330
|
+
|
|
331
|
+
Performance/RedundantMerge:
|
|
332
|
+
Enabled: true
|
|
333
|
+
|
|
334
|
+
Performance/StartWith:
|
|
335
|
+
Enabled: true
|
|
336
|
+
|
|
337
|
+
Performance/EndWith:
|
|
338
|
+
Enabled: true
|
|
339
|
+
|
|
340
|
+
Performance/RegexpMatch:
|
|
341
|
+
Enabled: true
|
|
342
|
+
|
|
343
|
+
Performance/ReverseEach:
|
|
344
|
+
Enabled: true
|
|
345
|
+
|
|
346
|
+
Performance/StringReplacement:
|
|
347
|
+
Enabled: true
|
|
348
|
+
|
|
349
|
+
Performance/DeletePrefix:
|
|
350
|
+
Enabled: true
|
|
351
|
+
|
|
352
|
+
Performance/DeleteSuffix:
|
|
353
|
+
Enabled: true
|
|
354
|
+
|
|
355
|
+
Performance/InefficientHashSearch:
|
|
356
|
+
Enabled: true
|
|
357
|
+
|
|
358
|
+
Performance/ConstantRegexp:
|
|
359
|
+
Enabled: true
|
|
360
|
+
|
|
361
|
+
Performance/RedundantStringChars:
|
|
362
|
+
Enabled: true
|
|
363
|
+
|
|
364
|
+
Performance/StringInclude:
|
|
365
|
+
Enabled: true
|
|
366
|
+
|
|
367
|
+
Minitest/AssertNil:
|
|
368
|
+
Enabled: true
|
|
369
|
+
|
|
370
|
+
Minitest/AssertRaisesWithRegexpArgument:
|
|
371
|
+
Enabled: true
|
|
372
|
+
|
|
373
|
+
Minitest/AssertWithExpectedArgument:
|
|
374
|
+
Enabled: true
|
|
375
|
+
|
|
376
|
+
Minitest/LiteralAsActualArgument:
|
|
377
|
+
Enabled: true
|
|
378
|
+
|
|
379
|
+
Minitest/NonExecutableTestMethod:
|
|
380
|
+
Enabled: true
|
|
381
|
+
|
|
382
|
+
Minitest/SkipEnsure:
|
|
383
|
+
Enabled: true
|
|
384
|
+
|
|
385
|
+
Minitest/UnreachableAssertion:
|
|
386
|
+
Enabled: true
|
|
387
|
+
|
|
388
|
+
Markdown:
|
|
389
|
+
# Off, unlike Rails: README abbreviates a snippet to its shape --
|
|
390
|
+
# with_recursive(tree: [...]) -- which is not Ruby and means not to be.
|
|
391
|
+
WarnInvalid: false
|
|
392
|
+
# Whether to lint codeblocks without code attributes
|
|
393
|
+
Autodetect: false
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
2
4
|
|
|
3
5
|
# Specify your gem's dependencies in activerecord-refined.gemspec
|
|
4
6
|
gemspec
|
|
@@ -7,6 +9,6 @@ gemspec
|
|
|
7
9
|
# needs the client libraries installed. `rake test` runs on SQLite, so a
|
|
8
10
|
# checkout without them is still usable: bundle config set --local without db
|
|
9
11
|
group :db do
|
|
10
|
-
gem
|
|
11
|
-
gem
|
|
12
|
+
gem "mysql2"
|
|
13
|
+
gem "pg"
|
|
12
14
|
end
|