<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>tasks/rcov.rake</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,10 +1,17 @@
-== 0.0.2 2008-05-01
+== 0.2.5 2008-05-06
+
+* 3 minor enhancements:
+  * passes test for multiple results
+  * passes test for null results
+  * rcov rake task
+
+== 0.2.0 2008-05-01
 
 * 2 major enhancments:
   * tests
   * it actually works!
 
-== 0.0.1 2008-04-15
+== 0.1.0 2008-04-15
 
 * 1 major enhancement:
   * Initial release</diff>
      <filename>History.txt</filename>
    </modified>
    <modified>
      <diff>@@ -16,6 +16,7 @@ script/txt2html
 setup.rb
 tasks/deployment.rake
 tasks/environment.rake
+tasks/rcov.rake
 tasks/website.rake
 test/helper.rb
 test/localtest.rb</diff>
      <filename>Manifest.txt</filename>
    </modified>
    <modified>
      <diff>@@ -70,16 +70,21 @@ module ActiveRecord
       def sql_query(sql)
         dbslay_results = cmd_execute(:db, 'SQL' =&gt; sql)
                 
-        case dbslay_results
-        when Hash
-          # check for an error
-          if dbslay_results['MYSQL_ERROR']
-            raise DbslayerException, &quot;MySQL Error #{dbslay_results['MYSQL_ERRNO']}: #{dbslay_results['MYSQL_ERROR']}&quot;
-          else
-            DbslayerResult.new(dbslay_results['RESULT'])
+        # 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']
+          case result
+          when Hash
+            DbslayerResult.new(result)
+          when Array
+            result.map {|r| DbslayerResult.new(r) }
+          else  
+            raise DbslayerException, &quot;Unknown format for SQL results from DBSlayer&quot;
           end
-        when Array
-          dbslay_results.map { |r| DbslayerResult.new(r['RESULT']) }
+        elsif dbslay_results['SUCCESS']
+          return dbslay_results['SUCCESS']
         else  
           raise DbslayerException, &quot;Unknown format for SQL results from DBSlayer&quot;
         end
@@ -106,14 +111,14 @@ module ActiveRecord
 
       def client_version_num
         if @client_version.nil?
-          @client_version = cmd_execute(:db, 'CLIENT_VERSION' =&gt; true)[&quot;CLIENT_VERSION&quot;]
+          @client_version = Integer(cmd_execute(:db, 'CLIENT_VERSION' =&gt; true)[&quot;CLIENT_VERSION&quot;])
         end
         @client_version
       end
 
       def server_version_num
         if @server_version.nil?
-          @server_version = cmd_execute(:db, 'SERVER_VERSION' =&gt; true)[&quot;SERVER_VERSION&quot;]
+          @server_version = Integer(cmd_execute(:db, 'SERVER_VERSION' =&gt; true)[&quot;SERVER_VERSION&quot;])
         end
         @server_version
       end</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.0'
+      VERSION = '0.2.5'
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/activerecord-dbslayer-adapter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,6 +10,10 @@ require 'active_record/connection_adapters/dbslayer_adapter'
 
 STAT_REPLY = {&quot;STAT&quot; =&gt; &quot;STAT&quot;}
 
+CLIENT_INFO_REPLY = {&quot;CLIENT_INFO&quot; =&gt; &quot;5.2.27&quot;}
+
+VERSION_NUM_REPLY = {&quot;SERVER_VERSION&quot; =&gt; &quot;50037&quot;, &quot;CLIENT_VERSION&quot; =&gt; &quot;50037&quot;}
+
 # Let's mock out the DBSlayer reply
 CITY_ROWS = [[123, &quot;Mumbai (Bombay)&quot; , &quot;India&quot; , 10500000] ,
             [4112, &quot;Seoul&quot; , &quot;South Korea&quot; , 9981619] ,
@@ -23,7 +27,7 @@ CITY_ROWS = [[123, &quot;Mumbai (Bombay)&quot; , &quot;India&quot; , 10500000] ,
             [1, &quot;New York&quot; , &quot;United States&quot; , 8008278]
            ].freeze
 
-CITY_TYPES = [&quot;MYSQL_TYPE_STRING&quot;, &quot;MYSQL_TYPE_STRING&quot; , &quot;MYSQL_TYPE_LONG&quot;].freeze
+CITY_TYPES = [&quot;MYSQL_TYPE_INTEGER&quot;, &quot;MYSQL_TYPE_STRING&quot;, &quot;MYSQL_TYPE_STRING&quot; , &quot;MYSQL_TYPE_LONG&quot;].freeze
 
 CITY_HEADER = [&quot;id&quot;, &quot;city_name&quot; , &quot;country_name&quot; , &quot;population&quot;].freeze
    
@@ -34,6 +38,27 @@ CITY_RESULTS = {
               }
 }.freeze
 
