activesalesforce 0.0.7 → 0.0.8
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.
@@ -60,7 +60,7 @@ module ActiveRecord
|
|
60
60
|
def create_sobject()
|
61
61
|
fields = @attributes.changed_fields
|
62
62
|
|
63
|
-
sobj = [ 'type { :xmlns => "urn:sobject.partner.soap.sforce.com" }', self.class.
|
63
|
+
sobj = [ 'type { :xmlns => "urn:sobject.partner.soap.sforce.com" }', self.class.table_name ]
|
64
64
|
sobj << 'Id { :xmlns => "urn:sobject.partner.soap.sforce.com" }' << self.Id if self.Id
|
65
65
|
|
66
66
|
# now add any changed fields
|
@@ -106,7 +106,9 @@ module ActiveRecord
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def self.table_name
|
109
|
-
|
109
|
+
# Undo weird camilization that messes with custom object names
|
110
|
+
name = self.name
|
111
|
+
name.last(6) == "Custom" ? name.first(name.length - 6) << "__c" : name
|
110
112
|
end
|
111
113
|
|
112
114
|
def self.primary_key
|
@@ -64,7 +64,16 @@ module ActiveRecord
|
|
64
64
|
|
65
65
|
|
66
66
|
module ConnectionAdapters
|
67
|
-
class SalesforceError <
|
67
|
+
class SalesforceError < RuntimeError
|
68
|
+
attr :fault
|
69
|
+
|
70
|
+
def initialize(message, fault)
|
71
|
+
super message
|
72
|
+
|
73
|
+
@fault = fault
|
74
|
+
|
75
|
+
#puts "\n\nError encountered: #{message}\n\n"
|
76
|
+
end
|
68
77
|
end
|
69
78
|
|
70
79
|
class SalesforceAdapter < AbstractAdapter
|
@@ -136,10 +145,12 @@ module ActiveRecord
|
|
136
145
|
@batch_size = nil
|
137
146
|
|
138
147
|
records = get_result(@connection.query(:queryString => soql), :query).records
|
148
|
+
|
149
|
+
result = []
|
150
|
+
return result unless records
|
139
151
|
|
140
152
|
records = [ records ] unless records.is_a?(Array)
|
141
153
|
|
142
|
-
result = []
|
143
154
|
records.each do |record|
|
144
155
|
attributes = Salesforce::SObjectAttributes.new(columns_map(record[:type]), record)
|
145
156
|
result << attributes
|
@@ -169,13 +180,14 @@ module ActiveRecord
|
|
169
180
|
def get_result(response, method)
|
170
181
|
responseName = (method.to_s + "Response").to_sym
|
171
182
|
finalResponse = response[responseName]
|
172
|
-
|
183
|
+
|
184
|
+
raise SalesforceError.new(response[:Fault].faultstring, response.fault) unless finalResponse
|
173
185
|
|
174
186
|
result = finalResponse[:result]
|
175
187
|
end
|
176
188
|
|
177
189
|
def check_result(result)
|
178
|
-
raise SalesforceError, result[:
|
190
|
+
raise SalesforceError.new(result[:Errors], result[:Errors].Message) unless result[:success] == "true"
|
179
191
|
result
|
180
192
|
end
|
181
193
|
|
@@ -183,8 +195,6 @@ module ActiveRecord
|
|
183
195
|
cached_columns = @columns_map[table_name]
|
184
196
|
return cached_columns if cached_columns
|
185
197
|
|
186
|
-
puts "describeSObject(#{table_name})"
|
187
|
-
|
188
198
|
cached_columns = []
|
189
199
|
@columns_map[table_name] = cached_columns
|
190
200
|
|
data/test/unit/account_test.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: activesalesforce
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2006-01-
|
6
|
+
version: 0.0.8
|
7
|
+
date: 2006-01-26 00:00:00 -05:00
|
8
8
|
summary: ActiveSalesforce is an extension to the Rails Framework that allows for the dynamic creation and management of ActiveRecord objects through the use of Salesforce meta-data and uses a Salesforce.com organization as the backing store.
|
9
9
|
require_paths:
|
10
10
|
- lib
|