quo 0.6.0 → 1.0.0.beta1
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/.standard.yml +4 -1
- data/Appraisals +15 -0
- data/CHANGELOG.md +78 -0
- data/Gemfile +6 -4
- data/LICENSE.txt +1 -1
- data/README.md +222 -232
- data/Steepfile +0 -2
- data/gemfiles/rails_7.0.gemfile +15 -0
- data/gemfiles/rails_7.1.gemfile +15 -0
- data/gemfiles/rails_7.2.gemfile +15 -0
- data/gemfiles/rails_8.0.gemfile +15 -0
- data/lib/quo/collection_backed_query.rb +87 -0
- data/lib/quo/collection_results.rb +44 -0
- data/lib/quo/composed_query.rb +278 -0
- data/lib/quo/engine.rb +11 -0
- data/lib/quo/minitest/helpers.rb +41 -0
- data/lib/quo/preloadable.rb +46 -0
- data/lib/quo/query.rb +97 -215
- data/lib/quo/relation_backed_query.rb +150 -0
- data/lib/quo/relation_backed_query_specification.rb +154 -0
- data/lib/quo/relation_results.rb +58 -0
- data/lib/quo/results.rb +48 -44
- data/lib/quo/rspec/helpers.rb +31 -9
- data/lib/quo/testing/collection_backed_fake.rb +29 -0
- data/lib/quo/testing/relation_backed_fake.rb +52 -0
- data/lib/quo/version.rb +3 -1
- data/lib/quo.rb +23 -30
- data/rbs_collection.yaml +0 -2
- data/sig/generated/quo/collection_backed_query.rbs +39 -0
- data/sig/generated/quo/collection_results.rbs +30 -0
- data/sig/generated/quo/composed_query.rbs +112 -0
- data/sig/generated/quo/engine.rbs +6 -0
- data/sig/generated/quo/preloadable.rbs +29 -0
- data/sig/generated/quo/query.rbs +98 -0
- data/sig/generated/quo/relation_backed_query.rbs +67 -0
- data/sig/generated/quo/relation_backed_query_specification.rbs +94 -0
- data/sig/generated/quo/relation_results.rbs +38 -0
- data/sig/generated/quo/results.rbs +39 -0
- data/sig/generated/quo/testing/collection_backed_fake.rbs +13 -0
- data/sig/generated/quo/testing/relation_backed_fake.rbs +23 -0
- data/sig/generated/quo/version.rbs +5 -0
- data/sig/generated/quo.rbs +9 -0
- data/sig/literal.rbs +7 -0
- metadata +77 -37
- data/lib/quo/eager_query.rb +0 -51
- data/lib/quo/loaded_query.rb +0 -18
- data/lib/quo/merged_query.rb +0 -36
- data/lib/quo/query_composer.rb +0 -78
- data/lib/quo/railtie.rb +0 -7
- data/lib/quo/utilities/callstack.rb +0 -21
- data/lib/quo/utilities/compose.rb +0 -18
- data/lib/quo/utilities/sanitize.rb +0 -19
- data/lib/quo/utilities/wrap.rb +0 -23
- data/lib/quo/wrapped_query.rb +0 -18
- data/sig/quo/eager_query.rbs +0 -15
- data/sig/quo/loaded_query.rbs +0 -7
- data/sig/quo/merged_query.rbs +0 -19
- data/sig/quo/query.rbs +0 -83
- data/sig/quo/query_composer.rbs +0 -32
- data/sig/quo/results.rbs +0 -22
- data/sig/quo/utilities/callstack.rbs +0 -7
- data/sig/quo/utilities/compose.rbs +0 -8
- data/sig/quo/utilities/sanitize.rbs +0 -9
- data/sig/quo/utilities/wrap.rbs +0 -11
- data/sig/quo/wrapped_query.rbs +0 -11
- data/sig/quo.rbs +0 -41
@@ -0,0 +1,112 @@
|
|
1
|
+
# Generated from lib/quo/composed_query.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Quo
|
4
|
+
module ComposedQuery
|
5
|
+
# Combine two Query classes into a new composed query class
|
6
|
+
# Combine two query-like or composeable entities:
|
7
|
+
# These can be Quo::Query, Quo::ComposedQuery, Quo::CollectionBackedQuery and ActiveRecord::Relations.
|
8
|
+
# See the `README.md` docs for more details.
|
9
|
+
# @rbs chosen_superclass: singleton(Quo::RelationBackedQuery | Quo::CollectionBackedQuery)
|
10
|
+
# @rbs left_query_class: singleton(Quo::Query | ::ActiveRecord::Relation)
|
11
|
+
# @rbs right_query_class: singleton(Quo::Query | ::ActiveRecord::Relation)
|
12
|
+
# @rbs joins: untyped
|
13
|
+
# @rbs return: singleton(Quo::ComposedQuery)
|
14
|
+
def self?.composer: (untyped chosen_superclass, untyped left_query_class, untyped right_query_class, ?joins: untyped) -> singleton(Quo::ComposedQuery)
|
15
|
+
|
16
|
+
# We can also merge instance of prepared queries
|
17
|
+
# @rbs left_instance: Quo::Query | ::ActiveRecord::Relation
|
18
|
+
# @rbs right_instance: Quo::Query | ::ActiveRecord::Relation
|
19
|
+
# @rbs joins: untyped
|
20
|
+
# @rbs return: Quo::ComposedQuery
|
21
|
+
def self?.merge_instances: (Quo::Query | ::ActiveRecord::Relation left_instance, Quo::Query | ::ActiveRecord::Relation right_instance, ?joins: untyped) -> Quo::ComposedQuery
|
22
|
+
|
23
|
+
# @rbs override
|
24
|
+
def query: ...
|
25
|
+
|
26
|
+
# @rbs override
|
27
|
+
def inspect: ...
|
28
|
+
|
29
|
+
# @rbs left_query_class: singleton(Quo::Query | ::ActiveRecord::Relation)
|
30
|
+
# @rbs right_query_class: singleton(Quo::Query | ::ActiveRecord::Relation)
|
31
|
+
private def self.validate_query_classes: (untyped left_query_class, untyped right_query_class) -> untyped
|
32
|
+
|
33
|
+
# @rbs left_query_class: singleton(Quo::Query | ::ActiveRecord::Relation)
|
34
|
+
# @rbs right_query_class: singleton(Quo::Query | ::ActiveRecord::Relation)
|
35
|
+
private def self.collect_properties: (untyped left_query_class, untyped right_query_class) -> untyped
|
36
|
+
|
37
|
+
private def self.create_composed_class: (untyped chosen_superclass, untyped props) -> untyped
|
38
|
+
|
39
|
+
# @rbs klass: Class
|
40
|
+
# @rbs left_query_class: singleton(Quo::Query | ::ActiveRecord::Relation)
|
41
|
+
# @rbs right_query_class: singleton(Quo::Query | ::ActiveRecord::Relation)
|
42
|
+
# @rbs joins: untyped
|
43
|
+
private def self.assign_query_metadata: (Class klass, untyped left_query_class, untyped right_query_class, untyped joins) -> untyped
|
44
|
+
|
45
|
+
# @rbs left_instance: Quo::Query | ::ActiveRecord::Relation
|
46
|
+
# @rbs right_instance: Quo::Query | ::ActiveRecord::Relation
|
47
|
+
private def self.validate_instances: (Quo::Query | ::ActiveRecord::Relation left_instance, Quo::Query | ::ActiveRecord::Relation right_instance) -> untyped
|
48
|
+
|
49
|
+
# @rbs relation: ::ActiveRecord::Relation
|
50
|
+
# @rbs query: Quo::Query
|
51
|
+
# @rbs joins: untyped
|
52
|
+
private def self.merge_query_and_relation: (Quo::Query query, ::ActiveRecord::Relation relation, untyped joins) -> untyped
|
53
|
+
|
54
|
+
# @rbs relation: ::ActiveRecord::Relation
|
55
|
+
# @rbs query: Quo::Query
|
56
|
+
# @rbs joins: untyped
|
57
|
+
private def self.merge_relation_and_query: (::ActiveRecord::Relation relation, Quo::Query query, untyped joins) -> untyped
|
58
|
+
|
59
|
+
# @rbs left_query: Quo::Query | ::ActiveRecord::Relation
|
60
|
+
# @rbs right_query: Quo::Query | ::ActiveRecord::Relation
|
61
|
+
private def self.merge_query_instances: (Quo::Query | ::ActiveRecord::Relation left_query, Quo::Query | ::ActiveRecord::Relation right_query, untyped joins) -> untyped
|
62
|
+
|
63
|
+
# @rbs left_query: Quo::Query | ::ActiveRecord::Relation
|
64
|
+
# @rbs right_query: Quo::Query | ::ActiveRecord::Relation
|
65
|
+
private def self.determine_base_class_for_queries: (Quo::Query | ::ActiveRecord::Relation left_query, Quo::Query | ::ActiveRecord::Relation right_query) -> untyped
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
# @rbs return: Hash[Symbol, untyped]
|
70
|
+
def child_options: (untyped query_class) -> Hash[Symbol, untyped]
|
71
|
+
|
72
|
+
# @rbs return: Array[Symbol]
|
73
|
+
def property_names: (untyped query_class) -> Array[Symbol]
|
74
|
+
|
75
|
+
# @rbs return: Quo::Query | ::ActiveRecord::Relation
|
76
|
+
def left: () -> (Quo::Query | ::ActiveRecord::Relation)
|
77
|
+
|
78
|
+
# @rbs return: Quo::Query | ::ActiveRecord::Relation
|
79
|
+
def right: () -> (Quo::Query | ::ActiveRecord::Relation)
|
80
|
+
|
81
|
+
# @rbs return: ActiveRecord::Relation | CollectionBackedQuery
|
82
|
+
def merge_left_and_right: () -> (ActiveRecord::Relation | CollectionBackedQuery)
|
83
|
+
|
84
|
+
# @rbs left_rel: ActiveRecord::Relation
|
85
|
+
# @rbs right_rel: ActiveRecord::Relation
|
86
|
+
# @rbs return: ActiveRecord::Relation
|
87
|
+
def merge_active_record_relations: (ActiveRecord::Relation left_rel, ActiveRecord::Relation right_rel) -> ActiveRecord::Relation
|
88
|
+
|
89
|
+
# @rbs left_rel: ActiveRecord::Relation
|
90
|
+
# @rbs return: ActiveRecord::Relation
|
91
|
+
def apply_joins: (ActiveRecord::Relation left_rel) -> ActiveRecord::Relation
|
92
|
+
|
93
|
+
# @rbs rel: untyped
|
94
|
+
# @rbs return: bool
|
95
|
+
def is_relation?: (untyped rel) -> bool
|
96
|
+
|
97
|
+
# @rbs left: untyped
|
98
|
+
# @rbs right: untyped
|
99
|
+
# @rbs return: bool
|
100
|
+
def both_relations?: (untyped left, untyped right) -> bool
|
101
|
+
|
102
|
+
# @rbs left: untyped
|
103
|
+
# @rbs right: untyped
|
104
|
+
# @rbs return: bool
|
105
|
+
def left_relation_right_enumerable?: (untyped left, untyped right) -> bool
|
106
|
+
|
107
|
+
# @rbs left: untyped
|
108
|
+
# @rbs right: untyped
|
109
|
+
# @rbs return: bool
|
110
|
+
def left_enumerable_right_relation?: (untyped left, untyped right) -> bool
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Generated from lib/quo/preloadable.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Quo
|
4
|
+
module Preloadable
|
5
|
+
def self.included: (untyped base) -> untyped
|
6
|
+
|
7
|
+
# This implementation of `query` calls `collection` and preloads the includes.
|
8
|
+
# @rbs return: Object & Enumerable[untyped]
|
9
|
+
def query: () -> (Object & Enumerable[untyped])
|
10
|
+
|
11
|
+
# For use with collections of ActiveRecord models.
|
12
|
+
# Configures ActiveRecord::Associations::Preloader to load associations of models in the collection
|
13
|
+
# @rbs *options: untyped
|
14
|
+
# @rbs return: Quo::Query
|
15
|
+
def preload: (*untyped options) -> Quo::Query
|
16
|
+
|
17
|
+
# Alias for `preload`
|
18
|
+
# @rbs *options: untyped
|
19
|
+
# @rbs return: Quo::Query
|
20
|
+
def includes: (*untyped options) -> Quo::Query
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
@_rel_preload: untyped?
|
25
|
+
|
26
|
+
# @rbs (untyped records, ?untyped? preload) -> untyped
|
27
|
+
def preload_includes: (untyped records, ?untyped? preload) -> untyped
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# Generated from lib/quo/query.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Quo
|
4
|
+
class Query < Literal::Struct
|
5
|
+
include Literal::Types
|
6
|
+
|
7
|
+
def self.inspect: () -> untyped
|
8
|
+
|
9
|
+
def self.to_s: () -> untyped
|
10
|
+
|
11
|
+
def inspect: () -> untyped
|
12
|
+
|
13
|
+
def to_s: () -> untyped
|
14
|
+
|
15
|
+
# TODO: put this in a module with the composer and merge_instances methods
|
16
|
+
# Compose is aliased as `+`. Can optionally take `joins` parameters to add joins on merged relation.
|
17
|
+
# @rbs right: Quo::Query | ActiveRecord::Relation | Object & Enumerable[untyped]
|
18
|
+
# @rbs joins: Symbol | Hash[Symbol, untyped] | Array[Symbol | Hash[Symbol, untyped]]
|
19
|
+
# @rbs return: Quo::Query & Quo::ComposedQuery
|
20
|
+
def self.compose: (Quo::Query | ActiveRecord::Relation | Object & Enumerable[untyped] right, ?joins: Symbol | Hash[Symbol, untyped] | Array[Symbol | Hash[Symbol, untyped]]) -> (Quo::Query & Quo::ComposedQuery)
|
21
|
+
|
22
|
+
COERCE_TO_INT: untyped
|
23
|
+
|
24
|
+
attr_accessor page(): Integer?
|
25
|
+
|
26
|
+
attr_accessor page_size(): Integer?
|
27
|
+
|
28
|
+
@current_page: Integer?
|
29
|
+
|
30
|
+
def next_page_query: () -> Quo::Query
|
31
|
+
|
32
|
+
def previous_page_query: () -> Quo::Query
|
33
|
+
|
34
|
+
def offset: () -> Integer
|
35
|
+
|
36
|
+
# Returns a active record query, or a Quo::Query instance
|
37
|
+
def query: () -> (Quo::Query | ::ActiveRecord::Relation)
|
38
|
+
|
39
|
+
# @rbs **overrides: untyped
|
40
|
+
# @rbs return: Quo::Query
|
41
|
+
def copy: (**untyped overrides) -> Quo::Query
|
42
|
+
|
43
|
+
# Compose is aliased as `+`. Can optionally take `joins` parameters to add joins on merged relation.
|
44
|
+
# @rbs right: Quo::Query | ::ActiveRecord::Relation
|
45
|
+
# @rbs joins: untyped
|
46
|
+
# @rbs return: Quo::ComposedQuery
|
47
|
+
def merge: (Quo::Query | ::ActiveRecord::Relation right, ?joins: untyped) -> Quo::ComposedQuery
|
48
|
+
|
49
|
+
@__transformer: nil | ^(untyped, ?Integer) -> untyped
|
50
|
+
|
51
|
+
# Set a block used to transform data after query fetching
|
52
|
+
# @rbs block: ^(untyped, ?Integer) -> untyped
|
53
|
+
# @rbs return: self
|
54
|
+
def transform: () ?{ (?) -> untyped } -> self
|
55
|
+
|
56
|
+
# Is this query object a ActiveRecord relation under the hood?
|
57
|
+
def relation?: () -> bool
|
58
|
+
|
59
|
+
# Is this query object loaded data/collection under the hood? (ie not a AR relation)
|
60
|
+
def collection?: () -> bool
|
61
|
+
|
62
|
+
# Is this query object paged? (ie is paging enabled)
|
63
|
+
def paged?: () -> bool
|
64
|
+
|
65
|
+
# Is this query object transforming results?
|
66
|
+
def transform?: () -> bool
|
67
|
+
|
68
|
+
# Unwrap the paginated query
|
69
|
+
def unwrap: () -> ActiveRecord::Relation
|
70
|
+
|
71
|
+
# Unwrap the un-paginated query
|
72
|
+
def unwrap_unpaginated: () -> ActiveRecord::Relation
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def transformer: () -> untyped
|
77
|
+
|
78
|
+
def validated_query: () -> untyped
|
79
|
+
|
80
|
+
# The underlying query is essentially the configured query with optional extras setup
|
81
|
+
def underlying_query: () -> void
|
82
|
+
|
83
|
+
# The configured query is the underlying query with paging
|
84
|
+
def configured_query: () -> void
|
85
|
+
|
86
|
+
def sanitised_page_size: () -> Integer
|
87
|
+
|
88
|
+
# @rbs rel: untyped
|
89
|
+
# @rbs return: bool
|
90
|
+
def is_collection?: (untyped rel) -> bool
|
91
|
+
|
92
|
+
# @rbs rel: untyped
|
93
|
+
# @rbs return: bool
|
94
|
+
def test_relation: (untyped rel) -> bool
|
95
|
+
|
96
|
+
def quo_unwrap_unpaginated_query: (untyped q) -> untyped
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Generated from lib/quo/relation_backed_query.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Quo
|
4
|
+
class RelationBackedQuery < Query
|
5
|
+
# @rbs query: ActiveRecord::Relation | Quo::Query
|
6
|
+
# @rbs props: Hash[Symbol, untyped]
|
7
|
+
# @rbs &block: () -> ActiveRecord::Relation | Quo::Query | Object & Enumerable[untyped]
|
8
|
+
# @rbs return: Quo::RelationBackedQuery
|
9
|
+
def self.wrap: (?ActiveRecord::Relation | Quo::Query query, ?props: Hash[Symbol, untyped]) ?{ (?) -> untyped } -> Quo::RelationBackedQuery
|
10
|
+
|
11
|
+
# @rbs conditions: untyped?
|
12
|
+
# @rbs return: String
|
13
|
+
def self.sanitize_sql_for_conditions: (untyped? conditions) -> String
|
14
|
+
|
15
|
+
# @rbs string: String
|
16
|
+
# @rbs return: String
|
17
|
+
def self.sanitize_sql_string: (String string) -> String
|
18
|
+
|
19
|
+
# @rbs value: untyped
|
20
|
+
# @rbs return: String
|
21
|
+
def self.sanitize_sql_parameter: (untyped value) -> String
|
22
|
+
|
23
|
+
@_specification: Quo::RelationBackedQuerySpecification?
|
24
|
+
|
25
|
+
# Apply a query specification to this query
|
26
|
+
# @rbs specification: Quo::RelationBackedQuerySpecification
|
27
|
+
# @rbs return: Quo::Query
|
28
|
+
def with_specification: (Quo::RelationBackedQuerySpecification specification) -> Quo::Query
|
29
|
+
|
30
|
+
# Apply query options using the specification
|
31
|
+
# @rbs options: Hash[Symbol, untyped]
|
32
|
+
# @rbs return: Quo::Query
|
33
|
+
def with: (?Hash[Symbol, untyped] options) -> Quo::Query
|
34
|
+
|
35
|
+
# @rbs return: Quo::CollectionBackedQuery
|
36
|
+
def to_collection: (?total_count: untyped) -> Quo::CollectionBackedQuery
|
37
|
+
|
38
|
+
def results: () -> Quo::Results
|
39
|
+
|
40
|
+
# Return the SQL string for this query if its a relation type query object
|
41
|
+
def to_sql: () -> String
|
42
|
+
|
43
|
+
# Implements a fluent API for query methods
|
44
|
+
# This allows methods to be chained like query.where(...).order(...).limit(...)
|
45
|
+
# @rbs method_name: Symbol
|
46
|
+
# @rbs *args: untyped
|
47
|
+
# @rbs **kwargs: untyped
|
48
|
+
# @rbs &block: untyped
|
49
|
+
# @rbs return: Quo::Query
|
50
|
+
def method_missing: (Symbol method_name, *untyped args, **untyped kwargs) ?{ (?) -> untyped } -> Quo::Query
|
51
|
+
|
52
|
+
# @rbs method_name: Symbol
|
53
|
+
# @rbs include_private: bool
|
54
|
+
# @rbs return: bool
|
55
|
+
def respond_to_missing?: (Symbol method_name, ?bool include_private) -> bool
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def validated_query: () -> untyped
|
60
|
+
|
61
|
+
# The underlying query is essentially the configured query with optional extras setup
|
62
|
+
def underlying_query: () -> ActiveRecord::Relation
|
63
|
+
|
64
|
+
# The configured query is the underlying query with paging
|
65
|
+
def configured_query: () -> ActiveRecord::Relation
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# Generated from lib/quo/relation_backed_query_specification.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Quo
|
4
|
+
# RelationBackedQuerySpecification encapsulates all the options for building a SQL query
|
5
|
+
# This separates the storage of query options from the actual query construction
|
6
|
+
# and provides a cleaner interface for RelationBackedQuery
|
7
|
+
class RelationBackedQuerySpecification
|
8
|
+
# @rbs!
|
9
|
+
# @options: Hash[Symbol, untyped]
|
10
|
+
attr_reader options: untyped
|
11
|
+
|
12
|
+
# @rbs options: Hash[Symbol, untyped]
|
13
|
+
def initialize: (?Hash[Symbol, untyped] options) -> untyped
|
14
|
+
|
15
|
+
# Creates a new specification with merged options
|
16
|
+
# @rbs new_options: Hash[Symbol, untyped]
|
17
|
+
# @rbs return: Quo::QuerySpecification
|
18
|
+
def merge: (Hash[Symbol, untyped] new_options) -> Quo::QuerySpecification
|
19
|
+
|
20
|
+
# Apply all the specification options to the given ActiveRecord relation
|
21
|
+
# @rbs relation: ActiveRecord::Relation
|
22
|
+
# @rbs return: ActiveRecord::Relation
|
23
|
+
def apply_to: (ActiveRecord::Relation relation) -> ActiveRecord::Relation
|
24
|
+
|
25
|
+
# @rbs *fields: untyped
|
26
|
+
# @rbs return: Quo::QuerySpecification
|
27
|
+
def select: (*untyped fields) -> Quo::QuerySpecification
|
28
|
+
|
29
|
+
# @rbs conditions: untyped
|
30
|
+
# @rbs return: Quo::QuerySpecification
|
31
|
+
def where: (untyped conditions) -> Quo::QuerySpecification
|
32
|
+
|
33
|
+
# @rbs order_clause: untyped
|
34
|
+
# @rbs return: Quo::QuerySpecification
|
35
|
+
def order: (untyped order_clause) -> Quo::QuerySpecification
|
36
|
+
|
37
|
+
# @rbs *columns: untyped
|
38
|
+
# @rbs return: Quo::QuerySpecification
|
39
|
+
def group: (*untyped columns) -> Quo::QuerySpecification
|
40
|
+
|
41
|
+
# @rbs value: Integer
|
42
|
+
# @rbs return: Quo::QuerySpecification
|
43
|
+
def limit: (Integer value) -> Quo::QuerySpecification
|
44
|
+
|
45
|
+
# @rbs value: Integer
|
46
|
+
# @rbs return: Quo::QuerySpecification
|
47
|
+
def offset: (Integer value) -> Quo::QuerySpecification
|
48
|
+
|
49
|
+
# @rbs tables: untyped
|
50
|
+
# @rbs return: Quo::QuerySpecification
|
51
|
+
def joins: (untyped tables) -> Quo::QuerySpecification
|
52
|
+
|
53
|
+
# @rbs tables: untyped
|
54
|
+
# @rbs return: Quo::QuerySpecification
|
55
|
+
def left_outer_joins: (untyped tables) -> Quo::QuerySpecification
|
56
|
+
|
57
|
+
# @rbs *associations: untyped
|
58
|
+
# @rbs return: Quo::QuerySpecification
|
59
|
+
def includes: (*untyped associations) -> Quo::QuerySpecification
|
60
|
+
|
61
|
+
# @rbs *associations: untyped
|
62
|
+
# @rbs return: Quo::QuerySpecification
|
63
|
+
def preload: (*untyped associations) -> Quo::QuerySpecification
|
64
|
+
|
65
|
+
# @rbs *associations: untyped
|
66
|
+
# @rbs return: Quo::QuerySpecification
|
67
|
+
def eager_load: (*untyped associations) -> Quo::QuerySpecification
|
68
|
+
|
69
|
+
# @rbs enabled: bool
|
70
|
+
# @rbs return: Quo::QuerySpecification
|
71
|
+
def distinct: (?bool enabled) -> Quo::QuerySpecification
|
72
|
+
|
73
|
+
# @rbs order_clause: untyped
|
74
|
+
# @rbs return: Quo::QuerySpecification
|
75
|
+
def reorder: (untyped order_clause) -> Quo::QuerySpecification
|
76
|
+
|
77
|
+
# @rbs *modules: untyped
|
78
|
+
# @rbs return: Quo::QuerySpecification
|
79
|
+
def extending: (*untyped modules) -> Quo::QuerySpecification
|
80
|
+
|
81
|
+
# @rbs *args: untyped
|
82
|
+
# @rbs return: Quo::QuerySpecification
|
83
|
+
def unscope: (*untyped args) -> Quo::QuerySpecification
|
84
|
+
|
85
|
+
# Builds a new specification from a hash of options
|
86
|
+
# @rbs options: Hash[Symbol, untyped]
|
87
|
+
# @rbs return: Quo::QuerySpecification
|
88
|
+
def self.build: (?Hash[Symbol, untyped] options) -> Quo::QuerySpecification
|
89
|
+
|
90
|
+
# Returns a blank specification
|
91
|
+
# @rbs return: Quo::QuerySpecification
|
92
|
+
def self.blank: () -> Quo::QuerySpecification
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Generated from lib/quo/relation_results.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Quo
|
4
|
+
class RelationResults < Results
|
5
|
+
# @rbs query: Quo::Query
|
6
|
+
# @rbs transformer: (^(untyped, ?Integer) -> untyped)?
|
7
|
+
# @rbs return: void
|
8
|
+
def initialize: (Quo::Query query, ?transformer: (^(untyped, ?Integer) -> untyped)?) -> void
|
9
|
+
|
10
|
+
# Are there any results for this query?
|
11
|
+
def exists?: () -> bool
|
12
|
+
|
13
|
+
# Gets the count of all results ignoring the current page and page size (if set).
|
14
|
+
def total_count: () -> Integer
|
15
|
+
|
16
|
+
# Gets the actual count of elements in the page of results (assuming paging is being used, otherwise the count of
|
17
|
+
# all results)
|
18
|
+
def page_count: () -> Integer
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
@query: Quo::RelationBackedQuery
|
23
|
+
|
24
|
+
@configured_query: ActiveRecord::Relation
|
25
|
+
|
26
|
+
# Note we reselect the query as this prevents query errors if the SELECT clause is not compatible with COUNT
|
27
|
+
# (SQLException: wrong number of arguments to function COUNT()). We do this in two ways, either with the primary key
|
28
|
+
# or with Arel.star. The primary key is the most compatible way to count, but if the query does not have a primary
|
29
|
+
# we fallback. The fallback "*" wont work in certain situations though, specifically if we have a limit() on the query
|
30
|
+
# which Arel constructs as a subquery. In this case we will get a SQL error as the generated SQL contains
|
31
|
+
# `SELECT COUNT(count_column) FROM (SELECT * AS count_column FROM ...) subquery_for_count` where the error is:
|
32
|
+
# `ActiveRecord::StatementInvalid: SQLite3::SQLException: near "AS": syntax error`
|
33
|
+
# Either way DB engines know how to count efficiently.
|
34
|
+
# @rbs query: ActiveRecord::Relation
|
35
|
+
# @rbs return: Integer
|
36
|
+
def count_query: (ActiveRecord::Relation query) -> Integer
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Generated from lib/quo/results.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Quo
|
4
|
+
class Results
|
5
|
+
def empty?: () -> bool
|
6
|
+
|
7
|
+
# Alias for total_count
|
8
|
+
def count: () -> Integer
|
9
|
+
|
10
|
+
# Alias for total_count
|
11
|
+
def size: () -> Integer
|
12
|
+
|
13
|
+
# Alias for page_count
|
14
|
+
def page_size: () -> Integer
|
15
|
+
|
16
|
+
# @rbs &block: (untyped, *untyped) -> untyped
|
17
|
+
# @rbs return: Hash[untyped, Array[untyped]]
|
18
|
+
def group_by: () { (untyped, *untyped) -> untyped } -> Hash[untyped, Array[untyped]]
|
19
|
+
|
20
|
+
# Delegate other enumerable methods to underlying collection but also transform
|
21
|
+
# @rbs override
|
22
|
+
def method_missing: ...
|
23
|
+
|
24
|
+
# @rbs name: Symbol
|
25
|
+
# @rbs include_private: bool
|
26
|
+
# @rbs return: bool
|
27
|
+
def respond_to_missing?: (Symbol name, ?bool include_private) -> bool
|
28
|
+
|
29
|
+
def transform?: () -> bool
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
@transformer: (^(untyped, ?Integer) -> untyped)?
|
34
|
+
|
35
|
+
# @rbs results: untyped
|
36
|
+
# @rbs return: untyped
|
37
|
+
def transform_results: (untyped results) -> untyped
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Generated from lib/quo/testing/collection_backed_fake.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Quo
|
4
|
+
module Testing
|
5
|
+
class CollectionBackedFake
|
6
|
+
def collection: () -> untyped
|
7
|
+
|
8
|
+
def results: () -> untyped
|
9
|
+
|
10
|
+
def page_count: () -> untyped
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Generated from lib/quo/testing/relation_backed_fake.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Quo
|
4
|
+
module Testing
|
5
|
+
class RelationBackedFake
|
6
|
+
def query: () -> untyped
|
7
|
+
|
8
|
+
def results: () -> untyped
|
9
|
+
|
10
|
+
def page_count: () -> untyped
|
11
|
+
|
12
|
+
def total_count: () -> untyped
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def validated_query: () -> untyped
|
17
|
+
|
18
|
+
def underlying_query: () -> untyped
|
19
|
+
|
20
|
+
def configured_query: () -> untyped
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|