+COUNTRY_ROWS = [[1, 'United States'], [2, 'Canada'], [3, 'India']].freeze
+
+COUNTRY_TYPES = [&quot;MYSQL_TYPE_INTEGER&quot;, &quot;MYSQL_TYPE_STRING&quot;]
+
+COUNTRY_HEADER = [&quot;id&quot;, &quot;name&quot;]
+
+MULTIPLE_RESULTS = {
+  &quot;RESULT&quot; =&gt; [{&quot;TYPES&quot; =&gt;  CITY_TYPES, 
+              &quot;HEADER&quot; =&gt;  CITY_HEADER, 
+              &quot;ROWS&quot; =&gt; CITY_ROWS
+              },
+              
+              {&quot;TYPES&quot; =&gt;  COUNTRY_TYPES, 
+               &quot;HEADER&quot; =&gt;  COUNTRY_HEADER, 
+               &quot;ROWS&quot; =&gt; COUNTRY_ROWS
+              }
+    
+              ]
+}.freeze
+
+NULL_RESULT = {&quot;SUCCESS&quot; =&gt; true}
 
 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>@@ -2,18 +2,28 @@ require File.dirname(__FILE__) + '/helper.rb'
 
 class TestDbslayerConnection &lt; Test::Unit::TestCase
 
-  STAT_REPLY = {
-    &quot;STAT&quot; =&gt; &quot;THIS IS A STAT REPLY&quot;
-  }.freeze
-  
-  CLIENT_INFO_REPLY = {
-    &quot;CLIENT_INFO&quot; =&gt; &quot;5.2.27&quot;
-  }.freeze
-  
   def setup
     @slayer = ActiveRecord::ConnectionAdapters::DbslayerConnection.new
   end
   
+  def test_query_string
+    query = {&quot;foo&quot; =&gt; &quot;bar&quot;}
+    assert_equal URI.encode(query.to_json), @slayer.send('query_string', query)
+  end
+  
+  # def cmd_execute(endpoint, commands)
+  # 147         url = &quot;http://#{host}:#{port}/#{endpoint.to_s}?#{query_string(commands)}&quot;
+  # 148         open(url) do |file|
+  # 149           JSON.parse(file.read)
+  # 150         end
+  
+  # def test_cmd_execute_url
+  #   query = {&quot;SQL&quot; =&gt; &quot;select * from cities&quot;}
+  #   test = ActiveRecord::ConnectionAdapters::DbslayerConnection.new('localhost', 9090)
+  #   URI.expects(:open).with(&quot;http://localhost:9090/db?#{test.send(:query_string, query)}&quot;)
+  #   test.send :cmd_execute, :db, query 
+  # end
+  
   def test_sql_query
     sql_command = &quot;select * from cities limit 10&quot;
     @slayer.stubs(:cmd_execute).with(:db, {&quot;SQL&quot; =&gt; sql_command}).returns(CITY_RESULTS)
@@ -24,6 +34,26 @@ 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)
+    
+    reply = @slayer.sql_query(sql_command)
+    assert_kind_of Array, reply
+    assert_equal 2, reply.size
+    reply.each {|i| assert_kind_of(ActiveRecord::ConnectionAdapters::DbslayerResult, i)}
+    assert_equal CITY_ROWS, reply[0].rows
+    assert_equal COUNTRY_ROWS, reply[1].rows
+  end
+  
   def test_stat
     @slayer.stubs(:cmd_execute).with(:db, {&quot;STAT&quot; =&gt; true}).returns(STAT_REPLY)
     reply = @slayer.mysql_stats
@@ -40,6 +70,21 @@ class TestDbslayerConnection &lt; Test::Unit::TestCase
   
   def test_server_error
     @slayer.stubs(:cmd_execute).returns(ERROR_REPLY)
-    assert_raise(DbslayerException) { @slayer.sql_query(&quot;SELECT * FROM items&quot;) }
+    assert_raise(ActiveRecord::ConnectionAdapters::DbslayerException) { @slayer.sql_query(&quot;SELECT * FROM items&quot;) }
   end
+  
+  def test_client_num
+    @slayer.stubs(:cmd_execute).with(:db, {&quot;CLIENT_VERSION&quot; =&gt; true}).returns(VERSION_NUM_REPLY)
+    reply = @slayer.client_version_num
+  
+    assert_equal 50037, reply
+  end
+  
+  def test_server_num
+    @slayer.stubs(:cmd_execute).with(:db, {&quot;SERVER_VERSION&quot; =&gt; true}).returns(VERSION_NUM_REPLY)
+    reply = @slayer.server_version_num
+  
+    assert_equal 50037, reply
+  end   
+  
 end</diff>
      <filename>test/test_dbslayer_connection.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0ad288887d167265431c0cbbdce8257bd403af88</id>
    </parent>
  </parents>
  <author>
    <name>harrisj</name>
    <email>harrisj@ae54da50-7589-804d-96e1-6ee4b2538e53</email>
  </author>
  <url>http://github.com/harrisj/activerecord-dbslayer-adapter/commit/102cec42ea8bbe59742e0525f67b3ee1489c4bbf</url>
  <id>102cec42ea8bbe59742e0525f67b3ee1489c4bbf</id>
  <committed-date>2008-05-08T11:16:27-07:00</committed-date>
  <authored-date>2008-05-08T11:16:27-07:00</authored-date>
  <message>Fixed for work for multiples, null results


git-svn-id: svn://newsprojects.nytimes.com/newsdev/gems/activerecord-dbslayer-adapter@4455 ae54da50-7589-804d-96e1-6ee4b2538e53</message>
  <tree>d9bffc96ceb1f9985615c38f98b67fd7b77235db</tree>
  <committer>
    <name>harrisj</name>
    <email>harrisj@ae54da50-7589-804d-96e1-6ee4b2538e53</email>
  </committer>
</commit>
