sunstone 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/arel/collectors/sunstone.rb +3 -1
- data/lib/arel/visitors/sunstone.rb +35 -39
- data/sunstone.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5b03328d14a617316bc09421b97d94726aa85e6
|
4
|
+
data.tar.gz: a46d7b00f94e8a052d6014ab391bdf153c1686fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d82113de48120d57a36fa5cd35b980bac4456671c81c4712547d9323fbb4d620525a76271de2cfc9f4c4eea60934032510e5cb7f902fac8124261515ac31831c
|
7
|
+
data.tar.gz: 788d96dfeda86bee15c0b2009a3f05ba5838791a98354567af7040c1dee24690804559c6a4c18a22443e05048738722f5cbec74b58c10af13345dd820f2a82fc
|
@@ -2,7 +2,7 @@ module Arel
|
|
2
2
|
module Collectors
|
3
3
|
class Sunstone < Arel::Collectors::Bind
|
4
4
|
|
5
|
-
attr_accessor :request_type, :table, :where, :limit, :offset, :order, :operation, :columns, :updates, :eager_loads
|
5
|
+
attr_accessor :request_type, :table, :where, :limit, :offset, :order, :operation, :columns, :updates, :eager_loads, :id
|
6
6
|
|
7
7
|
def substitute_binds hash, bvs
|
8
8
|
if hash.is_a?(Array)
|
@@ -42,6 +42,8 @@ module Arel
|
|
42
42
|
case operation
|
43
43
|
when :count, :average, :min, :max
|
44
44
|
path += "/#{operation}"
|
45
|
+
when :update
|
46
|
+
path += "/#{id}"
|
45
47
|
end
|
46
48
|
|
47
49
|
get_params = {}
|
@@ -109,27 +109,26 @@ module Arel
|
|
109
109
|
# stmt
|
110
110
|
# end
|
111
111
|
#
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
# end
|
112
|
+
def visit_Arel_Nodes_UpdateStatement o, collector
|
113
|
+
collector.request_type = Net::HTTP::Patch
|
114
|
+
collector.table = o.relation.name
|
115
|
+
collector.operation = :update
|
116
|
+
|
117
|
+
wheres = o.wheres.map { |x| visit(x, collector) }.inject([]) { |c, w|
|
118
|
+
w.is_a?(Array) ? c += w : c << w
|
119
|
+
}
|
120
|
+
if wheres.size != 1 && wheres.first.size != 1 && !wheres['id']
|
121
|
+
raise 'Upsupported'
|
122
|
+
end
|
123
|
+
|
124
|
+
collector.id = wheres.first['id']
|
125
|
+
|
126
|
+
if o.values
|
127
|
+
collector.updates = o.values.map { |x| visit(x, collector) }.inject({}){|c,v| c.merge(v) }#.zip(o.values).to_h
|
128
|
+
end
|
129
|
+
|
130
|
+
collector
|
131
|
+
end
|
133
132
|
#
|
134
133
|
#
|
135
134
|
# def visit_Arel_Nodes_Exists o, collector
|
@@ -392,7 +391,7 @@ module Arel
|
|
392
391
|
#
|
393
392
|
def visit_Arel_Nodes_Count o, collector
|
394
393
|
collector.operation = :count
|
395
|
-
collector.columns = o.expressions.first
|
394
|
+
collector.columns = visit o.expressions.first, collector
|
396
395
|
end
|
397
396
|
#
|
398
397
|
# def visit_Arel_Nodes_Sum o, collector
|
@@ -590,18 +589,16 @@ module Arel
|
|
590
589
|
ors
|
591
590
|
end
|
592
591
|
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
# end
|
604
|
-
# end
|
592
|
+
def visit_Arel_Nodes_Assignment o, collector
|
593
|
+
case o.right
|
594
|
+
when Arel::Nodes::UnqualifiedColumn, Arel::Attributes::Attribute, Arel::Nodes::BindParam
|
595
|
+
{ visit(o.left, collector) => visit(o.right, collector) }
|
596
|
+
else
|
597
|
+
collector = visit o.left, collector
|
598
|
+
collector << " = "
|
599
|
+
collector << quote(o.right, column_for(o.left)).to_s
|
600
|
+
end
|
601
|
+
end
|
605
602
|
|
606
603
|
def visit_Arel_Nodes_Equality o, collector
|
607
604
|
key = visit(o.left, collector).to_s.split('.')
|
@@ -637,11 +634,10 @@ module Arel
|
|
637
634
|
collector
|
638
635
|
end
|
639
636
|
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
#
|
637
|
+
def visit_Arel_Nodes_UnqualifiedColumn o, collector
|
638
|
+
o.name
|
639
|
+
end
|
640
|
+
|
645
641
|
def visit_Arel_Attributes_Attribute o, collector
|
646
642
|
join_name = o.relation.table_alias || o.relation.name
|
647
643
|
# collector <<
|
data/sunstone.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunstone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Bracy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|