GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: DataMapper Adapters
Homepage: http://www.yehudakatz.com
Clone URL: git://github.com/wycats/dm-adapters.git
Some changes. WARNING: Broken build.
wycats (author)
Sat Jun 14 23:45:58 -0700 2008
commit  c28d2f2e001d7df2ae087edbb988c38a5b9ecd20
tree    4f1959762bbf48f0620331c870f27371e2099ae0
parent  99ef4f8d404592139c10bb91ec0a4b2b8f2668d6
...
105
106
107
108
 
 
109
110
111
112
 
113
114
 
115
116
117
118
119
 
 
 
 
120
121
 
122
123
124
125
126
127
 
 
 
 
 
128
129
130
131
132
133
134
 
 
 
 
 
 
 
 
135
136
137
138
139
 
140
141
142
143
144
 
 
145
146
147
...
105
106
107
 
108
109
110
111
112
 
113
114
 
115
116
 
 
 
 
117
118
119
120
121
 
122
123
 
 
 
 
 
124
125
126
127
128
129
 
 
 
 
 
 
130
131
132
133
134
135
136
137
138
 
 
139
 
140
141
142
 
 
 
143
144
145
146
147
0
@@ -105,43 +105,43 @@ module DataMapper
0
         @connection = SalesforceAPI::Connection.new(URI.unescape(@uri.user), @uri.password, "#{ENV["HOME"]}/.salesforce/#{basename}").driver
0
       end
0
       
0
- def read_set(repository, query)
0
+ def read_many(query)
0
+ repository = query.repository
0
         properties = query.fields
0
         properties_with_indexes = Hash[*properties.zip((0...properties.size).to_a).flatten]
0
         
0
- set = Collection.new(query)
0
+ Collection.new(query) do |set|
0
         
0
- conditions = query.conditions.map {|c| SQL.from_condition(c, repository)}.compact.join(") AND (")
0
+ conditions = query.conditions.map {|c| SQL.from_condition(c, repository)}.compact.join(") AND (")
0
         
0
- query_string = "SELECT #{query.fields.map {|f| f.field}.join(", ")} from #{query.model.storage_name(repository.name)}"
0
- query_string << " WHERE (#{conditions})" unless conditions.empty?
0
- query_string << " ORDER BY #{SQL.order(query.order[0])}" unless query.order.empty?
0
- query_string << " LIMIT #{query.limit}" if query.limit
0
+ query_string = "SELECT #{query.fields.map {|f| f.field}.join(", ")} from #{query.model.storage_name(repository.name)}"
0
+ query_string << " WHERE (#{conditions})" unless conditions.empty?
0
+ query_string << " ORDER BY #{SQL.order(query.order[0])}" unless query.order.empty?
0
+ query_string << " LIMIT #{query.limit}" if query.limit
0
 
0
- DataMapper.logger.debug query_string
0
+ DataMapper.logger.debug query_string
0
         
0
- begin
0
- results = @connection.query(:queryString => query_string).result
0
- rescue SOAP::FaultError => e
0
- raise SalesforceAPI::ReadError, e.message
0
- end
0
+ begin
0
+ results = @connection.query(:queryString => query_string).result
0
+ rescue SOAP::FaultError => e
0
+ raise SalesforceAPI::ReadError, e.message
0
+ end
0
           
0
- results = results.size > 0 ? results.records : []
0
-
0
- results.each do |result|
0
- props = properties_with_indexes.inject([]) do |accum, (prop, idx)|
0
- accum[idx] = result.send(soap_attr(prop))
0
- accum
0
+ results = results.size > 0 ? results.records : []
0
+
0
+ results.each do |result|
0
+ props = properties_with_indexes.inject([]) do |accum, (prop, idx)|
0
+ accum[idx] = result.send(soap_attr(prop))
0
+ accum
0
+ end
0
+ set.load(props)
0
           end
0
- set.load(props)
0
- end
0
         
0
- set
0
+ end
0
       end
0
       
0
- def read(repository, resource, key)
0
- read_set(repository, DataMapper::Query.new(repository, resource,
0
- {resource.key(repository.name)[0].name.eql => key[0]})).first
0
+ def read_one(query)
0
+ read_many(query).first
0
       end
0
       
0
       def update(repository, resource)

Comments

    No one has commented yet.