inquery 1.0.11 → 1.1.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/rubocop.yml +1 -1
- data/.github/workflows/ruby.yml +24 -8
- data/.gitignore +2 -2
- data/.rubocop.yml +4 -0
- data/Appraisals +24 -4
- data/CHANGELOG.md +38 -0
- data/Gemfile +17 -1
- data/Gemfile.lock +125 -0
- data/LICENSE +1 -1
- data/MIGRATION.md +260 -0
- data/README.md +14 -8
- data/RUBY_VERSION +1 -1
- data/Rakefile +4 -11
- data/VERSION +1 -1
- data/doc/Inquery/Exceptions/Base.html +4 -4
- data/doc/Inquery/Exceptions/InvalidRelation.html +4 -4
- data/doc/Inquery/Exceptions/UnknownCallSignature.html +4 -4
- data/doc/Inquery/Exceptions.html +4 -4
- data/doc/Inquery/MethodAccessibleHash.html +431 -0
- data/doc/Inquery/Mixins/RawSqlUtils.html +17 -4
- data/doc/Inquery/Mixins/RelationValidation/ClassMethods.html +8 -7
- data/doc/Inquery/Mixins/RelationValidation.html +9 -8
- data/doc/Inquery/Mixins/SchemaValidation/ClassMethods.html +4 -4
- data/doc/Inquery/Mixins/SchemaValidation.html +4 -4
- data/doc/Inquery/Mixins.html +4 -4
- data/doc/Inquery/Query/Chainable.html +207 -90
- data/doc/Inquery/Query.html +401 -73
- data/doc/Inquery.html +12 -9
- data/doc/_index.html +12 -5
- data/doc/class_list.html +6 -3
- data/doc/css/full_list.css +3 -3
- data/doc/css/style.css +6 -0
- data/doc/file.README.html +102 -16
- data/doc/file_list.html +5 -2
- data/doc/frames.html +10 -5
- data/doc/index.html +102 -16
- data/doc/js/app.js +294 -264
- data/doc/js/full_list.js +30 -4
- data/doc/method_list.html +48 -21
- data/doc/top-level-namespace.html +4 -4
- data/gemfiles/rails_5.2.gemfile +1 -0
- data/gemfiles/rails_6.0.gemfile +1 -0
- data/gemfiles/rails_6.1.gemfile +1 -0
- data/gemfiles/rails_7.0.gemfile +1 -0
- data/gemfiles/{rails_5.1.gemfile → rails_7.1.gemfile} +2 -1
- data/gemfiles/rails_7.2.gemfile +8 -0
- data/gemfiles/rails_8.0.gemfile +8 -0
- data/gemfiles/rails_8.1.gemfile +8 -0
- data/inquery.gemspec +11 -34
- data/lib/inquery/method_accessible_hash.rb +45 -0
- data/lib/inquery/mixins/raw_sql_utils.rb +32 -6
- data/lib/inquery/mixins/relation_validation.rb +1 -1
- data/lib/inquery/query/chainable.rb +69 -27
- data/lib/inquery/query.rb +67 -14
- data/lib/inquery.rb +2 -0
- data/test/inquery/error_handling_test.rb +117 -0
- data/test/inquery/method_accessible_hash_test.rb +85 -0
- data/test/inquery/mixins/raw_sql_utils_test.rb +67 -0
- data/test/inquery/query/chainable_test.rb +78 -0
- data/test/inquery/query_test.rb +86 -0
- data/test/test_helper.rb +11 -0
- metadata +30 -129
- data/.yardopts +0 -1
data/doc/Inquery/Query.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<title>
|
|
7
7
|
Class: Inquery::Query
|
|
8
8
|
|
|
9
|
-
— Documentation by YARD 0.9.
|
|
9
|
+
— Documentation by YARD 0.9.37
|
|
10
10
|
|
|
11
11
|
</title>
|
|
12
12
|
|
|
@@ -104,7 +104,31 @@
|
|
|
104
104
|
|
|
105
105
|
</div>
|
|
106
106
|
|
|
107
|
-
<div
|
|
107
|
+
<h2>Overview</h2><div class="docstring">
|
|
108
|
+
<div class="discussion">
|
|
109
|
+
|
|
110
|
+
<p>Base query class that encapsulates database queries in reusable classes.</p>
|
|
111
|
+
|
|
112
|
+
<p>Subclasses must implement the ‘call’ method to define the query logic. Optionally, override ‘process’ to transform the query results.</p>
|
|
113
|
+
|
|
114
|
+
<p>Example:</p>
|
|
115
|
+
|
|
116
|
+
<pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>FetchActiveUsers</span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="../Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'>Query</span>
|
|
117
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
|
|
118
|
+
<span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='label'>active:</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
|
119
|
+
<span class='kw'>end</span>
|
|
120
|
+
<span class='kw'>end</span>
|
|
121
|
+
|
|
122
|
+
<span class='const'>FetchActiveUsers</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span> <span class='comment'># => Returns active users
|
|
123
|
+
</span></code></pre>
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
<div class="tags">
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
</div><div id="subclasses">
|
|
108
132
|
<h2>Direct Known Subclasses</h2>
|
|
109
133
|
<p class="children"><span class='object_link'><a href="Query/Chainable.html" title="Inquery::Query::Chainable (class)">Chainable</a></span></p>
|
|
110
134
|
</div>
|
|
@@ -147,7 +171,8 @@
|
|
|
147
171
|
|
|
148
172
|
|
|
149
173
|
|
|
150
|
-
<span class="summary_desc"><div class='inline'
|
|
174
|
+
<span class="summary_desc"><div class='inline'>
|
|
175
|
+
<p>Returns the value of attribute params.</p>
|
|
151
176
|
</div></span>
|
|
152
177
|
|
|
153
178
|
</li>
|
|
@@ -183,7 +208,8 @@
|
|
|
183
208
|
|
|
184
209
|
|
|
185
210
|
|
|
186
|
-
<span class="summary_desc"><div class='inline'
|
|
211
|
+
<span class="summary_desc"><div class='inline'>
|
|
212
|
+
<p>Instantiates the query class with the given params and executes only the ‘call’ method, skipping post-processing.</p>
|
|
187
213
|
</div></span>
|
|
188
214
|
|
|
189
215
|
</li>
|
|
@@ -206,7 +232,8 @@
|
|
|
206
232
|
|
|
207
233
|
|
|
208
234
|
|
|
209
|
-
<span class="summary_desc"><div class='inline'
|
|
235
|
+
<span class="summary_desc"><div class='inline'>
|
|
236
|
+
<p>Instantiates the query class with the given params and executes both ‘call’ and ‘process’ methods.</p>
|
|
210
237
|
</div></span>
|
|
211
238
|
|
|
212
239
|
</li>
|
|
@@ -238,7 +265,8 @@
|
|
|
238
265
|
|
|
239
266
|
|
|
240
267
|
|
|
241
|
-
<span class="summary_desc"><div class='inline'
|
|
268
|
+
<span class="summary_desc"><div class='inline'>
|
|
269
|
+
<p>Override this method in subclasses to define the query logic.</p>
|
|
242
270
|
</div></span>
|
|
243
271
|
|
|
244
272
|
</li>
|
|
@@ -247,7 +275,7 @@
|
|
|
247
275
|
<li class="public ">
|
|
248
276
|
<span class="summary_signature">
|
|
249
277
|
|
|
250
|
-
<a href="#connection-instance_method" title="#connection (instance method)">#<strong>connection</strong> ⇒
|
|
278
|
+
<a href="#connection-instance_method" title="#connection (instance method)">#<strong>connection</strong> ⇒ ActiveRecord::ConnectionAdapters::AbstractAdapter </a>
|
|
251
279
|
|
|
252
280
|
|
|
253
281
|
|
|
@@ -261,7 +289,8 @@
|
|
|
261
289
|
|
|
262
290
|
|
|
263
291
|
|
|
264
|
-
<span class="summary_desc"><div class='inline'
|
|
292
|
+
<span class="summary_desc"><div class='inline'>
|
|
293
|
+
<p>Returns the database connection to use for this query.</p>
|
|
265
294
|
</div></span>
|
|
266
295
|
|
|
267
296
|
</li>
|
|
@@ -286,7 +315,8 @@
|
|
|
286
315
|
|
|
287
316
|
|
|
288
317
|
|
|
289
|
-
<span class="summary_desc"><div class='inline'
|
|
318
|
+
<span class="summary_desc"><div class='inline'>
|
|
319
|
+
<p>Initializes a new query instance with the given parameters.</p>
|
|
290
320
|
</div></span>
|
|
291
321
|
|
|
292
322
|
</li>
|
|
@@ -295,7 +325,7 @@
|
|
|
295
325
|
<li class="public ">
|
|
296
326
|
<span class="summary_signature">
|
|
297
327
|
|
|
298
|
-
<a href="#osparams-instance_method" title="#osparams (instance method)">#<strong>osparams</strong> ⇒
|
|
328
|
+
<a href="#osparams-instance_method" title="#osparams (instance method)">#<strong>osparams</strong> ⇒ MethodAccessibleHash </a>
|
|
299
329
|
|
|
300
330
|
|
|
301
331
|
|
|
@@ -309,7 +339,8 @@
|
|
|
309
339
|
|
|
310
340
|
|
|
311
341
|
|
|
312
|
-
<span class="summary_desc"><div class='inline'
|
|
342
|
+
<span class="summary_desc"><div class='inline'>
|
|
343
|
+
<p>Returns the query params wrapped in a MethodAccessibleHash for convenient access using dot notation.</p>
|
|
313
344
|
</div></span>
|
|
314
345
|
|
|
315
346
|
</li>
|
|
@@ -332,7 +363,8 @@
|
|
|
332
363
|
|
|
333
364
|
|
|
334
365
|
|
|
335
|
-
<span class="summary_desc"><div class='inline'
|
|
366
|
+
<span class="summary_desc"><div class='inline'>
|
|
367
|
+
<p>Override this method in subclasses to transform the query results.</p>
|
|
336
368
|
</div></span>
|
|
337
369
|
|
|
338
370
|
</li>
|
|
@@ -355,7 +387,8 @@
|
|
|
355
387
|
|
|
356
388
|
|
|
357
389
|
|
|
358
|
-
<span class="summary_desc"><div class='inline'
|
|
390
|
+
<span class="summary_desc"><div class='inline'>
|
|
391
|
+
<p>Executes the query by calling ‘call’ and then ‘process’.</p>
|
|
359
392
|
</div></span>
|
|
360
393
|
|
|
361
394
|
</li>
|
|
@@ -392,14 +425,56 @@
|
|
|
392
425
|
|
|
393
426
|
</h3><div class="docstring">
|
|
394
427
|
<div class="discussion">
|
|
395
|
-
|
|
396
|
-
|
|
428
|
+
|
|
429
|
+
<p>Initializes a new query instance with the given parameters.</p>
|
|
430
|
+
|
|
431
|
+
<p>If a schema is defined using ‘schema’ or ‘schema3’, the params will be validated against it before the query is executed.</p>
|
|
397
432
|
|
|
398
433
|
|
|
399
434
|
</div>
|
|
400
435
|
</div>
|
|
401
436
|
<div class="tags">
|
|
437
|
+
<p class="tag_title">Parameters:</p>
|
|
438
|
+
<ul class="param">
|
|
402
439
|
|
|
440
|
+
<li>
|
|
441
|
+
|
|
442
|
+
<span class='name'>params</span>
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
—
|
|
452
|
+
<div class='inline'>
|
|
453
|
+
<p>Parameters for the query</p>
|
|
454
|
+
</div>
|
|
455
|
+
|
|
456
|
+
</li>
|
|
457
|
+
|
|
458
|
+
</ul>
|
|
459
|
+
|
|
460
|
+
<p class="tag_title">Raises:</p>
|
|
461
|
+
<ul class="raise">
|
|
462
|
+
|
|
463
|
+
<li>
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
<span class='type'>(<tt>Schemacop::Exceptions::ValidationError</tt>)</span>
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
—
|
|
471
|
+
<div class='inline'>
|
|
472
|
+
<p>if params don’t match schema</p>
|
|
473
|
+
</div>
|
|
474
|
+
|
|
475
|
+
</li>
|
|
476
|
+
|
|
477
|
+
</ul>
|
|
403
478
|
|
|
404
479
|
</div><table class="source_code">
|
|
405
480
|
<tr>
|
|
@@ -407,16 +482,16 @@ was a validation schema specified).</p>
|
|
|
407
482
|
<pre class="lines">
|
|
408
483
|
|
|
409
484
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
485
|
+
52
|
|
486
|
+
53
|
|
487
|
+
54
|
|
488
|
+
55
|
|
489
|
+
56
|
|
490
|
+
57
|
|
491
|
+
58</pre>
|
|
417
492
|
</td>
|
|
418
493
|
<td>
|
|
419
|
-
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line
|
|
494
|
+
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line 52</span>
|
|
420
495
|
|
|
421
496
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
422
497
|
<span class='ivar'>@params</span> <span class='op'>=</span> <span class='id identifier rubyid_params'>params</span>
|
|
@@ -448,7 +523,8 @@ was a validation schema specified).</p>
|
|
|
448
523
|
|
|
449
524
|
</h3><div class="docstring">
|
|
450
525
|
<div class="discussion">
|
|
451
|
-
|
|
526
|
+
|
|
527
|
+
<p>Returns the value of attribute params.</p>
|
|
452
528
|
|
|
453
529
|
|
|
454
530
|
</div>
|
|
@@ -462,12 +538,12 @@ was a validation schema specified).</p>
|
|
|
462
538
|
<pre class="lines">
|
|
463
539
|
|
|
464
540
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
541
|
+
19
|
|
542
|
+
20
|
|
543
|
+
21</pre>
|
|
468
544
|
</td>
|
|
469
545
|
<td>
|
|
470
|
-
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line
|
|
546
|
+
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line 19</span>
|
|
471
547
|
|
|
472
548
|
<span class='kw'>def</span> <span class='id identifier rubyid_params'>params</span>
|
|
473
549
|
<span class='ivar'>@params</span>
|
|
@@ -495,14 +571,70 @@ was a validation schema specified).</p>
|
|
|
495
571
|
|
|
496
572
|
</h3><div class="docstring">
|
|
497
573
|
<div class="discussion">
|
|
498
|
-
|
|
499
|
-
and
|
|
574
|
+
|
|
575
|
+
<p>Instantiates the query class with the given params and executes only the ‘call’ method, skipping post-processing.</p>
|
|
500
576
|
|
|
501
577
|
|
|
502
578
|
</div>
|
|
503
579
|
</div>
|
|
504
580
|
<div class="tags">
|
|
581
|
+
<p class="tag_title">Parameters:</p>
|
|
582
|
+
<ul class="param">
|
|
583
|
+
|
|
584
|
+
<li>
|
|
585
|
+
|
|
586
|
+
<span class='name'>args</span>
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
—
|
|
594
|
+
<div class='inline'>
|
|
595
|
+
<p>Parameters to pass to the query</p>
|
|
596
|
+
</div>
|
|
597
|
+
|
|
598
|
+
</li>
|
|
599
|
+
|
|
600
|
+
</ul>
|
|
601
|
+
|
|
602
|
+
<p class="tag_title">Returns:</p>
|
|
603
|
+
<ul class="return">
|
|
604
|
+
|
|
605
|
+
<li>
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
—
|
|
613
|
+
<div class='inline'>
|
|
614
|
+
<p>The raw query results</p>
|
|
615
|
+
</div>
|
|
616
|
+
|
|
617
|
+
</li>
|
|
505
618
|
|
|
619
|
+
</ul>
|
|
620
|
+
<p class="tag_title">Raises:</p>
|
|
621
|
+
<ul class="raise">
|
|
622
|
+
|
|
623
|
+
<li>
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
<span class='type'>(<tt>Schemacop::Exceptions::ValidationError</tt>)</span>
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
—
|
|
631
|
+
<div class='inline'>
|
|
632
|
+
<p>if params don’t match schema</p>
|
|
633
|
+
</div>
|
|
634
|
+
|
|
635
|
+
</li>
|
|
636
|
+
|
|
637
|
+
</ul>
|
|
506
638
|
|
|
507
639
|
</div><table class="source_code">
|
|
508
640
|
<tr>
|
|
@@ -510,12 +642,12 @@ and runs <code>call</code> on it.</p>
|
|
|
510
642
|
<pre class="lines">
|
|
511
643
|
|
|
512
644
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
645
|
+
41
|
|
646
|
+
42
|
|
647
|
+
43</pre>
|
|
516
648
|
</td>
|
|
517
649
|
<td>
|
|
518
|
-
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line
|
|
650
|
+
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line 41</span>
|
|
519
651
|
|
|
520
652
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
|
521
653
|
<span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
|
|
@@ -536,14 +668,72 @@ and runs <code>call</code> on it.</p>
|
|
|
536
668
|
|
|
537
669
|
</h3><div class="docstring">
|
|
538
670
|
<div class="discussion">
|
|
539
|
-
|
|
540
|
-
and
|
|
671
|
+
|
|
672
|
+
<p>Instantiates the query class with the given params and executes both ‘call’ and ‘process’ methods.</p>
|
|
673
|
+
|
|
674
|
+
<p>This is the primary way to execute queries. It runs the query logic defined in ‘call’ and then passes the results through ‘process’ for any post-processing.</p>
|
|
541
675
|
|
|
542
676
|
|
|
543
677
|
</div>
|
|
544
678
|
</div>
|
|
545
679
|
<div class="tags">
|
|
680
|
+
<p class="tag_title">Parameters:</p>
|
|
681
|
+
<ul class="param">
|
|
682
|
+
|
|
683
|
+
<li>
|
|
684
|
+
|
|
685
|
+
<span class='name'>args</span>
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
—
|
|
693
|
+
<div class='inline'>
|
|
694
|
+
<p>Parameters to pass to the query</p>
|
|
695
|
+
</div>
|
|
696
|
+
|
|
697
|
+
</li>
|
|
698
|
+
|
|
699
|
+
</ul>
|
|
700
|
+
|
|
701
|
+
<p class="tag_title">Returns:</p>
|
|
702
|
+
<ul class="return">
|
|
703
|
+
|
|
704
|
+
<li>
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
—
|
|
712
|
+
<div class='inline'>
|
|
713
|
+
<p>The processed query results</p>
|
|
714
|
+
</div>
|
|
715
|
+
|
|
716
|
+
</li>
|
|
717
|
+
|
|
718
|
+
</ul>
|
|
719
|
+
<p class="tag_title">Raises:</p>
|
|
720
|
+
<ul class="raise">
|
|
546
721
|
|
|
722
|
+
<li>
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
<span class='type'>(<tt>Schemacop::Exceptions::ValidationError</tt>)</span>
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
—
|
|
730
|
+
<div class='inline'>
|
|
731
|
+
<p>if params don’t match schema</p>
|
|
732
|
+
</div>
|
|
733
|
+
|
|
734
|
+
</li>
|
|
735
|
+
|
|
736
|
+
</ul>
|
|
547
737
|
|
|
548
738
|
</div><table class="source_code">
|
|
549
739
|
<tr>
|
|
@@ -551,12 +741,12 @@ and runs <code>call</code> and <code>process</code> on it.</p>
|
|
|
551
741
|
<pre class="lines">
|
|
552
742
|
|
|
553
743
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
744
|
+
31
|
|
745
|
+
32
|
|
746
|
+
33</pre>
|
|
557
747
|
</td>
|
|
558
748
|
<td>
|
|
559
|
-
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line
|
|
749
|
+
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line 31</span>
|
|
560
750
|
|
|
561
751
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
|
562
752
|
<span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span>
|
|
@@ -583,13 +773,50 @@ and runs <code>call</code> and <code>process</code> on it.</p>
|
|
|
583
773
|
|
|
584
774
|
</h3><div class="docstring">
|
|
585
775
|
<div class="discussion">
|
|
586
|
-
|
|
776
|
+
|
|
777
|
+
<p>Override this method in subclasses to define the query logic.</p>
|
|
587
778
|
|
|
588
779
|
|
|
589
780
|
</div>
|
|
590
781
|
</div>
|
|
591
782
|
<div class="tags">
|
|
592
783
|
|
|
784
|
+
<p class="tag_title">Returns:</p>
|
|
785
|
+
<ul class="return">
|
|
786
|
+
|
|
787
|
+
<li>
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
—
|
|
795
|
+
<div class='inline'>
|
|
796
|
+
<p>Query results (typically an ActiveRecord::Relation)</p>
|
|
797
|
+
</div>
|
|
798
|
+
|
|
799
|
+
</li>
|
|
800
|
+
|
|
801
|
+
</ul>
|
|
802
|
+
<p class="tag_title">Raises:</p>
|
|
803
|
+
<ul class="raise">
|
|
804
|
+
|
|
805
|
+
<li>
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
<span class='type'>(<tt>NotImplementedError</tt>)</span>
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
—
|
|
813
|
+
<div class='inline'>
|
|
814
|
+
<p>if not overridden in subclass</p>
|
|
815
|
+
</div>
|
|
816
|
+
|
|
817
|
+
</li>
|
|
818
|
+
|
|
819
|
+
</ul>
|
|
593
820
|
|
|
594
821
|
</div><table class="source_code">
|
|
595
822
|
<tr>
|
|
@@ -597,12 +824,12 @@ and runs <code>call</code> and <code>process</code> on it.</p>
|
|
|
597
824
|
<pre class="lines">
|
|
598
825
|
|
|
599
826
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
827
|
+
71
|
|
828
|
+
72
|
|
829
|
+
73</pre>
|
|
603
830
|
</td>
|
|
604
831
|
<td>
|
|
605
|
-
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line
|
|
832
|
+
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line 71</span>
|
|
606
833
|
|
|
607
834
|
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
|
|
608
835
|
<span class='id identifier rubyid_fail'>fail</span> <span class='const'>NotImplementedError</span>
|
|
@@ -615,7 +842,7 @@ and runs <code>call</code> and <code>process</code> on it.</p>
|
|
|
615
842
|
<div class="method_details ">
|
|
616
843
|
<h3 class="signature " id="connection-instance_method">
|
|
617
844
|
|
|
618
|
-
#<strong>connection</strong> ⇒ <tt>
|
|
845
|
+
#<strong>connection</strong> ⇒ <tt>ActiveRecord::ConnectionAdapters::AbstractAdapter</tt>
|
|
619
846
|
|
|
620
847
|
|
|
621
848
|
|
|
@@ -623,14 +850,29 @@ and runs <code>call</code> and <code>process</code> on it.</p>
|
|
|
623
850
|
|
|
624
851
|
</h3><div class="docstring">
|
|
625
852
|
<div class="discussion">
|
|
626
|
-
|
|
627
|
-
|
|
853
|
+
|
|
854
|
+
<p>Returns the database connection to use for this query.</p>
|
|
855
|
+
|
|
856
|
+
<p>Override this method if you need to use a different connection than the default ActiveRecord connection.</p>
|
|
628
857
|
|
|
629
858
|
|
|
630
859
|
</div>
|
|
631
860
|
</div>
|
|
632
861
|
<div class="tags">
|
|
633
862
|
|
|
863
|
+
<p class="tag_title">Returns:</p>
|
|
864
|
+
<ul class="return">
|
|
865
|
+
|
|
866
|
+
<li>
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
<span class='type'>(<tt>ActiveRecord::ConnectionAdapters::AbstractAdapter</tt>)</span>
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
</li>
|
|
874
|
+
|
|
875
|
+
</ul>
|
|
634
876
|
|
|
635
877
|
</div><table class="source_code">
|
|
636
878
|
<tr>
|
|
@@ -638,12 +880,12 @@ connection is desired. Defaults to <code>ActiveRecord::Base.connection</code>.</
|
|
|
638
880
|
<pre class="lines">
|
|
639
881
|
|
|
640
882
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
883
|
+
106
|
|
884
|
+
107
|
|
885
|
+
108</pre>
|
|
644
886
|
</td>
|
|
645
887
|
<td>
|
|
646
|
-
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line
|
|
888
|
+
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line 106</span>
|
|
647
889
|
|
|
648
890
|
<span class='kw'>def</span> <span class='id identifier rubyid_connection'>connection</span>
|
|
649
891
|
<span class='const'>ActiveRecord</span><span class='op'>::</span><span class='const'>Base</span><span class='period'>.</span><span class='id identifier rubyid_connection'>connection</span>
|
|
@@ -656,7 +898,7 @@ connection is desired. Defaults to <code>ActiveRecord::Base.connection</code>.</
|
|
|
656
898
|
<div class="method_details ">
|
|
657
899
|
<h3 class="signature " id="osparams-instance_method">
|
|
658
900
|
|
|
659
|
-
#<strong>osparams</strong> ⇒ <tt>
|
|
901
|
+
#<strong>osparams</strong> ⇒ <tt><span class='object_link'><a href="MethodAccessibleHash.html" title="Inquery::MethodAccessibleHash (class)">MethodAccessibleHash</a></span></tt>
|
|
660
902
|
|
|
661
903
|
|
|
662
904
|
|
|
@@ -664,14 +906,40 @@ connection is desired. Defaults to <code>ActiveRecord::Base.connection</code>.</
|
|
|
664
906
|
|
|
665
907
|
</h3><div class="docstring">
|
|
666
908
|
<div class="discussion">
|
|
667
|
-
|
|
668
|
-
|
|
909
|
+
|
|
910
|
+
<p>Returns the query params wrapped in a MethodAccessibleHash for convenient access using dot notation.</p>
|
|
911
|
+
|
|
912
|
+
<p>Example:</p>
|
|
913
|
+
|
|
914
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_schema3'>schema3</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_str!'>str!</span> <span class='symbol'>:name</span> <span class='rbrace'>}</span>
|
|
915
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
|
|
916
|
+
<span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='label'>name:</span> <span class='id identifier rubyid_osparams'>osparams</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span> <span class='comment'># Access via dot notation
|
|
917
|
+
</span><span class='kw'>end</span>
|
|
918
|
+
</code></pre>
|
|
669
919
|
|
|
670
920
|
|
|
671
921
|
</div>
|
|
672
922
|
</div>
|
|
673
923
|
<div class="tags">
|
|
674
924
|
|
|
925
|
+
<p class="tag_title">Returns:</p>
|
|
926
|
+
<ul class="return">
|
|
927
|
+
|
|
928
|
+
<li>
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
<span class='type'>(<tt><span class='object_link'><a href="MethodAccessibleHash.html" title="Inquery::MethodAccessibleHash (class)">MethodAccessibleHash</a></span></tt>)</span>
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
—
|
|
936
|
+
<div class='inline'>
|
|
937
|
+
<p>Params with method access</p>
|
|
938
|
+
</div>
|
|
939
|
+
|
|
940
|
+
</li>
|
|
941
|
+
|
|
942
|
+
</ul>
|
|
675
943
|
|
|
676
944
|
</div><table class="source_code">
|
|
677
945
|
<tr>
|
|
@@ -679,15 +947,15 @@ easyer access.</p>
|
|
|
679
947
|
<pre class="lines">
|
|
680
948
|
|
|
681
949
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
950
|
+
96
|
|
951
|
+
97
|
|
952
|
+
98</pre>
|
|
685
953
|
</td>
|
|
686
954
|
<td>
|
|
687
|
-
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line
|
|
955
|
+
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line 96</span>
|
|
688
956
|
|
|
689
957
|
<span class='kw'>def</span> <span class='id identifier rubyid_osparams'>osparams</span>
|
|
690
|
-
<span class='ivar'>@osparams</span> <span class='op'>||=</span> <span class='const'>
|
|
958
|
+
<span class='ivar'>@osparams</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="MethodAccessibleHash.html" title="Inquery::MethodAccessibleHash (class)">MethodAccessibleHash</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="MethodAccessibleHash.html#initialize-instance_method" title="Inquery::MethodAccessibleHash#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span>
|
|
691
959
|
<span class='kw'>end</span></pre>
|
|
692
960
|
</td>
|
|
693
961
|
</tr>
|
|
@@ -705,13 +973,54 @@ easyer access.</p>
|
|
|
705
973
|
|
|
706
974
|
</h3><div class="docstring">
|
|
707
975
|
<div class="discussion">
|
|
708
|
-
|
|
976
|
+
|
|
977
|
+
<p>Override this method in subclasses to transform the query results.</p>
|
|
978
|
+
|
|
979
|
+
<p>By default, returns the results unchanged. Common uses include converting to JSON, counting records, or extracting specific fields.</p>
|
|
709
980
|
|
|
710
981
|
|
|
711
982
|
</div>
|
|
712
983
|
</div>
|
|
713
984
|
<div class="tags">
|
|
985
|
+
<p class="tag_title">Parameters:</p>
|
|
986
|
+
<ul class="param">
|
|
987
|
+
|
|
988
|
+
<li>
|
|
989
|
+
|
|
990
|
+
<span class='name'>results</span>
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
|
994
|
+
|
|
995
|
+
|
|
996
|
+
|
|
997
|
+
—
|
|
998
|
+
<div class='inline'>
|
|
999
|
+
<p>The results from the ‘call’ method</p>
|
|
1000
|
+
</div>
|
|
1001
|
+
|
|
1002
|
+
</li>
|
|
714
1003
|
|
|
1004
|
+
</ul>
|
|
1005
|
+
|
|
1006
|
+
<p class="tag_title">Returns:</p>
|
|
1007
|
+
<ul class="return">
|
|
1008
|
+
|
|
1009
|
+
<li>
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
—
|
|
1017
|
+
<div class='inline'>
|
|
1018
|
+
<p>The processed results</p>
|
|
1019
|
+
</div>
|
|
1020
|
+
|
|
1021
|
+
</li>
|
|
1022
|
+
|
|
1023
|
+
</ul>
|
|
715
1024
|
|
|
716
1025
|
</div><table class="source_code">
|
|
717
1026
|
<tr>
|
|
@@ -719,12 +1028,12 @@ easyer access.</p>
|
|
|
719
1028
|
<pre class="lines">
|
|
720
1029
|
|
|
721
1030
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
1031
|
+
82
|
|
1032
|
+
83
|
|
1033
|
+
84</pre>
|
|
725
1034
|
</td>
|
|
726
1035
|
<td>
|
|
727
|
-
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line
|
|
1036
|
+
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line 82</span>
|
|
728
1037
|
|
|
729
1038
|
<span class='kw'>def</span> <span class='id identifier rubyid_process'>process</span><span class='lparen'>(</span><span class='id identifier rubyid_results'>results</span><span class='rparen'>)</span>
|
|
730
1039
|
<span class='id identifier rubyid_results'>results</span>
|
|
@@ -745,13 +1054,32 @@ easyer access.</p>
|
|
|
745
1054
|
|
|
746
1055
|
</h3><div class="docstring">
|
|
747
1056
|
<div class="discussion">
|
|
748
|
-
|
|
1057
|
+
|
|
1058
|
+
<p>Executes the query by calling ‘call’ and then ‘process’.</p>
|
|
749
1059
|
|
|
750
1060
|
|
|
751
1061
|
</div>
|
|
752
1062
|
</div>
|
|
753
1063
|
<div class="tags">
|
|
754
1064
|
|
|
1065
|
+
<p class="tag_title">Returns:</p>
|
|
1066
|
+
<ul class="return">
|
|
1067
|
+
|
|
1068
|
+
<li>
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
—
|
|
1076
|
+
<div class='inline'>
|
|
1077
|
+
<p>The processed query results</p>
|
|
1078
|
+
</div>
|
|
1079
|
+
|
|
1080
|
+
</li>
|
|
1081
|
+
|
|
1082
|
+
</ul>
|
|
755
1083
|
|
|
756
1084
|
</div><table class="source_code">
|
|
757
1085
|
<tr>
|
|
@@ -759,12 +1087,12 @@ easyer access.</p>
|
|
|
759
1087
|
<pre class="lines">
|
|
760
1088
|
|
|
761
1089
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
1090
|
+
63
|
|
1091
|
+
64
|
|
1092
|
+
65</pre>
|
|
765
1093
|
</td>
|
|
766
1094
|
<td>
|
|
767
|
-
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line
|
|
1095
|
+
<pre class="code"><span class="info file"># File 'lib/inquery/query.rb', line 63</span>
|
|
768
1096
|
|
|
769
1097
|
<span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span>
|
|
770
1098
|
<span class='id identifier rubyid_process'>process</span><span class='lparen'>(</span><span class='id identifier rubyid_call'>call</span><span class='rparen'>)</span>
|
|
@@ -779,9 +1107,9 @@ easyer access.</p>
|
|
|
779
1107
|
</div>
|
|
780
1108
|
|
|
781
1109
|
<div id="footer">
|
|
782
|
-
Generated on
|
|
783
|
-
<a href="
|
|
784
|
-
0.9.
|
|
1110
|
+
Generated on Mon Jan 5 14:06:48 2026 by
|
|
1111
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1112
|
+
0.9.37 (ruby-3.3.5).
|
|
785
1113
|
</div>
|
|
786
1114
|
|
|
787
1115
|
</div>
|