You are viewing a plain text version of this content. The canonical link for it is here.
Posted to alois-commits@incubator.apache.org by fl...@apache.org on 2011/02/02 11:53:18 UTC

svn commit: r1066431 - in /incubator/alois/trunk: etc/default/alois-environment.rb rails/lib/activerecord_reset_column_patch.rb

Author: flavio
Date: Wed Feb  2 11:53:17 2011
New Revision: 1066431

URL: http://svn.apache.org/viewvc?rev=1066431&view=rev
Log:
Fixed problem, that reset_column did not work if special column names exist.

Added:
    incubator/alois/trunk/rails/lib/activerecord_reset_column_patch.rb
Modified:
    incubator/alois/trunk/etc/default/alois-environment.rb

Modified: incubator/alois/trunk/etc/default/alois-environment.rb
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/etc/default/alois-environment.rb?rev=1066431&r1=1066430&r2=1066431&view=diff
==============================================================================
--- incubator/alois/trunk/etc/default/alois-environment.rb (original)
+++ incubator/alois/trunk/etc/default/alois-environment.rb Wed Feb  2 11:53:17 2011
@@ -11,6 +11,7 @@ require 'pathname'
 require 'alois/date_time_enhance'
 require 'mysql_adapter_extensions'
 require 'dummy_class_extension'
+require "activerecord_reset_column_patch"
 begin
   require 'will_paginate'
 rescue LoadError

Added: incubator/alois/trunk/rails/lib/activerecord_reset_column_patch.rb
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/lib/activerecord_reset_column_patch.rb?rev=1066431&view=auto
==============================================================================
--- incubator/alois/trunk/rails/lib/activerecord_reset_column_patch.rb (added)
+++ incubator/alois/trunk/rails/lib/activerecord_reset_column_patch.rb Wed Feb  2 11:53:17 2011
@@ -0,0 +1,32 @@
+# Copyright 2010 The Apache Software Foundation.
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# overwrite reset_column_information, would fail for column count(*)
+
+module ActiveRecord
+  class Base
+    def self.reset_column_information
+      
+      generated_methods.each { |name| 
+        begin
+          undef_method(name)
+        rescue
+          $log.warn("Undef method #{name} failed: #{$!}")
+        end
+      }
+      @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @generated_methods = @inheritance_column = nil
+      
+    end
+  end
+end