quo 0.5.3 → 0.6.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 +0 -33
- data/lib/quo/query.rb +6 -1
- data/lib/quo/utilities/callstack.rb +2 -1
- data/lib/quo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78b41f6d815238ed48ed00790498c1d6d7e8c099c0312fe82a441dcbe68d667f
|
4
|
+
data.tar.gz: 84d11fe9c86ef448d17229f0544a1966f55597ce1a8522e4ef92b626fea24537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc89984c05233e3300c62149c457bec4e079c9d2dd646011c5fa348aaee3a66e59e627fcc93051ac992bd167df536b27d51784e241996dd548dde84b25ec3bde
|
7
|
+
data.tar.gz: 1c3b41c2f541e96121b07bb3ce640846b3e308fcd018625d211b2f96a43ff4fe9cc0372d3bf8602c7fb22594c9935bb72bdd48041bde5e5eb391e6c3969a3ecc
|
data/README.md
CHANGED
@@ -130,38 +130,6 @@ composed = query1 + query2 # or Quo::Query.compose(query1, query2) or query1.com
|
|
130
130
|
composed.first
|
131
131
|
```
|
132
132
|
|
133
|
-
```ruby
|
134
|
-
class CompanyToBeApproved < Quo::TypedQuery
|
135
|
-
def query
|
136
|
-
Registration
|
137
|
-
.left_joins(:approval)
|
138
|
-
.where(approvals: {completed_at: nil})
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
class CompanyInUsCityAndState < Quo::TypedQuery
|
143
|
-
param :state, Literal::Union[String, Array[String]]
|
144
|
-
param :city, optional(Literal::Union[String, Array[String]])
|
145
|
-
|
146
|
-
def query
|
147
|
-
q = Registration
|
148
|
-
.joins(company: :address)
|
149
|
-
.where(addresses: {state: state})
|
150
|
-
q = q.where(addresses: {city: city}) if city
|
151
|
-
q
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
|
156
|
-
query1 = CompanyToBeApproved.new
|
157
|
-
query_partialy_applied = CompanyInUsState.with(state: "California")
|
158
|
-
query2 = query_partialy_applied.with(city: ["San Francisco", "Los Angeles"]).operation
|
159
|
-
|
160
|
-
composed = query1 + query2
|
161
|
-
# '+' composes the queries and returns a new prepared query
|
162
|
-
composed.first
|
163
|
-
```
|
164
|
-
|
165
133
|
This effectively executes:
|
166
134
|
|
167
135
|
```ruby
|
@@ -170,7 +138,6 @@ Registration
|
|
170
138
|
.joins(company: :address)
|
171
139
|
.where(approvals: {completed_at: nil})
|
172
140
|
.where(addresses: {state: options[:state]})
|
173
|
-
.limit(1)
|
174
141
|
```
|
175
142
|
|
176
143
|
It is also possible to compose with an `ActiveRecord::Relation`. This can be useful in a Query object itself to help
|
data/lib/quo/query.rb
CHANGED
@@ -202,11 +202,16 @@ module Quo
|
|
202
202
|
configured_query.to_sql if relation?
|
203
203
|
end
|
204
204
|
|
205
|
-
# Unwrap the
|
205
|
+
# Unwrap the paginated query
|
206
206
|
def unwrap
|
207
207
|
configured_query
|
208
208
|
end
|
209
209
|
|
210
|
+
# Unwrap the un-paginated query
|
211
|
+
def unwrap_unpaginated
|
212
|
+
underlying_query
|
213
|
+
end
|
214
|
+
|
210
215
|
delegate :distinct, to: :configured_query
|
211
216
|
|
212
217
|
private
|
@@ -13,7 +13,8 @@ module Quo
|
|
13
13
|
stack_to_display = stack[0..callstack_size]
|
14
14
|
message = "\n[Query stack]: -> #{stack_to_display&.join("\n &> ")}\n"
|
15
15
|
message += " (truncated to #{callstack_size} most recent)" if callstack_size && stack.size > callstack_size
|
16
|
-
Quo.configuration.logger&.
|
16
|
+
logger = Quo.configuration.logger&.call
|
17
|
+
logger.info(message) if logger
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
data/lib/quo/version.rb
CHANGED
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.6.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: 2024-
|
11
|
+
date: 2024-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|