activerecord-turbopuffer-adapter 0.1.1 → 0.1.2
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/lib/arel/visitors/turbopuffer.rb +16 -4
- data/lib/turbopuffer/active_record/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: 23fa3cc80f986e56ce18f779fb0d108fc441bc0eb38bc7f8b3eeb23d25ae1c7b
|
|
4
|
+
data.tar.gz: 1f888b8b3bf5238a24f32d76bfcfa5fe71ef433a3b85c12db4b0f96d36c888f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c969a1e7195c56421d923e8d711f81c71028fe8b7ccbdb3b774ccb56671db31b75f5e9a9803bd28886ef503cf7c6477171f4175f799cbe025d65fba41e9a0476
|
|
7
|
+
data.tar.gz: 96966fdeb4d6ebeebaa15d717404359947b5afee6c753b19e92e7fe9fe50ead8e708e7728b654e72ef7706042f7dca34bfbec7cdbf3f278e04fde7449b9b271d
|
|
@@ -59,10 +59,14 @@ module Arel::Visitors
|
|
|
59
59
|
case filters.size
|
|
60
60
|
when 0 then nil
|
|
61
61
|
when 1 then filters.first
|
|
62
|
-
else
|
|
62
|
+
else conjunction(filters)
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
+
def conjunction(filters)
|
|
67
|
+
[ "And", filters.flat_map { |filter| (filter in [ "And", children ]) ? children : [ filter ] } ]
|
|
68
|
+
end
|
|
69
|
+
|
|
66
70
|
def aggregate_node(projection)
|
|
67
71
|
projection.is_a?(Arel::Nodes::As) ? projection.left : projection
|
|
68
72
|
end
|
|
@@ -182,7 +186,7 @@ module Arel::Visitors
|
|
|
182
186
|
def visit_Arel_Table(o) = o.name
|
|
183
187
|
|
|
184
188
|
# filters
|
|
185
|
-
def visit_Arel_Nodes_And(o) =
|
|
189
|
+
def visit_Arel_Nodes_And(o) = conjunction(o.children.map { |c| visit(c) })
|
|
186
190
|
def visit_Arel_Nodes_Or(o) = [ "Or", [ visit(o.left), visit(o.right) ] ]
|
|
187
191
|
def visit_Arel_Nodes_Grouping(o) = visit(o.expr)
|
|
188
192
|
|
|
@@ -200,10 +204,18 @@ module Arel::Visitors
|
|
|
200
204
|
"Lt" => "AnyLt", "Lte" => "AnyLte", "Gt" => "AnyGt", "Gte" => "AnyGte"
|
|
201
205
|
}.freeze
|
|
202
206
|
|
|
207
|
+
MATCHES_MISSING = [ "Lt", "Lte" ].freeze
|
|
208
|
+
|
|
203
209
|
def comparison(node, operator, value = visit(node.right))
|
|
210
|
+
attribute = visit(node.left)
|
|
204
211
|
operator = ARRAY_OPERATORS.fetch(operator) if array_attribute?(node.left) && !value.nil?
|
|
212
|
+
filter = [ attribute, operator, value ]
|
|
205
213
|
|
|
206
|
-
|
|
214
|
+
if MATCHES_MISSING.include?(operator) && !value.nil?
|
|
215
|
+
[ "And", [ filter, [ attribute, "NotEq", nil ] ] ]
|
|
216
|
+
else
|
|
217
|
+
filter
|
|
218
|
+
end
|
|
207
219
|
end
|
|
208
220
|
|
|
209
221
|
def array_attribute?(node)
|
|
@@ -227,7 +239,7 @@ module Arel::Visitors
|
|
|
227
239
|
def visit_Arel_Nodes_Between(o)
|
|
228
240
|
low, high = o.right.children.map { |bound| visit(bound) }
|
|
229
241
|
|
|
230
|
-
[
|
|
242
|
+
conjunction([ comparison(o, "Gte", low), comparison(o, "Lte", high) ])
|
|
231
243
|
end
|
|
232
244
|
|
|
233
245
|
def visit_Arel_Nodes_Not(o) = [ "Not", visit(o.expr) ]
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-turbopuffer-adapter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Richard Monette
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-09-
|
|
10
|
+
date: 2026-09-20 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activerecord
|