Skip to content
Browse files

Merge branch 'master' of git@github.com:rails/rails

  • Loading branch information...
2 parents 983dc80 + d20955f commit 1767c4b2da21379862a9ab1a4316d8da6b820a2a @jeremy jeremy committed Nov 7, 2008
View
1 actionpack/lib/action_controller/dispatcher.rb
@@ -23,7 +23,6 @@ def define_dispatcher_callbacks(cache_classes)
if defined?(ActiveRecord)
after_dispatch :checkin_connections
- before_dispatch { ActiveRecord::Base.verify_active_connections! }
to_prepare(:activerecord_instantiate_observers) { ActiveRecord::Base.instantiate_observers }
end
View
4 actionpack/lib/action_view/helpers/text_helper.rb
@@ -559,7 +559,7 @@ def set_cycle(name, cycle_object)
(?:\.[-\w]+)* # remaining subdomains or domain
(?::\d+)? # port
(?:/(?:[~\w\+@%=\(\)-]|(?:[,.;:'][^\s$]))*)* # path
- (?:\?[\w\+@%&=.;-]+)? # query string
+ (?:\?[\w\+@%&=.;:-]+)? # query string
(?:\#[\w\-]*)? # trailing anchor
)
([[:punct:]]|<|$|) # trailing text
@@ -598,4 +598,4 @@ def auto_link_email_addresses(text)
end
end
end
-end
+end
View
1 actionpack/test/template/text_helper_test.rb
@@ -221,6 +221,7 @@ def test_auto_link_parsing
http://www.amazon.com/Testing-Equal-Sign-In-Path/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1198861734&sr=8-1
http://en.wikipedia.org/wiki/Sprite_(computer_graphics)
http://en.wikipedia.org/wiki/Texas_hold'em
+ https://www.google.com/doku.php?id=gps:resource:scs:start
)
urls.each do |url|
View
2 activerecord/CHANGELOG
@@ -1,7 +1,5 @@
*2.2.1 [RC2 or 2.2 final]*
-* Stop logging SHOW FIELDS and SET SQL_AUTO_IS_NULL=0 for the MysqlAdapter as they only clutter up the log and offer no value [DHH]
-
* Ensure indices don't flip order in schema.rb #1266 [Jordi Bunster]
* Fixed that serialized strings should never be type-casted (i.e. turning "Yes" to a boolean) #857 [Andreas Korth]
View
2 activerecord/lib/active_record/associations.rb
@@ -1609,7 +1609,7 @@ def create_belongs_to_reflection(association_id, options)
:class_name, :table_name, :join_table, :foreign_key, :association_foreign_key,
:select, :conditions, :include, :order, :group, :limit, :offset,
:uniq,
- :finder_sql, :delete_sql, :insert_sql,
+ :finder_sql, :counter_sql, :delete_sql, :insert_sql,
:before_add, :after_add, :before_remove, :after_remove,
:extend, :readonly,
:validate
View
5 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -292,10 +292,7 @@ def establish_connection(name, spec)
# and also returns connections to the pool cached by threads that are no
# longer alive.
def clear_active_connections!
- @connection_pools.each_value do |pool|
- pool.release_connection
- pool.clear_stale_cached_connections!
- end
+ @connection_pools.each_value {|pool| pool.release_connection }
end
# Clears the cache which maps classes
View
3 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -125,9 +125,8 @@ def reset!
end
# Returns true if its safe to reload the connection between requests for development mode.
- # This is not the case for Ruby/MySQL and it's not necessary for any adapters except SQLite.
def requires_reloading?
- false
+ true
end
# Checks whether the connection to the database is still active (i.e. not stale).
View
12 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -305,12 +305,8 @@ def select_rows(sql, name = nil)
rows
end
- def execute(sql, name = nil, skip_logging = false) #:nodoc:
- if skip_logging
- @connection.query(sql)
- else
- log(sql, name) { @connection.query(sql) }
- end
+ def execute(sql, name = nil) #:nodoc:
+ log(sql, name) { @connection.query(sql) }
rescue ActiveRecord::StatementInvalid => exception
if exception.message.split(":").first =~ /Packets out of order/
raise ActiveRecord::StatementInvalid, "'Packets out of order' error was received from the database. Please update your mysql bindings (gem install mysql) and read http://dev.mysql.com/doc/mysql/en/password-hashing.html for more information. If you're on Windows, use the Instant Rails installer to get the updated mysql bindings."
@@ -441,7 +437,7 @@ def indexes(table_name, name = nil)#:nodoc:
def columns(table_name, name = nil)#:nodoc:
sql = "SHOW FIELDS FROM #{quote_table_name(table_name)}"
columns = []
- execute(sql, name, true).each { |field| columns << MysqlColumn.new(field[0], field[4], field[1], field[2] == "YES") }
+ execute(sql, name).each { |field| columns << MysqlColumn.new(field[0], field[4], field[1], field[2] == "YES") }
columns
end
@@ -559,7 +555,7 @@ def configure_connection
# By default, MySQL 'where id is null' selects the last inserted id.
# Turn this off. http://dev.rubyonrails.org/ticket/6778
- execute("SET SQL_AUTO_IS_NULL=0", "ID NULL OFF", true)
+ execute("SET SQL_AUTO_IS_NULL=0")
end
def select(sql, name = nil)
View
23 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -68,6 +68,16 @@ class DeveloperWithSymbolsForKeys < ActiveRecord::Base
:foreign_key => "developer_id"
end
+class DeveloperWithCounterSQL < ActiveRecord::Base
+ set_table_name 'developers'
+ has_and_belongs_to_many :projects,
+ :class_name => "DeveloperWithCounterSQL",
+ :join_table => "developers_projects",
+ :association_foreign_key => "project_id",
+ :foreign_key => "developer_id",
+ :counter_sql => 'SELECT COUNT(*) AS count_all FROM projects INNER JOIN developers_projects ON projects.id = developers_projects.project_id WHERE developers_projects.developer_id =#{id}'
+end
+
class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
fixtures :accounts, :companies, :categories, :posts, :categories_posts, :developers, :projects, :developers_projects,
:parrots, :pirates, :treasures, :price_estimates, :tags, :taggings
@@ -739,6 +749,19 @@ def test_counting_on_habtm_association_and_not_array
assert_nothing_raised { david.projects.count(:all, :conditions => '1=1') }
end
+ def test_count
+ david = Developer.find(1)
+ assert_equal 2, david.projects.count
+ end
+
+ def test_count_with_counter_sql
+ developer = DeveloperWithCounterSQL.create(:name => 'tekin')
+ developer.project_ids = [projects(:active_record).id]
+ developer.save
+ developer.reload
+ assert_equal 1, developer.projects.count
+ end
+
uses_mocha 'mocking Post.transaction' do
def test_association_proxy_transaction_method_starts_transaction_in_association_class
Post.expects(:transaction)

0 comments on commit 1767c4b

Please sign in to comment.
Something went wrong with that request. Please try again.