<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -40,47 +40,56 @@ class ActiveSchemaTest &lt; ActiveRecord::TestCase
   end
 
   def test_add_timestamps 
-    #we need to actually modify some data, so we make execute to point to the original method
-    ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do      
-      alias_method :execute_with_stub, :execute
-      alias_method :execute, :execute_without_stub
-    end  
-    ActiveRecord::Base.connection.create_table :delete_me do |t|        
-    end
-    ActiveRecord::Base.connection.add_timestamps :delete_me
-    assert_equal ActiveRecord::Base.connection.execute(&quot;SHOW FIELDS FROM delete_me where FIELD='updated_at' AND TYPE='datetime'&quot;).num_rows, 1
-    assert_equal ActiveRecord::Base.connection.execute(&quot;SHOW FIELDS FROM delete_me where FIELD='created_at' AND TYPE='datetime'&quot;).num_rows, 1
-  ensure    
-    ActiveRecord::Base.connection.drop_table :delete_me rescue nil  
-    #before finishing, we restore the alias to the mock-up method
-    ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do      
-      alias_method :execute, :execute_with_stub
+    with_real_execute do
+      begin
+        ActiveRecord::Base.connection.create_table :delete_me do |t|
+        end
+        ActiveRecord::Base.connection.add_timestamps :delete_me
+        assert column_present?('delete_me', 'updated_at', 'datetime')
+        assert column_present?('delete_me', 'created_at', 'datetime')
+      ensure
+        ActiveRecord::Base.connection.drop_table :delete_me rescue nil
+      end
     end
   end
   
   def test_remove_timestamps 
-    #we need to actually modify some data, so we make execute to point to the original method
-    ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do      
-      alias_method :execute_with_stub, :execute
-      alias_method :execute, :execute_without_stub
-    end  
-    ActiveRecord::Base.connection.create_table :delete_me do |t|        
-      t.timestamps
-    end
-    ActiveRecord::Base.connection.remove_timestamps :delete_me
-    assert_equal ActiveRecord::Base.connection.execute(&quot;SHOW FIELDS FROM delete_me where FIELD='updated_at' AND TYPE='datetime'&quot;).num_rows, 0
-    assert_equal ActiveRecord::Base.connection.execute(&quot;SHOW FIELDS FROM delete_me where FIELD='created_at' AND TYPE='datetime'&quot;).num_rows, 0
-  ensure    
-    ActiveRecord::Base.connection.drop_table :delete_me rescue nil  
-    #before finishing, we restore the alias to the mock-up method
-    ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do      
-      alias_method :execute, :execute_with_stub
+    with_real_execute do
+      begin
+        ActiveRecord::Base.connection.create_table :delete_me do |t|
+          t.timestamps
+        end
+        ActiveRecord::Base.connection.remove_timestamps :delete_me
+        assert !column_present?('delete_me', 'updated_at', 'datetime')
+        assert !column_present?('delete_me', 'created_at', 'datetime')
+      ensure
+        ActiveRecord::Base.connection.drop_table :delete_me rescue nil
+      end
     end
   end
 
-
   private
+    def with_real_execute
+      #we need to actually modify some data, so we make execute point to the original method
+      ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do
+        alias_method :execute_with_stub, :execute
+        alias_method :execute, :execute_without_stub
+      end
+      yield
+    ensure
+      #before finishing, we restore the alias to the mock-up method
+      ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do
+        alias_method :execute, :execute_with_stub
+      end
+    end
+
+
     def method_missing(method_symbol, *arguments)
       ActiveRecord::Base.connection.send(method_symbol, *arguments)
     end
+
+    def column_present?(table_name, column_name, type)
+      results = ActiveRecord::Base.connection.select_all(&quot;SHOW FIELDS FROM #{table_name} LIKE '#{column_name}'&quot;)
+      results.first &amp;&amp; results.first['Type'] == type
+    end
 end</diff>
      <filename>activerecord/test/cases/active_schema_test_mysql.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>262d23d763c05bbe5f433a99cb9f02e48a8cdd4a</id>
    </parent>
  </parents>
  <author>
    <name>Frederick Cheung</name>
    <email>frederick.cheung@gmail.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/dd9938a44ee3a7bb6c42527a1be6fcec70bf4772</url>
  <id>dd9938a44ee3a7bb6c42527a1be6fcec70bf4772</id>
  <committed-date>2008-05-21T16:02:27-07:00</committed-date>
  <authored-date>2008-05-21T13:03:38-07:00</authored-date>
  <message>Fix mysql 4.1 incompatibility in the active record schema tests.

Signed-off-by: Michael Koziarski &lt;michael@koziarski.com&gt;
[#233 state:resolved ]</message>
  <tree>edc43d66fe1088e435f90efd50f5f7166194645b</tree>
  <committer>
    <name>Michael Koziarski</name>
    <email>michael@koziarski.com</email>
  </committer>
</commit>
