sunstone 1.3.0 → 1.4.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c0406aa3472706a069b6ad96fbd734c94dbe2fa
|
4
|
+
data.tar.gz: 3c1d5642f1edb3c3868c2e01b4cc5408c3354ffa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f759b2964fb0767614828d9cc455fac9d769c2778e502131d55430c7f8c9b8a96766940eafa60d5077efccb7837b8fe6b467b6fd6f82bca597a7246267d96f72
|
7
|
+
data.tar.gz: ff84746a3d4dc7dcd66e4fcf0b779cee4b8d56e331fd57f97b34dcfb96c42db5ec5b18593cf5164c05d3d079ca5c336b6f77c5a42d32beb497610d16248b94ab
|
@@ -111,6 +111,12 @@ module ActiveRecord
|
|
111
111
|
def reset!
|
112
112
|
# configure_connection
|
113
113
|
end
|
114
|
+
|
115
|
+
# Executes the delete statement and returns the number of rows affected.
|
116
|
+
def delete(arel, name = nil, binds = [])
|
117
|
+
r = exec_delete(to_sql(arel, binds), name, binds)
|
118
|
+
r.rows.first.to_i
|
119
|
+
end
|
114
120
|
|
115
121
|
# TODO: deal with connection.close
|
116
122
|
# Disconnects from the database if already connected. Otherwise, this
|
@@ -39,13 +39,6 @@ module Arel
|
|
39
39
|
def compile bvs, conn = nil
|
40
40
|
path = "/#{table}"
|
41
41
|
|
42
|
-
case operation
|
43
|
-
when :count, :average, :min, :max
|
44
|
-
path += "/#{operation}"
|
45
|
-
when :update
|
46
|
-
path += "/#{id}"
|
47
|
-
end
|
48
|
-
|
49
42
|
get_params = {}
|
50
43
|
|
51
44
|
if where
|
@@ -64,6 +57,15 @@ module Arel
|
|
64
57
|
get_params[:order] = order if order
|
65
58
|
get_params[:columns] = columns if columns
|
66
59
|
|
60
|
+
|
61
|
+
case operation
|
62
|
+
when :count, :average, :min, :max
|
63
|
+
path += "/#{operation}"
|
64
|
+
when :update, :delete
|
65
|
+
path += "/#{get_params[:where]['id']}"
|
66
|
+
get_params.delete(:where)
|
67
|
+
end
|
68
|
+
|
67
69
|
if get_params.size > 0
|
68
70
|
path += '?' + get_params.to_param
|
69
71
|
end
|
@@ -84,18 +84,24 @@ module Arel
|
|
84
84
|
end
|
85
85
|
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
87
|
+
private
|
88
|
+
|
89
|
+
def visit_Arel_Nodes_DeleteStatement o, collector
|
90
|
+
collector.request_type = Net::HTTP::Delete
|
91
|
+
collector.table = o.relation.name
|
92
|
+
collector.operation = :delete
|
93
|
+
|
94
|
+
wheres = o.wheres.map { |x| visit(x, collector) }.inject([]) { |c, w|
|
95
|
+
w.is_a?(Array) ? c += w : c << w
|
96
|
+
}
|
97
|
+
if wheres.size != 1 && wheres.first.size != 1 && !wheres['id']
|
98
|
+
raise 'Upsupported'
|
99
|
+
else
|
100
|
+
collector.where = wheres
|
101
|
+
end
|
102
|
+
|
103
|
+
collector
|
104
|
+
end
|
99
105
|
#
|
100
106
|
# # FIXME: we should probably have a 2-pass visitor for this
|
101
107
|
# def build_subselect key, o
|
@@ -119,6 +125,8 @@ module Arel
|
|
119
125
|
}
|
120
126
|
if wheres.size != 1 && wheres.first.size != 1 && !wheres['id']
|
121
127
|
raise 'Upsupported'
|
128
|
+
else
|
129
|
+
collector.where = wheres
|
122
130
|
end
|
123
131
|
|
124
132
|
collector.id = wheres.first['id']
|
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.4.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-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|