<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,9 @@
+== 0.3.0 2008-06-05
+
+* 2 major enhancements
+  * insert now supports the DBSlayer's INSERT_ID
+  * update now correctly uses the DBSlayer's AFFECTED_ROWS
+
 == 0.2.5 2008-05-06
 
 * 3 minor enhancements:</diff>
      <filename>History.txt</filename>
    </modified>
    <modified>
      <diff>@@ -339,9 +339,10 @@ module ActiveRecord
         end
 
         # Executes the update statement and returns the number of rows affected.
-        def update_sql(sql, name = nil)
-          execute(sql, name).rows[0][0]
-        end
+        # def update_sql(sql, name = nil)
+        #   execute(sql, name)
+        # end
+        # 
         
         def supports_views?
           ## get mysql version</diff>
      <filename>lib/active_record/connection_adapters/dbslayer_adapter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,6 +26,18 @@ module ActiveRecord
         @hash['HEADER']
       end
       
+      def success?
+        @hash['SUCCESS']
+      end
+      
+      def affected_rows
+        @hash['AFFECTED_ROWS']
+      end
+      
+      def insert_id
+        @hash['INSERT_ID']
+      end
+      
       ## Compatibility to the MySQL ones
       def num_rows
         return 0 if rows.nil?
@@ -58,11 +70,13 @@ module ActiveRecord
     end
 
     class DbslayerConnection
-      attr_reader :host, :port
+      attr_reader :host, :port, :insert_id, :affected_rows
       
       def initialize(host='localhost', port=9090)
         @host = host
         @port = port
+        @insert_id = nil
+        @affected_rows = nil
       end
 
       ##
@@ -73,18 +87,19 @@ module ActiveRecord
         # check for an error
         if dbslay_results['MYSQL_ERROR']
           raise DbslayerException, &quot;MySQL Error #{dbslay_results['MYSQL_ERRNO']}: #{dbslay_results['MYSQL_ERROR']}&quot;
-        elsif dbslay_results['RESULT']
-          result = dbslay_results['RESULT']
+        elsif result = dbslay_results['RESULT']
           case result
           when Hash
-            DbslayerResult.new(result)
+            out = DbslayerResult.new(result)
+            set_affected!(out)
+            out
           when Array
-            result.map {|r| DbslayerResult.new(r) }
+            out = result.map {|r| DbslayerResult.new(r) }
+            set_affected!(out.last)
+            out
           else  
             raise DbslayerException, &quot;Unknown format for SQL results from DBSlayer&quot;
           end
-        elsif dbslay_results['SUCCESS']
-          return dbslay_results['SUCCESS']
         else  
           raise DbslayerException, &quot;Unknown format for SQL results from DBSlayer&quot;
         end
@@ -149,6 +164,11 @@ module ActiveRecord
           JSON.parse(file.read)
         end
       end
+      
+      def set_affected!(result)
+        @insert_id = result.insert_id
+        @affected_rows = result.affected_rows
+      end
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/active_record/connection_adapters/dbslayer_connection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -27,7 +27,7 @@ end
 module ActiveRecord
   module ConnectionAdapters
     class DbslayerAdapter
-      VERSION = '0.2.5'
+      VERSION = '0.3.0'
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/activerecord-dbslayer-adapter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 require 'rubygems'
+require 'test/unit'
 require 'active_support'
 require 'active_record'
-require 'test/unit'
 require 'mocha'
 
 $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -58,7 +58,13 @@ MULTIPLE_RESULTS = {
               ]
 }.freeze
 
