Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 5658

Show
Ignore:
Timestamp:
12/01/06 05:56:51 (2 years ago)
Author:
david
Message:

If only life was that simple (it didnt help)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-pre-release/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb

    r5656 r5658  
    8080      end 
    8181 
     82      # Returns true if its safe to reload the connection between requests for development mode. 
     83      # This is not the case for Ruby/MySQL and it's not necessary for any adapters except SQLite. 
     84      def supports_reloading? 
     85        false 
     86      end 
     87 
    8288      # Lazily verify this connection, calling +active?+ only if it hasn't 
    8389      # been called for +timeout+ seconds.        
  • branches/1-2-pre-release/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb

    r5656 r5658  
    8585        clear_cache!(@@active_connections) do |name, conn| 
    8686          conn.disconnect! 
     87        end 
     88      end 
     89       
     90      # Clears the cache which maps classes  
     91      def clear_reloadable_connections! 
     92        @@active_connections.each do |name, conn| 
     93          conn.disconnect! if conn.supports_reloading? 
     94          @@active_connections.delete(name) 
    8795        end 
    8896      end 
  • branches/1-2-pre-release/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb

    r5656 r5658  
    100100 
    101101      def supports_migrations? #:nodoc: 
     102        true 
     103      end 
     104 
     105      def supports_reloading? 
    102106        true 
    103107      end 
  • branches/1-2-pre-release/activerecord/lib/active_record/vendor/mysql.rb

    r5656 r5658  
    11741174  def finalizer(net) 
    11751175    proc { 
    1176       begin 
    1177         net.clear 
    1178         net.write Mysql::COM_QUIT.chr 
    1179         net.close 
    1180       rescue Error => error 
    1181         # Swallow lost connection errors if connection is already closed. 
    1182         raise unless error.errno == Error::CR_SERVER_LOST 
    1183       end 
     1176      net.clear 
     1177      net.write Mysql::COM_QUIT.chr 
    11841178    } 
    11851179  end 
  • branches/1-2-pre-release/railties/lib/dispatcher.rb

    r5656 r5658  
    6363      end 
    6464         
    65       ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord) 
     65      ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord) 
    6666    end 
    6767     
     
    7777      unless identifier.nil? 
    7878        callback = preparation_callbacks.detect { |ident, _| ident == identifier } 
     79 
    7980        if callback # Already registered: update the existing callback 
    8081          callback[-1] = block 
     
    8283        end 
    8384      end 
     85 
    8486      preparation_callbacks << [identifier, block] 
    85       nil 
     87 
     88      return 
    8689    end 
    8790 
  • trunk/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb

    r5656 r5658  
    8080      end 
    8181 
     82      # Returns true if its safe to reload the connection between requests for development mode. 
     83      # This is not the case for Ruby/MySQL and it's not necessary for any adapters except SQLite. 
     84      def supports_reloading? 
     85        false 
     86      end 
     87 
    8288      # Lazily verify this connection, calling +active?+ only if it hasn't 
    8389      # been called for +timeout+ seconds.        
  • trunk/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb

    r5656 r5658  
    8585        clear_cache!(@@active_connections) do |name, conn| 
    8686          conn.disconnect! 
     87        end 
     88      end 
     89       
     90      # Clears the cache which maps classes  
     91      def clear_reloadable_connections! 
     92        @@active_connections.each do |name, conn| 
     93          conn.disconnect! if conn.supports_reloading? 
     94          @@active_connections.delete(name) 
    8795        end 
    8896      end 
  • trunk/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb

    r5656 r5658  
    100100 
    101101      def supports_migrations? #:nodoc: 
     102        true 
     103      end 
     104 
     105      def supports_reloading? 
    102106        true 
    103107      end 
  • trunk/activerecord/lib/active_record/vendor/mysql.rb

    r5656 r5658  
    11741174  def finalizer(net) 
    11751175    proc { 
    1176       begin 
    1177         net.clear 
    1178         net.write Mysql::COM_QUIT.chr 
    1179         net.close 
    1180       rescue Error => error 
    1181         # Swallow lost connection errors if connection is already closed. 
    1182         raise unless error.errno == Error::CR_SERVER_LOST 
    1183       end 
     1176      net.clear 
     1177      net.write Mysql::COM_QUIT.chr 
    11841178    } 
    11851179  end 
  • trunk/railties/lib/dispatcher.rb

    r5656 r5658  
    6363      end 
    6464         
    65       ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord) 
     65      ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord) 
    6666    end 
    6767     
     
    7777      unless identifier.nil? 
    7878        callback = preparation_callbacks.detect { |ident, _| ident == identifier } 
     79 
    7980        if callback # Already registered: update the existing callback 
    8081          callback[-1] = block 
     
    8283        end 
    8384      end 
     85 
    8486      preparation_callbacks << [identifier, block] 
    85       nil 
     87 
     88      return 
    8689    end 
    8790