quo 0.3.1 → 0.4.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/README.md +3 -3
- data/Steepfile +1 -0
- data/lib/quo/eager_query.rb +23 -3
- data/lib/quo/merged_query.rb +4 -4
- data/lib/quo/query.rb +36 -22
- data/lib/quo/query_composer.rb +34 -22
- data/lib/quo/{enumerator.rb → results.rb} +4 -3
- data/lib/quo/rspec/helpers.rb +2 -2
- data/lib/quo/utilities/callstack.rb +1 -1
- data/lib/quo/utilities/wrap.rb +1 -1
- data/lib/quo/version.rb +1 -1
- data/lib/quo/wrapped_query.rb +1 -1
- data/lib/quo.rb +8 -2
- data/sig/quo/eager_query.rbs +7 -2
- data/sig/quo/merged_query.rbs +3 -1
- data/sig/quo/query.rbs +5 -5
- data/sig/quo/query_composer.rbs +16 -2
- data/sig/quo/{enumerator.rbs → results.rbs} +2 -2
- data/sig/quo/wrapped_query.rbs +2 -2
- data/sig/quo.rbs +7 -2
- 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: 61bf7495c0092bf641ff6e85bed8dc0073ea61e15a5292f0825f50eca4348a92
|
4
|
+
data.tar.gz: c10cc10dfe8ce323e4395640604a1c6358333bb7ea26b1c109d43eee67ed2d73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8e4105330e725058ca4c94f2c58229a0018e9379c38ac189cc2dbd007163468b845dd9632d727f824a35d4bc8cebbb7e40f5d24267277b0c1cbe0b580abb100
|
7
|
+
data.tar.gz: 7180ea2d74f1849628a1635c381685c5d2841c27229868280cd59a580dae759d61cc5236fba06b4044a93b667a23f670f4ba5960720165ccb1a6a103a4d06f37
|
data/README.md
CHANGED
@@ -229,7 +229,7 @@ q.count # array size
|
|
229
229
|
`Quo::EagerQuery` is a subclass of `Quo::Query` which takes a data value on instantiation and returns it on calls to `query`
|
230
230
|
|
231
231
|
```ruby
|
232
|
-
q = Quo::EagerQuery.new(
|
232
|
+
q = Quo::EagerQuery.new([1, 2, 3])
|
233
233
|
q.eager? # is it 'eager'? Yes it is!
|
234
234
|
q.count # '3'
|
235
235
|
```
|
@@ -242,7 +242,7 @@ actually just a page of the data and not the total count.
|
|
242
242
|
Example of an EagerQuery used to wrap a page of enumerable data:
|
243
243
|
|
244
244
|
```ruby
|
245
|
-
Quo::EagerQuery.new(
|
245
|
+
Quo::EagerQuery.new(my_data, total_count: 100, page: current_page)
|
246
246
|
```
|
247
247
|
|
248
248
|
### Composition
|
@@ -262,7 +262,7 @@ composed.last
|
|
262
262
|
composed.first
|
263
263
|
# => #<Tag id: ...>
|
264
264
|
|
265
|
-
Quo::EagerQuery.new([3, 4]).compose(Quo::EagerQuery.new(
|
265
|
+
Quo::EagerQuery.new([3, 4]).compose(Quo::EagerQuery.new([1, 2])).last
|
266
266
|
# => 2
|
267
267
|
Quo::Query.compose([1, 2], [3, 4]).last
|
268
268
|
# => 4
|
data/Steepfile
CHANGED
data/lib/quo/eager_query.rb
CHANGED
@@ -2,9 +2,29 @@
|
|
2
2
|
|
3
3
|
module Quo
|
4
4
|
class EagerQuery < Quo::Query
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
class << self
|
6
|
+
def call(**options)
|
7
|
+
build_from_options(options).first
|
8
|
+
end
|
9
|
+
|
10
|
+
def call!(**options)
|
11
|
+
build_from_options(options).first!
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_from_options(options)
|
15
|
+
collection = options[:collection]
|
16
|
+
raise ArgumentError, "EagerQuery needs a collection" unless collection
|
17
|
+
new(collection, **options.except(:collection))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(collection, **options)
|
22
|
+
@collection = Array.wrap(collection)
|
23
|
+
super(**options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def copy(**options)
|
27
|
+
self.class.new(@collection, **@options.merge(options))
|
8
28
|
end
|
9
29
|
|
10
30
|
# Optionally return the `total_count` option if it has been set.
|
data/lib/quo/merged_query.rb
CHANGED
@@ -4,18 +4,18 @@ module Quo
|
|
4
4
|
class MergedQuery < Quo::Query
|
5
5
|
class << self
|
6
6
|
def call(**options)
|
7
|
-
build_from_options(
|
7
|
+
build_from_options(options).first
|
8
8
|
end
|
9
9
|
|
10
10
|
def call!(**options)
|
11
|
-
build_from_options(
|
11
|
+
build_from_options(options).first!
|
12
12
|
end
|
13
13
|
|
14
|
-
def build_from_options(
|
14
|
+
def build_from_options(options)
|
15
15
|
merged_query = options[:merged_query]
|
16
16
|
left = options[:left]
|
17
17
|
right = options[:right]
|
18
|
-
raise ArgumentError "MergedQuery needs the merged result and operands" unless merged_query && left && right
|
18
|
+
raise ArgumentError, "MergedQuery needs the merged result and operands" unless merged_query && left && right
|
19
19
|
new(merged_query, left, right, **options)
|
20
20
|
end
|
21
21
|
end
|
data/lib/quo/query.rb
CHANGED
@@ -28,7 +28,7 @@ module Quo
|
|
28
28
|
def initialize(**options)
|
29
29
|
@options = options
|
30
30
|
@current_page = options[:page]&.to_i || options[:current_page]&.to_i
|
31
|
-
@page_size = options[:page_size]&.to_i || 20
|
31
|
+
@page_size = options[:page_size]&.to_i || Quo.configuration.default_page_size || 20
|
32
32
|
end
|
33
33
|
|
34
34
|
# Returns a active record query, or a Quo::Query instance
|
@@ -93,57 +93,56 @@ module Quo
|
|
93
93
|
delegate :model, :klass, to: :underlying_query
|
94
94
|
|
95
95
|
# Get first elements
|
96
|
-
def first(
|
96
|
+
def first(limit = nil)
|
97
97
|
if transform?
|
98
|
-
res = query_with_logging.first(
|
98
|
+
res = query_with_logging.first(limit)
|
99
99
|
if res.is_a? Array
|
100
|
-
res.map.with_index { |r, i| transformer
|
100
|
+
res.map.with_index { |r, i| transformer&.call(r, i) }
|
101
101
|
elsif !res.nil?
|
102
|
-
transformer
|
102
|
+
transformer&.call(query_with_logging.first(limit))
|
103
103
|
end
|
104
104
|
else
|
105
|
-
query_with_logging.first(
|
105
|
+
query_with_logging.first(limit)
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
def first!(
|
110
|
-
item = first(
|
109
|
+
def first!(limit = nil)
|
110
|
+
item = first(limit)
|
111
111
|
raise ActiveRecord::RecordNotFound, "No item could be found!" unless item
|
112
112
|
item
|
113
113
|
end
|
114
114
|
|
115
115
|
# Get last elements
|
116
|
-
def last(
|
116
|
+
def last(limit = nil)
|
117
117
|
if transform?
|
118
|
-
res = query_with_logging.last(
|
118
|
+
res = query_with_logging.last(limit)
|
119
119
|
if res.is_a? Array
|
120
|
-
res.map.with_index { |r, i| transformer
|
120
|
+
res.map.with_index { |r, i| transformer&.call(r, i) }
|
121
121
|
elsif !res.nil?
|
122
|
-
transformer
|
122
|
+
transformer&.call(res)
|
123
123
|
end
|
124
124
|
else
|
125
|
-
query_with_logging.last(
|
125
|
+
query_with_logging.last(limit)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
129
|
# Convert to array
|
130
130
|
def to_a
|
131
131
|
arr = query_with_logging.to_a
|
132
|
-
transform? ? arr.map.with_index { |r, i| transformer
|
132
|
+
transform? ? arr.map.with_index { |r, i| transformer&.call(r, i) } : arr
|
133
133
|
end
|
134
134
|
|
135
135
|
# Convert to EagerQuery, and load all data
|
136
136
|
def to_eager(more_opts = {})
|
137
|
-
Quo::EagerQuery.new(
|
137
|
+
Quo::EagerQuery.new(to_a, **options.merge(more_opts))
|
138
138
|
end
|
139
139
|
alias_method :load, :to_eager
|
140
140
|
|
141
|
-
|
142
|
-
|
143
|
-
Quo::Enumerator.new(self, transformer: transformer)
|
141
|
+
def results
|
142
|
+
Quo::Results.new(self, transformer: transformer)
|
144
143
|
end
|
145
144
|
|
146
|
-
# Some convenience methods for
|
145
|
+
# Some convenience methods for working with results
|
147
146
|
delegate :each,
|
148
147
|
:map,
|
149
148
|
:flat_map,
|
@@ -151,8 +150,9 @@ module Quo
|
|
151
150
|
:reject,
|
152
151
|
:filter,
|
153
152
|
:find,
|
153
|
+
:include?,
|
154
154
|
:each_with_object,
|
155
|
-
to: :
|
155
|
+
to: :results
|
156
156
|
|
157
157
|
# Set a block used to transform data after query fetching
|
158
158
|
def transform(&block)
|
@@ -226,7 +226,11 @@ module Quo
|
|
226
226
|
|
227
227
|
def offset
|
228
228
|
per_page = sanitised_page_size
|
229
|
-
page = current_page&.positive?
|
229
|
+
page = if current_page && current_page&.positive?
|
230
|
+
current_page
|
231
|
+
else
|
232
|
+
1
|
233
|
+
end
|
230
234
|
per_page * (page - 1)
|
231
235
|
end
|
232
236
|
|
@@ -238,7 +242,17 @@ module Quo
|
|
238
242
|
end
|
239
243
|
|
240
244
|
def sanitised_page_size
|
241
|
-
|
245
|
+
if page_size && page_size.positive?
|
246
|
+
given_size = page_size.to_i
|
247
|
+
max_page_size = Quo.configuration.max_page_size || 200
|
248
|
+
if given_size > max_page_size
|
249
|
+
max_page_size
|
250
|
+
else
|
251
|
+
given_size
|
252
|
+
end
|
253
|
+
else
|
254
|
+
Quo.configuration.default_page_size || 20
|
255
|
+
end
|
242
256
|
end
|
243
257
|
|
244
258
|
def query_with_logging
|
data/lib/quo/query_composer.rb
CHANGED
@@ -5,6 +5,10 @@ module Quo
|
|
5
5
|
def initialize(left, right, joins = nil)
|
6
6
|
@left = left
|
7
7
|
@right = right
|
8
|
+
@unwrapped_left = unwrap_relation(left)
|
9
|
+
@unwrapped_right = unwrap_relation(right)
|
10
|
+
@left_relation = @unwrapped_left.is_a?(::ActiveRecord::Relation)
|
11
|
+
@right_relation = @unwrapped_right.is_a?(::ActiveRecord::Relation)
|
8
12
|
@joins = joins
|
9
13
|
end
|
10
14
|
|
@@ -19,22 +23,26 @@ module Quo
|
|
19
23
|
|
20
24
|
private
|
21
25
|
|
22
|
-
attr_reader :left, :right, :joins
|
26
|
+
attr_reader :left, :right, :joins, :unwrapped_left, :unwrapped_right
|
23
27
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
def left_relation?
|
29
|
+
@left_relation
|
30
|
+
end
|
31
|
+
|
32
|
+
def right_relation?
|
33
|
+
@right_relation
|
34
|
+
end
|
29
35
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
elsif
|
35
|
-
|
36
|
-
elsif
|
37
|
-
|
36
|
+
def merge_left_and_right
|
37
|
+
# FIXME: Skipping type checks here, as not sure how to make this type check with RBS
|
38
|
+
__skip__ = if both_relations?
|
39
|
+
apply_joins(unwrapped_left, joins).merge(unwrapped_right)
|
40
|
+
elsif left_relation_right_enumerable?
|
41
|
+
unwrapped_left.to_a + unwrapped_right
|
42
|
+
elsif left_enumerable_right_relation?
|
43
|
+
unwrapped_left + unwrapped_right.to_a
|
44
|
+
else
|
45
|
+
unwrapped_left + unwrapped_right
|
38
46
|
end
|
39
47
|
end
|
40
48
|
|
@@ -49,16 +57,20 @@ module Quo
|
|
49
57
|
query.is_a?(Quo::Query) ? query.unwrap : query
|
50
58
|
end
|
51
59
|
|
52
|
-
def relation_type?(query)
|
53
|
-
if query.is_a?(::Quo::Query)
|
54
|
-
query.relation?
|
55
|
-
else
|
56
|
-
query.is_a?(::ActiveRecord::Relation)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
60
|
def apply_joins(left_rel, joins)
|
61
61
|
joins.present? ? left_rel.joins(joins) : left_rel
|
62
62
|
end
|
63
|
+
|
64
|
+
def both_relations?
|
65
|
+
left_relation? && right_relation?
|
66
|
+
end
|
67
|
+
|
68
|
+
def left_relation_right_enumerable?
|
69
|
+
left_relation? && !right_relation?
|
70
|
+
end
|
71
|
+
|
72
|
+
def left_enumerable_right_relation?
|
73
|
+
!left_relation? && right_relation?
|
74
|
+
end
|
63
75
|
end
|
64
76
|
end
|
@@ -4,7 +4,7 @@ require "forwardable"
|
|
4
4
|
require_relative "./utilities/callstack"
|
5
5
|
|
6
6
|
module Quo
|
7
|
-
class
|
7
|
+
class Results
|
8
8
|
extend Forwardable
|
9
9
|
include Quo::Utilities::Callstack
|
10
10
|
|
@@ -28,7 +28,7 @@ module Quo
|
|
28
28
|
grouped = unwrapped.group_by do |*block_args|
|
29
29
|
x = block_args.first
|
30
30
|
transformed = transformer ? transformer.call(x) : x
|
31
|
-
block.call(transformed, *block_args[1..])
|
31
|
+
block ? block.call(transformed, *(block_args[1..] || [])) : transformed
|
32
32
|
end
|
33
33
|
|
34
34
|
grouped.tap do |groups|
|
@@ -51,7 +51,8 @@ module Quo
|
|
51
51
|
end
|
52
52
|
else
|
53
53
|
raw = unwrapped.send(method, *args, **kwargs)
|
54
|
-
|
54
|
+
# FIXME: consider how to handle applying a transformer to a Enumerator...
|
55
|
+
return raw if raw.is_a?(Quo::Results) || raw.is_a?(::Enumerator)
|
55
56
|
transform_results(raw)
|
56
57
|
end
|
57
58
|
else
|
data/lib/quo/rspec/helpers.rb
CHANGED
@@ -9,10 +9,10 @@ module Quo
|
|
9
9
|
unless with.nil?
|
10
10
|
return(
|
11
11
|
allow(query_class).to receive(:new)
|
12
|
-
.with(with) { ::Quo::EagerQuery.new(
|
12
|
+
.with(with) { ::Quo::EagerQuery.new(results) }
|
13
13
|
)
|
14
14
|
end
|
15
|
-
allow(query_class).to receive(:new) { ::Quo::EagerQuery.new(
|
15
|
+
allow(query_class).to receive(:new) { ::Quo::EagerQuery.new(results) }
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -12,7 +12,7 @@ module Quo
|
|
12
12
|
stack = Kernel.caller.grep_v(exclude).map { |l| l.gsub(working_dir + "/", "") }
|
13
13
|
stack_to_display = stack[0..callstack_size]
|
14
14
|
message = "\n[Query stack]: -> #{stack_to_display&.join("\n &> ")}\n"
|
15
|
-
message += " (truncated to #{callstack_size} most recent)" if stack.size > callstack_size
|
15
|
+
message += " (truncated to #{callstack_size} most recent)" if callstack_size && stack.size > callstack_size
|
16
16
|
Quo.configuration.logger&.info(message)
|
17
17
|
end
|
18
18
|
end
|
data/lib/quo/utilities/wrap.rb
CHANGED
@@ -15,7 +15,7 @@ module Quo
|
|
15
15
|
if query_rel_or_data.is_a? ActiveRecord::Relation
|
16
16
|
Quo::WrappedQuery.new(query_rel_or_data, **options)
|
17
17
|
else
|
18
|
-
Quo::EagerQuery.new(**options
|
18
|
+
Quo::EagerQuery.new(query_rel_or_data, **options)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/lib/quo/version.rb
CHANGED
data/lib/quo/wrapped_query.rb
CHANGED
data/lib/quo.rb
CHANGED
@@ -7,7 +7,7 @@ require_relative "quo/eager_query"
|
|
7
7
|
require_relative "quo/merged_query"
|
8
8
|
require_relative "quo/wrapped_query"
|
9
9
|
require_relative "quo/query_composer"
|
10
|
-
require_relative "quo/
|
10
|
+
require_relative "quo/results"
|
11
11
|
|
12
12
|
module Quo
|
13
13
|
class << self
|
@@ -22,12 +22,18 @@ module Quo
|
|
22
22
|
end
|
23
23
|
|
24
24
|
class Configuration
|
25
|
-
attr_accessor :formatted_query_log,
|
25
|
+
attr_accessor :formatted_query_log,
|
26
|
+
:query_show_callstack_size,
|
27
|
+
:logger,
|
28
|
+
:max_page_size,
|
29
|
+
:default_page_size
|
26
30
|
|
27
31
|
def initialize
|
28
32
|
@formatted_query_log = true
|
29
33
|
@query_show_callstack_size = 10
|
30
34
|
@logger = nil
|
35
|
+
@max_page_size = 200
|
36
|
+
@default_page_size = 20
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
data/sig/quo/eager_query.rbs
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
module Quo
|
2
2
|
class EagerQuery < Quo::Query
|
3
|
-
def
|
3
|
+
def self.call: (**untyped) -> untyped
|
4
|
+
def self.call!: (**untyped) -> untyped
|
5
|
+
def self.build_from_options: (queryOptions) -> EagerQuery
|
6
|
+
|
7
|
+
def initialize: (enumerable, **untyped options) -> void
|
4
8
|
def query: () -> enumerable
|
5
9
|
def relation?: () -> false
|
6
10
|
def eager?: () -> true
|
7
|
-
attr_reader collection: enumerable
|
8
11
|
|
9
12
|
private
|
10
13
|
|
14
|
+
attr_reader collection: enumerable
|
15
|
+
|
11
16
|
def preload_includes: (untyped records, ?untyped? preload) -> untyped
|
12
17
|
end
|
13
18
|
end
|
data/sig/quo/merged_query.rbs
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
module Quo
|
2
2
|
class MergedQuery < Quo::Query
|
3
|
+
def self.build_from_options: (queryOptions) -> MergedQuery
|
4
|
+
|
3
5
|
def initialize: (relOrEnumerable merged, composable left, composable right, **untyped options) -> void
|
4
6
|
|
5
7
|
@merged_query: relOrEnumerable
|
6
8
|
|
7
|
-
def query: () ->
|
9
|
+
def query: () -> relOrEnumerable
|
8
10
|
|
9
11
|
def to_s: () -> ::String
|
10
12
|
|
data/sig/quo/query.rbs
CHANGED
@@ -40,13 +40,13 @@ module Quo
|
|
40
40
|
|
41
41
|
alias size count
|
42
42
|
def page_count: () -> Integer
|
43
|
-
def first: (
|
44
|
-
def first!: (
|
45
|
-
def last: (
|
43
|
+
def first: (?Integer? limit) -> untyped
|
44
|
+
def first!: (?Integer? limit) -> untyped
|
45
|
+
def last: (?Integer? limit) -> untyped
|
46
46
|
def to_a: () -> Array[untyped]
|
47
47
|
def to_eager: (?::Hash[untyped, untyped] more_opts) -> Quo::EagerQuery
|
48
48
|
alias load to_eager
|
49
|
-
def
|
49
|
+
def results: () -> Quo::Results
|
50
50
|
|
51
51
|
# Set a block used to transform data after query fetching
|
52
52
|
def transform: () ?{ () -> untyped } -> self
|
@@ -70,7 +70,7 @@ module Quo
|
|
70
70
|
def formatted_queries?: () -> bool
|
71
71
|
def trim_query: (String sql) -> String
|
72
72
|
def format_query: (String sql_str) -> String
|
73
|
-
def transformer: () -> (nil | ^(untyped) -> untyped)
|
73
|
+
def transformer: () -> (nil | ^(untyped, ?Integer) -> untyped)
|
74
74
|
def offset: () -> Integer
|
75
75
|
def configured_query: () -> ActiveRecord::Relation
|
76
76
|
def sanitised_page_size: () -> Integer
|
data/sig/quo/query_composer.rbs
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module Quo
|
2
2
|
class QueryComposer
|
3
|
+
@left_relation: bool
|
4
|
+
@right_relation: bool
|
5
|
+
|
3
6
|
def initialize: (composable left, composable right, ?untyped? joins) -> void
|
4
7
|
def compose: () -> Quo::MergedQuery
|
5
8
|
|
@@ -9,10 +12,21 @@ module Quo
|
|
9
12
|
attr_reader right: composable
|
10
13
|
attr_reader joins: untyped
|
11
14
|
|
12
|
-
|
15
|
+
attr_reader unwrapped_left: relOrEnumerable
|
16
|
+
attr_reader unwrapped_right: relOrEnumerable
|
17
|
+
|
18
|
+
def left_relation?: -> bool
|
19
|
+
|
20
|
+
def merge_left_and_right: () -> relOrEnumerable
|
13
21
|
def merged_options: () -> ::Hash[untyped, untyped]
|
22
|
+
|
23
|
+
def right_relation?: -> bool
|
24
|
+
|
14
25
|
def unwrap_relation: (composable) -> relOrEnumerable
|
15
|
-
def relation_type?: (
|
26
|
+
def relation_type?: (relOrEnumerable) -> bool
|
16
27
|
def apply_joins: (ActiveRecord::Relation left_rel, untyped joins) -> ActiveRecord::Relation
|
28
|
+
def both_relations?: () -> bool
|
29
|
+
def left_relation_right_enumerable?: () -> bool
|
30
|
+
def left_enumerable_right_relation?: () -> bool
|
17
31
|
end
|
18
32
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Quo
|
2
|
-
class
|
2
|
+
class Results
|
3
3
|
extend Forwardable
|
4
4
|
|
5
5
|
include Quo::Utilities::Callstack
|
@@ -8,7 +8,7 @@ module Quo
|
|
8
8
|
|
9
9
|
@query: Quo::Query
|
10
10
|
|
11
|
-
def group_by: -> Hash[untyped, Array[untyped]]
|
11
|
+
def group_by: () { (untyped, *untyped) -> untyped } -> Hash[untyped, Array[untyped]]
|
12
12
|
|
13
13
|
def respond_to_missing?: (Symbol name, ?bool include_private) -> bool
|
14
14
|
|
data/sig/quo/wrapped_query.rbs
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Quo
|
2
2
|
class WrappedQuery < Quo::Query
|
3
|
-
@wrapped_query: ActiveRecord::Relation
|
4
|
-
|
5
3
|
def self.build_from_options: (**untyped options) -> WrappedQuery
|
6
4
|
|
5
|
+
@wrapped_query: ActiveRecord::Relation
|
6
|
+
|
7
7
|
def initialize: (ActiveRecord::Relation query, **untyped options) -> void
|
8
8
|
|
9
9
|
def query: () -> ActiveRecord::Relation
|
data/sig/quo.rbs
CHANGED
@@ -11,11 +11,14 @@ module Quo
|
|
11
11
|
|
12
12
|
type query = Quo::Query
|
13
13
|
type queryOrRel = query | ActiveRecord::Relation
|
14
|
-
|
15
|
-
type enumerable = Array[untyped] | Set[untyped]
|
14
|
+
type enumerable = Object & Enumerable[untyped]
|
16
15
|
type relOrEnumerable = ActiveRecord::Relation | enumerable
|
17
16
|
type composable = query | relOrEnumerable
|
18
17
|
|
18
|
+
# TODO: how can we do the known options, eg `page` and then allow anything else?
|
19
|
+
# Maybe we should separate out the known options from the unknown options
|
20
|
+
type queryOptions = Hash[Symbol, untyped]
|
21
|
+
|
19
22
|
interface _Logger
|
20
23
|
def info: (String) -> void
|
21
24
|
def error: (String) -> void
|
@@ -26,6 +29,8 @@ module Quo
|
|
26
29
|
attr_accessor formatted_query_log: bool?
|
27
30
|
attr_accessor query_show_callstack_size: Integer?
|
28
31
|
attr_accessor logger: _Logger?
|
32
|
+
attr_accessor max_page_size: Integer?
|
33
|
+
attr_accessor default_page_size: Integer?
|
29
34
|
|
30
35
|
def initialize: () -> void
|
31
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Ierodiaconou
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -66,11 +66,11 @@ files:
|
|
66
66
|
- Steepfile
|
67
67
|
- lib/quo.rb
|
68
68
|
- lib/quo/eager_query.rb
|
69
|
-
- lib/quo/enumerator.rb
|
70
69
|
- lib/quo/merged_query.rb
|
71
70
|
- lib/quo/query.rb
|
72
71
|
- lib/quo/query_composer.rb
|
73
72
|
- lib/quo/railtie.rb
|
73
|
+
- lib/quo/results.rb
|
74
74
|
- lib/quo/rspec/helpers.rb
|
75
75
|
- lib/quo/utilities/callstack.rb
|
76
76
|
- lib/quo/utilities/compose.rb
|
@@ -82,10 +82,10 @@ files:
|
|
82
82
|
- rbs_collection.yaml
|
83
83
|
- sig/quo.rbs
|
84
84
|
- sig/quo/eager_query.rbs
|
85
|
-
- sig/quo/enumerator.rbs
|
86
85
|
- sig/quo/merged_query.rbs
|
87
86
|
- sig/quo/query.rbs
|
88
87
|
- sig/quo/query_composer.rbs
|
88
|
+
- sig/quo/results.rbs
|
89
89
|
- sig/quo/utilities/callstack.rbs
|
90
90
|
- sig/quo/utilities/compose.rbs
|
91
91
|
- sig/quo/utilities/sanitize.rbs
|