-NULL_RESULT = {&quot;SUCCESS&quot; =&gt; true}
+NULL_RESULT = {&quot;RESULT&quot; =&gt; {&quot;SUCCESS&quot; =&gt; true}}.freeze
+
+INSERT_ID_RESULT = {&quot;RESULT&quot; =&gt; {&quot;AFFECTED_ROWS&quot; =&gt; 1 , &quot;INSERT_ID&quot; =&gt; 1 , &quot;SUCCESS&quot; =&gt; true} , &quot;SERVER&quot; =&gt; &quot;dbslayer&quot;}.freeze
+                         
+UPDATE_RESULT = {&quot;RESULT&quot; =&gt; {&quot;AFFECTED_ROWS&quot; =&gt; 42 , &quot;SUCCESS&quot; =&gt; true} , &quot;SERVER&quot; =&gt; &quot;dbslayer&quot;}.freeze
+
+INSERT_THEN_SELECT_RESULT = {&quot;RESULT&quot;=&gt; [{&quot;AFFECTED_ROWS&quot;=&gt;1, &quot;INSERT_ID&quot;=&gt;5, &quot;SUCCESS&quot;=&gt;true}, {&quot;HEADER&quot;=&gt;[&quot;id&quot;, &quot;name&quot;], &quot;ROWS&quot;=&gt;[[1, &quot;Brooklyn&quot;], [2, &quot;Queens&quot;], [3, &quot;Staten Island&quot;], [4, &quot;Queens&quot;], [5, &quot;Paramus&quot;]], &quot;TYPES&quot;=&gt;[&quot;MYSQL_TYPE_LONG&quot;, &quot;MYSQL_TYPE_VAR_STRING&quot;]}], &quot;SERVER&quot;=&gt;&quot;dbslayer&quot;}.freeze
 
 SHOW_TABLES_REPLY = {&quot;RESULT&quot;=&gt; {&quot;HEADER&quot;=&gt; [&quot;Tables_in_Test_Database&quot;], 
                      &quot;ROWS&quot; =&gt; [[&quot;table1&quot;], [&quot;table2&quot;]], </diff>
      <filename>test/helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,12 +29,20 @@ class Test_ActiveRecord_ConnectionAdapters_DbslayerAdapter &lt; Test::Unit::TestCas
     assert_equal CITY_ROWS, rows
   end
   
-  def test_insert_sql_with_id
+  def test_insert_returns_id
+    insert_sql = &quot;insert into cities(name) values(\&quot;Seattle\&quot;)&quot;
+    @adapter.raw_connection.expects(:cmd_execute).with(:db, sql_hash(insert_sql)).returns(INSERT_ID_RESULT)
     
+    id = @adapter.insert_sql(insert_sql)
+    assert_equal 1, id
   end
   
-  def test_insert_sql_no_id
+  def test_update_affected_rows
+    update_sql = &quot;update cities set urban=1&quot;
+    @adapter.raw_connection.expects(:cmd_execute).with(:db, sql_hash(update_sql)).returns(UPDATE_RESULT)
     
+    affected_rows = @adapter.send :update_sql, update_sql
+    assert_equal 42, affected_rows
   end
   
   def test_tables</diff>
      <filename>test/test_dbslayer_adapter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,14 +34,6 @@ class TestDbslayerConnection &lt; Test::Unit::TestCase
     assert_not_nil reply.rows
   end
   
-  def test_sql_null_return
-    sql_command = &quot;update set posted = 1&quot;
-    @slayer.stubs(:cmd_execute).with(:db, {&quot;SQL&quot; =&gt; sql_command}).returns(NULL_RESULT)
-    
-    status = @slayer.sql_query(sql_command)
-    assert_equal true, status
-  end
-  
   def test_multiple_results
     sql_command = &quot;select * from cities limit 10; select * from countries limit 3&quot;
     @slayer.stubs(:cmd_execute).with(:db, {&quot;SQL&quot; =&gt; sql_command}).returns(MULTIPLE_RESULTS)</diff>
      <filename>test/test_dbslayer_connection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -30,6 +30,10 @@ class Test_ActiveRecord_ConnectionAdapters_DbslayerResults &lt; Test::Unit::TestCas
     assert_equal CITY_TYPES, @result.types
   end
   
+  def test_success?
+    assert !@result.success?
+  end
+  
   def test_hash_rows
     assert_equal CITY_HASH_ROWS, @result.hash_rows
   end
@@ -52,3 +56,23 @@ class Test_ActiveRecord_ConnectionAdapters_DbslayerResults &lt; Test::Unit::TestCas
     assert_equal CITY_HASH_ROWS, output
   end
 end
+
+class Test_ActiveRecord_ConnectionAdapters_DbslayerResults_Insert &lt; Test::Unit::TestCase
+  include ActiveRecord::ConnectionAdapters
+  
+  def setup
+    @result = ActiveRecord::ConnectionAdapters::DbslayerResult.new(INSERT_ID_RESULT[&quot;RESULT&quot;])
+  end
+  
+  def test_success?
+    assert @result.success?
+  end
+  
+  def test_affected_rows
+    assert_equal 1, @result.affected_rows
+  end
+  
+  def test_insert_id
+    assert_equal 1, @result.insert_id
+  end
+end
\ No newline at end of file</diff>
      <filename>test/test_dbslayer_results.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>68359331bee492f794ab52fa80b7d1a005013d3b</id>
    </parent>
  </parents>
  <author>
    <name>Jacob Harris</name>
    <email>harrisj@harrisj.local</email>
  </author>
  <url>http://github.com/harrisj/activerecord-dbslayer-adapter/commit/57e5901792cf6e01c6d3066eade423d061458eb7</url>
  <id>57e5901792cf6e01c6d3066eade423d061458eb7</id>
  <committed-date>2008-06-05T18:59:49-07:00</committed-date>
  <authored-date>2008-06-05T18:59:49-07:00</authored-date>
  <message>Now changed to work correctly with DBslayers insert and update semantics</message>
  <tree>d8fdd6ce3fb768f86928707917e34b4abdb7f9de</tree>
  <committer>
    <name>Jacob Harris</name>
    <email>harrisj@harrisj.local</email>
  </committer>
</commit>
