<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,7 @@
 = dm-adapter-simpledb
 
+This is the new version of the adapter now based on Right_Aws which has helped a lot with performance. The rest of this FAQ is a bit dated...
+
 Written by Jeremy Boles
 Contributers Edward Ocampo-Gooding, Dan Mayer
 </diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -32,8 +32,7 @@ module DataMapper
       def read_many(query)
         sdb_type = simpledb_type(query.model)
         
-        conditions = set_conditions(query, sdb_type)
-        order = set_sort_order(query, conditions)
+        conditions, order = set_conditions_and_sort_order(query, sdb_type)
         results = get_results(query, conditions, order)
 
         Collection.new(query) do |collection|
@@ -79,51 +78,48 @@ module DataMapper
         @uri[:domain]
       end
 
-      #sets the conditions for the SDB query
-      def set_conditions(query, sdb_type)
+      #sets the conditions and order for the SDB query
+      def set_conditions_and_sort_order(query, sdb_type)
         conditions = [&quot;simpledb_type = '#{sdb_type}'&quot;]
-        if query.conditions.size &gt; 0
-          conditions += query.conditions.map do |condition|
-            operator = case condition[0]
-              when :eql then '='
-              when :not then '!='
-              when :gt then '&gt;'
-              when :gte then '&gt;='
-              when :lt then '&lt;'
-              when :lte then '&lt;='
-              else raise &quot;Invalid query operator: #{operator.inspect}&quot;
-            end
-            &quot;#{condition[1].name.to_s} #{operator} '#{condition[2].to_s}'&quot;
-          end
-        end
-        conditions
-      end
+        # look for query.order.first and insure in conditions
+        # raise if order if greater than 1
 
-      #adds sort information to SDB query
-      def set_sort_order(query, conditions)
-        if query.order!=nil &amp;&amp; query.order.length &gt; 0
+        if query.order &amp;&amp; query.order.length &gt; 0
           query_object = query.order[0]
           #anything sorted on must be a condition for SDB
-          conditions &lt;&lt; &quot;#{query_object.property.name.to_s} &gt; ''&quot; 
-          order = &quot;order by #{query_object.property.name.to_s} #{query_object.direction==:desc ? 'desc' : 'asc'}&quot;
+          conditions &lt;&lt; &quot;#{query_object.property.name} IS NOT NULL&quot; 
+          order = &quot;order by #{query_object.property.name} #{query_object.direction}&quot;
         else
           order = &quot;&quot;
         end
+
+        query.conditions.each do |operator, attribute, value|
+          operator = case operator
+                     when :eql then '='
+                     when :not then '!='
+                     when :gt then '&gt;'
+                     when :gte then '&gt;='
+                     when :lt then '&lt;'
+                     when :lte then '&lt;='
+                     else raise &quot;Invalid query operator: #{operator.inspect}&quot; 
+                     end
+          conditions &lt;&lt; &quot;#{attribute.name} #{operator} '#{value}'&quot;
+        end
+        [conditions,order]
       end
       
       #gets all results or proper number of results depending on the :limit
       def get_results(query, conditions, order)
-        
         query_call = &quot;select * from #{domain} &quot;
-        query_call = query_call + &quot;where #{conditions.compact.join(' and ')}&quot; if conditions.length &gt; 0
-        query_call = query_call + &quot; #{order}&quot;
+        query_call &lt;&lt; &quot;where #{conditions.compact.join(' and ')}&quot; if conditions.length &gt; 0
+        query_call &lt;&lt; &quot; #{order}&quot;
         if query.limit!=nil
           query_limit = query.limit
-          query_call = query_call + &quot; limit #{query.limit}&quot; 
+          query_call &lt;&lt; &quot; limit #{query.limit}&quot; 
         else
           #on large items force the max limit
           query_limit = 999999999 #TODO hack for query.limit being nil
-          query_call = query_call + &quot; limit 2500&quot;
+          query_call &lt;&lt; &quot; limit 2500&quot;
         end
         results = sdb.select(query_call)
         </diff>
      <filename>lib/simpledb_adapter.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1c32b245606a8802ba3d02c7167565e39ba71088</id>
    </parent>
  </parents>
  <author>
    <name>Dan Mayer</name>
    <email>dan@devver.net</email>
  </author>
  <url>http://github.com/danmayer/dm-adapter-simpledb/commit/69a14a733fc9e556fa3c05fd40f1fd8655ac3274</url>
  <id>69a14a733fc9e556fa3c05fd40f1fd8655ac3274</id>
  <committed-date>2009-06-23T22:42:35-07:00</committed-date>
  <authored-date>2009-06-23T22:42:35-07:00</authored-date>
  <message>merged in the rectorings from the BRUG meeting</message>
  <tree>b99f33ab78fe8139c749ea3d6de06caa0ae9f3af</tree>
  <committer>
    <name>Dan Mayer</name>
    <email>dan@devver.net</email>
  </committer>
</commit>
