quo 1.0.0.alpha1 → 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 +1 -1
- data/Appraisals +4 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +222 -233
- data/gemfiles/rails_8.0.gemfile +15 -0
- data/lib/quo/composed_query.rb +154 -44
- data/lib/quo/query.rb +0 -1
- data/lib/quo/relation_backed_query.rb +51 -78
- data/lib/quo/relation_backed_query_specification.rb +154 -0
- data/lib/quo/version.rb +1 -1
- data/lib/quo.rb +1 -0
- data/sig/generated/quo/composed_query.rbs +45 -16
- data/sig/generated/quo/relation_backed_query.rbs +21 -44
- data/sig/generated/quo/relation_backed_query_specification.rbs +94 -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/literal.rbs +7 -0
- metadata +15 -12
@@ -20,54 +20,17 @@ module Quo
|
|
20
20
|
# @rbs return: String
|
21
21
|
def self.sanitize_sql_parameter: (untyped value) -> String
|
22
22
|
|
23
|
-
@
|
23
|
+
@_specification: Quo::RelationBackedQuerySpecification?
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
@_rel_order: untyped?
|
28
|
-
|
29
|
-
@_rel_limit: untyped?
|
30
|
-
|
31
|
-
@_rel_preload: untyped?
|
32
|
-
|
33
|
-
@_rel_includes: untyped?
|
34
|
-
|
35
|
-
@_rel_select: untyped?
|
36
|
-
|
37
|
-
# SQL 'SELECT' configuration, calls to underlying AR relation
|
38
|
-
# @rbs *options: untyped
|
39
|
-
# @rbs return: Quo::Query
|
40
|
-
def select: (*untyped options) -> Quo::Query
|
41
|
-
|
42
|
-
# SQL 'LIMIT' configuration, calls to underlying AR relation
|
43
|
-
# @rbs limit: untyped
|
44
|
-
# @rbs return: Quo::Query
|
45
|
-
def limit: (untyped limit) -> Quo::Query
|
46
|
-
|
47
|
-
# SQL 'ORDER BY' configuration, calls to underlying AR relation
|
48
|
-
# @rbs options: untyped
|
25
|
+
# Apply a query specification to this query
|
26
|
+
# @rbs specification: Quo::RelationBackedQuerySpecification
|
49
27
|
# @rbs return: Quo::Query
|
50
|
-
def
|
28
|
+
def with_specification: (Quo::RelationBackedQuerySpecification specification) -> Quo::Query
|
51
29
|
|
52
|
-
#
|
53
|
-
# @rbs
|
30
|
+
# Apply query options using the specification
|
31
|
+
# @rbs options: Hash[Symbol, untyped]
|
54
32
|
# @rbs return: Quo::Query
|
55
|
-
def
|
56
|
-
|
57
|
-
# Configures underlying AR relation to include associations
|
58
|
-
# @rbs *options: untyped
|
59
|
-
# @rbs return: Quo::Query
|
60
|
-
def includes: (*untyped options) -> Quo::Query
|
61
|
-
|
62
|
-
# Configures underlying AR relation to preload associations
|
63
|
-
# @rbs *options: untyped
|
64
|
-
# @rbs return: Quo::Query
|
65
|
-
def preload: (*untyped options) -> Quo::Query
|
66
|
-
|
67
|
-
# Calls to underlying AR distinct method
|
68
|
-
# @rbs enabled: bool
|
69
|
-
# @rbs return: Quo::Query
|
70
|
-
def distinct: (?bool enabled) -> Quo::Query
|
33
|
+
def with: (?Hash[Symbol, untyped] options) -> Quo::Query
|
71
34
|
|
72
35
|
# @rbs return: Quo::CollectionBackedQuery
|
73
36
|
def to_collection: (?total_count: untyped) -> Quo::CollectionBackedQuery
|
@@ -77,6 +40,20 @@ module Quo
|
|
77
40
|
# Return the SQL string for this query if its a relation type query object
|
78
41
|
def to_sql: () -> String
|
79
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
|
+
|
80
57
|
private
|
81
58
|
|
82
59
|
def validated_query: () -> untyped
|
@@ -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,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
|
data/sig/literal.rbs
ADDED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Ierodiaconou
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-31 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activerecord
|
@@ -19,7 +18,7 @@ dependencies:
|
|
19
18
|
version: '7'
|
20
19
|
- - "<"
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
21
|
+
version: '9'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +28,7 @@ dependencies:
|
|
29
28
|
version: '7'
|
30
29
|
- - "<"
|
31
30
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
31
|
+
version: '9'
|
33
32
|
- !ruby/object:Gem::Dependency
|
34
33
|
name: activesupport
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +38,7 @@ dependencies:
|
|
39
38
|
version: '7'
|
40
39
|
- - "<"
|
41
40
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
41
|
+
version: '9'
|
43
42
|
type: :runtime
|
44
43
|
prerelease: false
|
45
44
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,14 +48,14 @@ dependencies:
|
|
49
48
|
version: '7'
|
50
49
|
- - "<"
|
51
50
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
51
|
+
version: '9'
|
53
52
|
- !ruby/object:Gem::Dependency
|
54
53
|
name: literal
|
55
54
|
requirement: !ruby/object:Gem::Requirement
|
56
55
|
requirements:
|
57
56
|
- - ">="
|
58
57
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
58
|
+
version: 1.6.0
|
60
59
|
- - "<"
|
61
60
|
- !ruby/object:Gem::Version
|
62
61
|
version: '2'
|
@@ -66,7 +65,7 @@ dependencies:
|
|
66
65
|
requirements:
|
67
66
|
- - ">="
|
68
67
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
68
|
+
version: 1.6.0
|
70
69
|
- - "<"
|
71
70
|
- !ruby/object:Gem::Version
|
72
71
|
version: '2'
|
@@ -102,6 +101,7 @@ files:
|
|
102
101
|
- gemfiles/rails_7.0.gemfile
|
103
102
|
- gemfiles/rails_7.1.gemfile
|
104
103
|
- gemfiles/rails_7.2.gemfile
|
104
|
+
- gemfiles/rails_8.0.gemfile
|
105
105
|
- lib/quo.rb
|
106
106
|
- lib/quo/collection_backed_query.rb
|
107
107
|
- lib/quo/collection_results.rb
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/quo/preloadable.rb
|
112
112
|
- lib/quo/query.rb
|
113
113
|
- lib/quo/relation_backed_query.rb
|
114
|
+
- lib/quo/relation_backed_query_specification.rb
|
114
115
|
- lib/quo/relation_results.rb
|
115
116
|
- lib/quo/results.rb
|
116
117
|
- lib/quo/rspec/helpers.rb
|
@@ -127,16 +128,19 @@ files:
|
|
127
128
|
- sig/generated/quo/preloadable.rbs
|
128
129
|
- sig/generated/quo/query.rbs
|
129
130
|
- sig/generated/quo/relation_backed_query.rbs
|
131
|
+
- sig/generated/quo/relation_backed_query_specification.rbs
|
130
132
|
- sig/generated/quo/relation_results.rbs
|
131
133
|
- sig/generated/quo/results.rbs
|
134
|
+
- sig/generated/quo/testing/collection_backed_fake.rbs
|
135
|
+
- sig/generated/quo/testing/relation_backed_fake.rbs
|
132
136
|
- sig/generated/quo/version.rbs
|
137
|
+
- sig/literal.rbs
|
133
138
|
homepage: https://github.com/stevegeek/quo
|
134
139
|
licenses:
|
135
140
|
- MIT
|
136
141
|
metadata:
|
137
142
|
homepage_uri: https://github.com/stevegeek/quo
|
138
143
|
source_code_uri: https://github.com/stevegeek/quo
|
139
|
-
post_install_message:
|
140
144
|
rdoc_options: []
|
141
145
|
require_paths:
|
142
146
|
- lib
|
@@ -151,8 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
155
|
- !ruby/object:Gem::Version
|
152
156
|
version: '0'
|
153
157
|
requirements: []
|
154
|
-
rubygems_version: 3.
|
155
|
-
signing_key:
|
158
|
+
rubygems_version: 3.6.2
|
156
159
|
specification_version: 4
|
157
160
|
summary: Quo is a query object gem for Rails
|
158
161
|
test_files: []
|