quo 0.1.0 → 0.3.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/Gemfile +9 -5
- data/README.md +6 -1
- data/Steepfile +34 -0
- data/lib/quo/eager_query.rb +4 -3
- data/lib/quo/enumerator.rb +2 -2
- data/lib/quo/query.rb +2 -5
- data/lib/quo/query_composer.rb +21 -20
- data/lib/quo/railtie.rb +3 -3
- data/lib/quo/utilities/compose.rb +4 -5
- data/lib/quo/utilities/sanitize.rb +0 -1
- data/lib/quo/utilities/wrap.rb +10 -6
- data/lib/quo/version.rb +1 -1
- data/lib/quo.rb +1 -0
- data/lib/tasks/quo.rake +20 -0
- data/rbs_collection.yaml +26 -0
- data/sig/quo.rbs +202 -1
- metadata +32 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3278d72f55569eb93fb569185467cd4b327ffd157e249c8538d4a643c652443c
|
4
|
+
data.tar.gz: e936c5fd0de429b941e110c273cb12ff302079095ab0f3d7d38023718b80b5e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4adcb23af540cf2db462bd21640aef4497c1f2509a1ac6968a5a15b1cd2004d7db9935638ba5496eb57ffc655ad515688fc9468a191d17b32735da1a7c652705
|
7
|
+
data.tar.gz: f99119cdf52a97e956317a530e9074e12b07816405f6dd5fd80f74665dd34c0294368ed6d6a7d88f8147484486f52606462864663357e430ca2eebc36b7372d7
|
data/Gemfile
CHANGED
@@ -5,12 +5,16 @@ source "https://rubygems.org"
|
|
5
5
|
# Specify your gem's dependencies in quo.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
|
8
|
+
group :development, :test do
|
9
|
+
gem "sqlite3"
|
9
10
|
|
10
|
-
gem "rails", ">= 6"
|
11
|
+
gem "rails", ">= 6", "< 8"
|
11
12
|
|
12
|
-
gem "rake", "~> 13.0"
|
13
|
+
gem "rake", "~> 13.0"
|
13
14
|
|
14
|
-
gem "minitest", "~> 5.0"
|
15
|
+
gem "minitest", "~> 5.0"
|
15
16
|
|
16
|
-
gem "standard", "~> 1.3"
|
17
|
+
gem "standard", "~> 1.3"
|
18
|
+
|
19
|
+
gem "steep", "~> 1.2"
|
20
|
+
end
|
data/README.md
CHANGED
@@ -148,9 +148,14 @@ class RegistrationToBeApproved < Quo::Query
|
|
148
148
|
def query
|
149
149
|
done = Registration.where(step: "complete")
|
150
150
|
approved = CompanyToBeApproved.new
|
151
|
-
|
151
|
+
# Here we use `.compose` utility method to wrap our Relation in a Query and
|
152
|
+
# then compose with the other Query
|
153
|
+
Quo::Query.compose(done, approved)
|
152
154
|
end
|
153
155
|
end
|
156
|
+
|
157
|
+
# A Relation can be composed directly to a Quo::Query
|
158
|
+
query = RegistrationToBeApproved.new + Registration.where(blocked: false)
|
154
159
|
```
|
155
160
|
|
156
161
|
Also you can use joins:
|
data/Steepfile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# D = Steep::Diagnostic
|
2
|
+
#
|
3
|
+
# target :lib do
|
4
|
+
# signature "sig"
|
5
|
+
#
|
6
|
+
# check "lib" # Directory name
|
7
|
+
# check "Gemfile" # File name
|
8
|
+
# check "app/models/**/*.rb" # Glob
|
9
|
+
# # ignore "lib/templates/*.rb"
|
10
|
+
#
|
11
|
+
# # library "pathname", "set" # Standard libraries
|
12
|
+
# # library "strong_json" # Gems
|
13
|
+
#
|
14
|
+
# # configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
|
15
|
+
# # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
|
16
|
+
# # configure_code_diagnostics do |hash| # You can setup everything yourself
|
17
|
+
# # hash[D::Ruby::NoMethod] = :information
|
18
|
+
# # end
|
19
|
+
# end
|
20
|
+
|
21
|
+
# target :test do
|
22
|
+
# signature "sig", "sig-private"
|
23
|
+
#
|
24
|
+
# check "test"
|
25
|
+
#
|
26
|
+
# # library "pathname", "set" # Standard libraries
|
27
|
+
# end
|
28
|
+
|
29
|
+
target :lib do
|
30
|
+
check "lib/quo"
|
31
|
+
signature "sig"
|
32
|
+
|
33
|
+
library "forwardable"
|
34
|
+
end
|
data/lib/quo/eager_query.rb
CHANGED
@@ -7,7 +7,9 @@ module Quo
|
|
7
7
|
super(**options.except(:collection))
|
8
8
|
end
|
9
9
|
|
10
|
-
# Optionally return the `total_count` option
|
10
|
+
# Optionally return the `total_count` option if it has been set.
|
11
|
+
# This is useful when the total count is known and not equal to size
|
12
|
+
# of wrapped collection.
|
11
13
|
def count
|
12
14
|
options[:total_count] || super
|
13
15
|
end
|
@@ -19,7 +21,6 @@ module Quo
|
|
19
21
|
options[:total_count].nil? && current_page.present?
|
20
22
|
end
|
21
23
|
|
22
|
-
# Return the underlying collection
|
23
24
|
def query
|
24
25
|
preload_includes(collection) if options[:includes]
|
25
26
|
collection
|
@@ -33,7 +34,7 @@ module Quo
|
|
33
34
|
true
|
34
35
|
end
|
35
36
|
|
36
|
-
|
37
|
+
private
|
37
38
|
|
38
39
|
attr_reader :collection
|
39
40
|
|
data/lib/quo/enumerator.rb
CHANGED
@@ -53,8 +53,8 @@ module Quo
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def respond_to_missing?(
|
57
|
-
Enumerable.instance_methods.include?(
|
56
|
+
def respond_to_missing?(name, include_private = false)
|
57
|
+
Enumerable.instance_methods.include?(name)
|
58
58
|
end
|
59
59
|
|
60
60
|
private
|
data/lib/quo/query.rb
CHANGED
@@ -14,12 +14,10 @@ module Quo
|
|
14
14
|
extend Quo::Utilities::Wrap
|
15
15
|
|
16
16
|
class << self
|
17
|
-
# Execute the query and return the first item
|
18
17
|
def call(**options)
|
19
18
|
new(**options).first
|
20
19
|
end
|
21
20
|
|
22
|
-
# Execute the query and return the first item, or raise an error if no item is found
|
23
21
|
def call!(**options)
|
24
22
|
new(**options).first!
|
25
23
|
end
|
@@ -43,7 +41,7 @@ module Quo
|
|
43
41
|
|
44
42
|
# Combine (compose) this query object with another composeable entity, see notes for `.compose` above.
|
45
43
|
# Compose is aliased as `+`. Can optionally take `joins()` parameters to perform a joins before the merge
|
46
|
-
def compose(right, joins
|
44
|
+
def compose(right, joins: nil)
|
47
45
|
Quo::QueryComposer.new(self, right, joins).compose
|
48
46
|
end
|
49
47
|
|
@@ -201,7 +199,7 @@ module Quo
|
|
201
199
|
|
202
200
|
delegate :distinct, to: :configured_query
|
203
201
|
|
204
|
-
|
202
|
+
private
|
205
203
|
|
206
204
|
def formatted_queries?
|
207
205
|
Quo.configuration&.formatted_query_log
|
@@ -254,7 +252,6 @@ module Quo
|
|
254
252
|
rel = rel.limit(@options[:limit]) if @options[:limit].present?
|
255
253
|
rel = rel.preload(@options[:preload]) if @options[:preload].present?
|
256
254
|
rel = rel.includes(@options[:includes]) if @options[:includes].present?
|
257
|
-
rel = rel.joins(@options[:joins]) if @options[:joins].present?
|
258
255
|
rel = rel.select(@options[:select]) if @options[:select].present?
|
259
256
|
end
|
260
257
|
rel
|
data/lib/quo/query_composer.rb
CHANGED
@@ -20,15 +20,18 @@ module Quo
|
|
20
20
|
attr_reader :left, :right, :joins
|
21
21
|
|
22
22
|
def merge
|
23
|
-
left_rel
|
24
|
-
|
23
|
+
left_rel = unwrap_relation(left)
|
24
|
+
right_rel = unwrap_relation(right)
|
25
|
+
left_type = relation_type?(left)
|
26
|
+
right_type = relation_type?(right)
|
27
|
+
|
25
28
|
if both_relations?(left_type, right_type)
|
26
29
|
apply_joins(left_rel, joins).merge(right_rel)
|
27
30
|
elsif left_relation_right_eager?(left_type, right_type)
|
28
31
|
left_rel.to_a + right_rel
|
29
|
-
elsif left_eager_right_relation?(
|
32
|
+
elsif left_eager_right_relation?(left_type, right_type) && left_rel.respond_to?(:+)
|
30
33
|
left_rel + right_rel.to_a
|
31
|
-
elsif both_eager_loaded?(
|
34
|
+
elsif both_eager_loaded?(left_type, right_type) && left_rel.respond_to?(:+)
|
32
35
|
left_rel + right_rel
|
33
36
|
else
|
34
37
|
raise_error
|
@@ -42,18 +45,20 @@ module Quo
|
|
42
45
|
{}
|
43
46
|
end
|
44
47
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
def unwrap_relation(query)
|
49
|
+
query.is_a?(Quo::Query) ? query.unwrap : query
|
50
|
+
end
|
51
|
+
|
52
|
+
def relation_type?(query)
|
53
|
+
if query.is_a?(::Quo::Query)
|
54
|
+
query.relation?
|
55
|
+
else
|
56
|
+
query.is_a?(::ActiveRecord::Relation)
|
52
57
|
end
|
53
58
|
end
|
54
59
|
|
55
60
|
def apply_joins(left_rel, joins)
|
56
|
-
joins.present? ? left_rel.joins(joins
|
61
|
+
joins.present? ? left_rel.joins(joins) : left_rel
|
57
62
|
end
|
58
63
|
|
59
64
|
def both_relations?(left_rel_type, right_rel_type)
|
@@ -64,16 +69,12 @@ module Quo
|
|
64
69
|
left_rel_type && !right_rel_type
|
65
70
|
end
|
66
71
|
|
67
|
-
def left_eager_right_relation?(
|
68
|
-
!left_rel_type && right_rel_type
|
69
|
-
end
|
70
|
-
|
71
|
-
def both_eager_loaded?(left_rel, left_rel_type, right_rel_type)
|
72
|
-
!left_rel_type && !right_rel_type && left_rel.respond_to?(:+)
|
72
|
+
def left_eager_right_relation?(left_rel_type, right_rel_type)
|
73
|
+
!left_rel_type && right_rel_type
|
73
74
|
end
|
74
75
|
|
75
|
-
def
|
76
|
-
|
76
|
+
def both_eager_loaded?(left_rel_type, right_rel_type)
|
77
|
+
!left_rel_type && !right_rel_type
|
77
78
|
end
|
78
79
|
|
79
80
|
def raise_error
|
data/lib/quo/railtie.rb
CHANGED
@@ -2,15 +2,14 @@
|
|
2
2
|
|
3
3
|
module Quo
|
4
4
|
module Utilities
|
5
|
+
# Combine two query-like or composeable entities:
|
6
|
+
# These can be Quo::Query, Quo::MergedQuery, Quo::EagerQuery and ActiveRecord::Relations.
|
7
|
+
# See the `README.md` docs for more details.
|
5
8
|
module Compose
|
6
|
-
|
7
|
-
# These can be Quo::Query, Quo::MergedQuery, Quo::EagerQuery and ActiveRecord::Relations.
|
8
|
-
# See the `README.md` docs for more details.
|
9
|
-
def compose(query1, query2, joins = nil)
|
9
|
+
def compose(query1, query2, joins: nil)
|
10
10
|
Quo::QueryComposer.new(query1, query2, joins).compose
|
11
11
|
end
|
12
12
|
|
13
|
-
# Determines if the object `query` is something which can be composed with query objects
|
14
13
|
def composable_with?(query)
|
15
14
|
query.is_a?(Quo::Query) || query.is_a?(ActiveRecord::Relation)
|
16
15
|
end
|
data/lib/quo/utilities/wrap.rb
CHANGED
@@ -2,17 +2,21 @@
|
|
2
2
|
|
3
3
|
module Quo
|
4
4
|
module Utilities
|
5
|
+
# Wrap a ActiveRecord::Relation or data collection in a Query.
|
6
|
+
#
|
7
|
+
# If the passed in object is already a Query object then just return it or copy it if new options are passed in.
|
8
|
+
# Otherwise if a Relation wrap it in a new Query object or else in an EagerQuery .
|
5
9
|
module Wrap
|
6
|
-
# Wrap a relation in a Query. If the passed in object is already a query object then just return it
|
7
10
|
def wrap(query_rel_or_data, **options)
|
8
|
-
if query_rel_or_data.is_a?
|
9
|
-
return query_rel_or_data.copy(**options)
|
11
|
+
if query_rel_or_data.is_a? Quo::Query
|
12
|
+
return options.present? ? query_rel_or_data.copy(**options) : query_rel_or_data
|
10
13
|
end
|
11
|
-
|
14
|
+
|
12
15
|
if query_rel_or_data.is_a? ActiveRecord::Relation
|
13
|
-
|
16
|
+
new(**options.merge(scope: query_rel_or_data))
|
17
|
+
else
|
18
|
+
Quo::EagerQuery.new(**options.merge(collection: query_rel_or_data))
|
14
19
|
end
|
15
|
-
Quo::EagerQuery.new(**options.merge(collection: query_rel_or_data))
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
data/lib/quo/version.rb
CHANGED
data/lib/quo.rb
CHANGED
data/lib/tasks/quo.rake
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
desc "List all the query objects in the app"
|
4
|
+
namespace :quo do
|
5
|
+
task list: :environment do
|
6
|
+
# In development classes are lazily loaded, so can't use Quo::Query.descendants.
|
7
|
+
# Instead we search all *_query.rb files
|
8
|
+
Dir["#{Rails.root}/**/*_query.rb"].each do |file|
|
9
|
+
source_code = File.read(file)
|
10
|
+
result = source_code.match(/class\s+([A-Za-z0-9_:]+)\s*<\s*(::)?Quo::Query/)
|
11
|
+
puts (result && result[1]) ? "\n\n> #{result[1]}" : "Class name could not be determined"
|
12
|
+
puts "\n"
|
13
|
+
comments = source_code.match(/((#[^\n]+\n)*)[^\n]+lass/)
|
14
|
+
puts (comments && comments[1].present?) ? comments[1] : "No description for class found"
|
15
|
+
puts "\n"
|
16
|
+
puts "Found in:"
|
17
|
+
puts " - #{file}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/rbs_collection.yaml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Download sources
|
2
|
+
sources:
|
3
|
+
- name: ruby/gem_rbs_collection
|
4
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
5
|
+
revision: main
|
6
|
+
repo_dir: gems
|
7
|
+
|
8
|
+
# A directory to install the downloaded RBSs
|
9
|
+
path: .gem_rbs_collection
|
10
|
+
|
11
|
+
gems:
|
12
|
+
- name: quo
|
13
|
+
ignore: true
|
14
|
+
- name: forwardable
|
15
|
+
# Skip loading rbs gem's RBS.
|
16
|
+
# It's unnecessary if you don't use rbs as a library.
|
17
|
+
- name: rbs
|
18
|
+
ignore: true
|
19
|
+
- name: rake
|
20
|
+
ignore: true
|
21
|
+
- name: minitest
|
22
|
+
ignore: true
|
23
|
+
- name: standard
|
24
|
+
ignore: true
|
25
|
+
- name: steep
|
26
|
+
ignore: true
|
data/sig/quo.rbs
CHANGED
@@ -1,4 +1,205 @@
|
|
1
1
|
module Quo
|
2
2
|
VERSION: String
|
3
|
-
|
3
|
+
|
4
|
+
interface _Enumerable
|
5
|
+
def each: { (untyped) -> void } -> untyped
|
6
|
+
end
|
7
|
+
|
8
|
+
interface _Collection
|
9
|
+
include _Enumerable
|
10
|
+
def is_a?: (Class) -> bool
|
11
|
+
def class: -> Class
|
12
|
+
def +: (untyped) -> _Collection
|
13
|
+
end
|
14
|
+
|
15
|
+
type query = Quo::MergedQuery | Quo::EagerQuery | Quo::Query
|
16
|
+
type merge_composable = query | ActiveRecord::Relation
|
17
|
+
type enumerable = _Collection
|
18
|
+
type query_like = ActiveRecord::Relation | enumerable
|
19
|
+
type composable = query | query_like
|
20
|
+
|
21
|
+
module Utilities
|
22
|
+
module Callstack
|
23
|
+
def debug_callstack: () -> void
|
24
|
+
end
|
25
|
+
|
26
|
+
module Compose
|
27
|
+
# Combine two query-like or composeable entities:
|
28
|
+
# These can be Quo::Query, Quo::MergedQuery, Quo::EagerQuery and ActiveRecord::Relations.
|
29
|
+
# See the `README.md` docs for more details.
|
30
|
+
def compose: (composable query1, composable query2, ?joins: untyped?) -> Quo::MergedQuery
|
31
|
+
|
32
|
+
# Determines if the object `query` is something which can be composed with query objects
|
33
|
+
def composable_with?: (merge_composable query) -> bool
|
34
|
+
end
|
35
|
+
|
36
|
+
module Sanitize
|
37
|
+
def sanitize_sql_for_conditions: (untyped conditions) -> (untyped | nil)
|
38
|
+
|
39
|
+
def sanitize_sql_string: (untyped string) -> (untyped | nil)
|
40
|
+
|
41
|
+
def sanitize_sql_parameter: (untyped value) -> (untyped | nil)
|
42
|
+
end
|
43
|
+
|
44
|
+
interface _Wrapable
|
45
|
+
def new: (**untyped options) -> query
|
46
|
+
end
|
47
|
+
|
48
|
+
module Wrap : _Wrapable
|
49
|
+
def wrap: (composable query_rel_or_data, **untyped options) -> query
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
class Enumerator
|
55
|
+
extend Forwardable
|
56
|
+
|
57
|
+
include Quo::Utilities::Callstack
|
58
|
+
|
59
|
+
def initialize: (Quo::Query query, ?transformer: ^(untyped, ?Integer) -> untyped) -> void
|
60
|
+
|
61
|
+
@query: Quo::Query
|
62
|
+
|
63
|
+
def respond_to_missing?: (Symbol name, ?bool include_private) -> bool
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
attr_reader transformer: ^(untyped, ?Integer) -> untyped
|
68
|
+
attr_reader unwrapped: ActiveRecord::Relation
|
69
|
+
|
70
|
+
def transform_results: (untyped) -> untyped
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
class Query
|
75
|
+
include Quo::Utilities::Callstack
|
76
|
+
extend Quo::Utilities::Compose
|
77
|
+
extend Quo::Utilities::Sanitize
|
78
|
+
extend Quo::Utilities::Wrap
|
79
|
+
|
80
|
+
def self.call: (**untyped options) -> untyped
|
81
|
+
def self.call!: (**untyped options) -> untyped
|
82
|
+
def self.description: (?String) -> (String | nil)
|
83
|
+
self.@description: String | nil
|
84
|
+
|
85
|
+
@scope: ActiveRecord::Relation | nil
|
86
|
+
|
87
|
+
attr_reader current_page: (Integer | nil)
|
88
|
+
attr_reader page_size: (Integer | nil)
|
89
|
+
attr_reader options: Hash[untyped, untyped]
|
90
|
+
|
91
|
+
def initialize: (**untyped options) -> void
|
92
|
+
def query: () -> composable
|
93
|
+
def compose: (composable right, ?joins: untyped?) -> Quo::MergedQuery
|
94
|
+
alias + compose
|
95
|
+
|
96
|
+
def copy: (**untyped options) -> query
|
97
|
+
|
98
|
+
def limit: (untyped limit) -> query
|
99
|
+
def order: (untyped options) -> query
|
100
|
+
def group: (*untyped options) -> query
|
101
|
+
def includes: (*untyped options) -> query
|
102
|
+
def preload: (*untyped options) -> query
|
103
|
+
def select: (*untyped options) -> query
|
104
|
+
|
105
|
+
def sum: (?untyped column_name) -> Numeric
|
106
|
+
def average: (untyped column_name) -> Numeric
|
107
|
+
def minimum: (untyped column_name) -> Numeric
|
108
|
+
def maximum: (untyped column_name) -> Numeric
|
109
|
+
def count: () -> Integer
|
110
|
+
|
111
|
+
alias total_count count
|
112
|
+
|
113
|
+
alias size count
|
114
|
+
def page_count: () -> Integer
|
115
|
+
def first: (*untyped args) -> untyped
|
116
|
+
def first!: (*untyped args) -> untyped
|
117
|
+
def last: (*untyped args) -> untyped
|
118
|
+
def to_a: () -> Array[untyped]
|
119
|
+
def to_eager: (?::Hash[untyped, untyped] more_opts) -> Quo::EagerQuery
|
120
|
+
alias load to_eager
|
121
|
+
def enumerator: () -> Quo::Enumerator
|
122
|
+
|
123
|
+
# Set a block used to transform data after query fetching
|
124
|
+
def transform: () ?{ () -> untyped } -> self
|
125
|
+
|
126
|
+
def exists?: () -> bool
|
127
|
+
def none?: () -> bool
|
128
|
+
alias empty? none?
|
129
|
+
def relation?: () -> bool
|
130
|
+
def eager?: () -> bool
|
131
|
+
def paged?: () -> bool
|
132
|
+
|
133
|
+
def model: () -> (untyped | nil)
|
134
|
+
def klass: () -> (untyped | nil)
|
135
|
+
|
136
|
+
def transform?: () -> bool
|
137
|
+
def to_sql: () -> (String | nil)
|
138
|
+
def unwrap: () -> query_like
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
def formatted_queries?: () -> bool
|
143
|
+
def trim_query: (String sql) -> String
|
144
|
+
def format_query: (String sql_str) -> String
|
145
|
+
def transformer: () -> (nil | ^(untyped) -> untyped)
|
146
|
+
def offset: () -> Integer
|
147
|
+
def configured_query: () -> ActiveRecord::Relation
|
148
|
+
def sanitised_page_size: () -> Integer
|
149
|
+
def query_with_logging: () -> ActiveRecord::Relation
|
150
|
+
def underlying_query: () -> ActiveRecord::Relation
|
151
|
+
def unwrap_relation: (composable query) -> ActiveRecord::Relation
|
152
|
+
def test_eager: (composable rel) -> bool
|
153
|
+
def test_relation: (composable rel) -> bool
|
154
|
+
end
|
155
|
+
|
156
|
+
class MergedQuery < Quo::Query
|
157
|
+
def initialize: (untyped options, ?untyped source_queries) -> void
|
158
|
+
|
159
|
+
def query: () -> composable
|
160
|
+
|
161
|
+
def to_s: () -> ::String
|
162
|
+
|
163
|
+
private
|
164
|
+
|
165
|
+
def source_queries_left: () -> composable
|
166
|
+
def source_queries_right: () -> composable
|
167
|
+
attr_reader source_queries: Array[composable]
|
168
|
+
def operand_desc: (untyped operand) -> (nil | String)
|
169
|
+
end
|
170
|
+
|
171
|
+
class EagerQuery < Quo::Query
|
172
|
+
def initialize: (**untyped options) -> void
|
173
|
+
def query: () -> enumerable
|
174
|
+
def relation?: () -> false
|
175
|
+
def eager?: () -> true
|
176
|
+
attr_reader collection: enumerable
|
177
|
+
|
178
|
+
private
|
179
|
+
|
180
|
+
def preload_includes: (untyped records, ?untyped? preload) -> untyped
|
181
|
+
end
|
182
|
+
|
183
|
+
class QueryComposer
|
184
|
+
def initialize: (composable left, composable right, ?untyped? joins) -> void
|
185
|
+
def compose: () -> Quo::MergedQuery
|
186
|
+
|
187
|
+
private
|
188
|
+
|
189
|
+
attr_reader left: composable
|
190
|
+
attr_reader right: composable
|
191
|
+
attr_reader joins: untyped
|
192
|
+
|
193
|
+
def merge: () -> (ActiveRecord::Relation | Array[untyped] | void)
|
194
|
+
def merged_options: () -> ::Hash[untyped, untyped]
|
195
|
+
def unwrap_relation: (composable) -> query_like
|
196
|
+
def relation_type?: (composable) -> bool
|
197
|
+
def apply_joins: (ActiveRecord::Relation left_rel, untyped joins) -> ActiveRecord::Relation
|
198
|
+
def both_relations?: (bool left_rel_type, bool right_rel_type) -> bool
|
199
|
+
def left_relation_right_eager?: (bool left_rel_type, bool right_rel_type) -> bool
|
200
|
+
def left_eager_right_relation?: (bool left_rel_type, bool right_rel_type) -> bool
|
201
|
+
def both_eager_loaded?: (bool left_rel_type, bool right_rel_type) -> bool
|
202
|
+
|
203
|
+
def raise_error: () -> void
|
204
|
+
end
|
4
205
|
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.3.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-
|
11
|
+
date: 2022-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '6'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '8'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,29 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '6'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '8'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activesupport
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '6'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '8'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '6'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '8'
|
27
53
|
description: Quo query objects are composable.
|
28
54
|
email:
|
29
55
|
- stevegeek@gmail.com
|
@@ -37,6 +63,7 @@ files:
|
|
37
63
|
- LICENSE.txt
|
38
64
|
- README.md
|
39
65
|
- Rakefile
|
66
|
+
- Steepfile
|
40
67
|
- lib/quo.rb
|
41
68
|
- lib/quo/eager_query.rb
|
42
69
|
- lib/quo/enumerator.rb
|
@@ -50,6 +77,8 @@ files:
|
|
50
77
|
- lib/quo/utilities/sanitize.rb
|
51
78
|
- lib/quo/utilities/wrap.rb
|
52
79
|
- lib/quo/version.rb
|
80
|
+
- lib/tasks/quo.rake
|
81
|
+
- rbs_collection.yaml
|
53
82
|
- sig/quo.rbs
|
54
83
|
homepage: https://github.com/stevegeek/quo
|
55
84
|
licenses:
|
@@ -72,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
101
|
- !ruby/object:Gem::Version
|
73
102
|
version: '0'
|
74
103
|
requirements: []
|
75
|
-
rubygems_version: 3.3.
|
104
|
+
rubygems_version: 3.3.26
|
76
105
|
signing_key:
|
77
106
|
specification_version: 4
|
78
107
|
summary: Quo is a query object gem for Rails
|