aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJamison Dance <jergason@gmail.com>2010-08-26 21:20:22 -0600
committerJamison Dance <jergason@gmail.com>2010-08-26 21:20:22 -0600
commit6398eba2400af004d9db19217f9d43ea7a33d877 (patch)
treef9f0755bbf42a2a86eff5a6b4d9bb46902745bee /activerecord
parent4d8158d9e5ada4aff5dc62712b7c4730b60cde48 (diff)
parent6eed7b36a2ec6f94d9ac3f254b05697649b78881 (diff)
downloadrails-6398eba2400af004d9db19217f9d43ea7a33d877.tar.gz
rails-6398eba2400af004d9db19217f9d43ea7a33d877.tar.bz2
rails-6398eba2400af004d9db19217f9d43ea7a33d877.zip
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG6
-rw-r--r--activerecord/README.rdoc2
-rw-r--r--activerecord/lib/active_record/associations.rb2
-rw-r--r--activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb2
-rw-r--r--activerecord/lib/active_record/callbacks.rb4
-rw-r--r--activerecord/lib/active_record/observer.rb2
-rw-r--r--activerecord/lib/active_record/railties/databases.rake6
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb14
8 files changed, 20 insertions, 18 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 972c907c46..384f95d0a0 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -2039,7 +2039,7 @@ during calendar reform. #7649, #7724 [fedot, Geoff Buesing]
end
end
-* Fixed that schema changes while the database was open would break any connections to a SQLite database (now we reconnect if that error is throw) [David Heinemeier Hansson]
+* Fixed that schema changes while the database was open would break any connections to an SQLite database (now we reconnect if that error is throw) [David Heinemeier Hansson]
* Don't classify the has_one class when eager loading, it is already singular. Add tests. (closes #4117) [Jonathan Viney]
@@ -3554,7 +3554,7 @@ in effect. Added :readonly finder constraint. Calling an association collectio
end
end
-* Fixed that schema changes while the database was open would break any connections to a SQLite database (now we reconnect if that error is throw) [David Heinemeier Hansson]
+* Fixed that schema changes while the database was open would break any connections to an SQLite database (now we reconnect if that error is throw) [David Heinemeier Hansson]
* Don't classify the has_one class when eager loading, it is already singular. Add tests. (closes #4117) [Jonathan Viney]
@@ -5218,7 +5218,7 @@ in effect. Added :readonly finder constraint. Calling an association collectio
NOTE: The agreement is considered valid if it's set to the string "1". This makes it easy to relate it to an HTML checkbox.
-* Added validation macros to make the stackable just like the lifecycle callbacks. Examples:
+* Added validation macros to make the stackable just like the life cycle callbacks. Examples:
class Person < ActiveRecord::Base
validate { |record| record.errors.add("name", "too short") unless name.size > 10 }
diff --git a/activerecord/README.rdoc b/activerecord/README.rdoc
index 1a0db4691b..101a595ecd 100644
--- a/activerecord/README.rdoc
+++ b/activerecord/README.rdoc
@@ -70,7 +70,7 @@ A short rundown of some of the major features:
{Learn more}[link:classes/ActiveRecord/Validations.html]
-* Callbacks available for the entire lifecycle (instantiation, saving, destroying, validating, etc.)
+* Callbacks available for the entire life cycle (instantiation, saving, destroying, validating, etc.)
class Person < ActiveRecord::Base
before_destroy :invalidate_payment_plan
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 0f4e9568ac..f2feac0279 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -340,7 +340,7 @@ module ActiveRecord
#
# === Association callbacks
#
- # Similar to the normal callbacks that hook into the lifecycle of an Active Record object,
+ # Similar to the normal callbacks that hook into the life cycle of an Active Record object,
# you can also define callbacks that get triggered when you add an object to or remove an
# object from an association collection.
#
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
index e983f86f9e..c0ec65bd40 100644
--- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
@@ -26,7 +26,7 @@ module ActiveRecord
def construct_find_options!(options)
options[:joins] = Arel::SqlLiteral.new @join_sql
options[:readonly] = finding_with_ambiguous_select?(options[:select] || @reflection.options[:select])
- options[:select] ||= (@reflection.options[:select] || '*')
+ options[:select] ||= (@reflection.options[:select] || Arel::SqlLiteral.new('*'))
end
def count_records
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index a31973d529..fd71d7db4e 100644
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -3,7 +3,7 @@ require 'active_support/core_ext/array/wrap'
module ActiveRecord
# = Active Record Callbacks
#
- # Callbacks are hooks into the lifecycle of an Active Record object that allow you to trigger logic
+ # Callbacks are hooks into the life cycle of an Active Record object that allow you to trigger logic
# before or after an alteration of the object state. This can be used to make sure that associated and
# dependent objects are deleted when +destroy+ is called (by overwriting +before_destroy+) or to massage attributes
# before they're validated (by overwriting +before_validation+). As an example of the callbacks initiated, consider
@@ -26,7 +26,7 @@ module ActiveRecord
# <tt>after_rollback</tt>.
#
# That's a total of ten callbacks, which gives you immense power to react and prepare for each state in the
- # Active Record lifecycle. The sequence for calling <tt>Base#save</tt> for an existing record is similar,
+ # Active Record life cycle. The sequence for calling <tt>Base#save</tt> for an existing record is similar,
# except that each <tt>_on_create</tt> callback is replaced by the corresponding <tt>_on_update</tt> callback.
#
# Examples:
diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb
index 32221f65ce..022cf109af 100644
--- a/activerecord/lib/active_record/observer.rb
+++ b/activerecord/lib/active_record/observer.rb
@@ -3,7 +3,7 @@ require 'active_support/core_ext/class/attribute'
module ActiveRecord
# = Active Record Observer
#
- # Observer classes respond to lifecycle callbacks to implement trigger-like
+ # Observer classes respond to life cycle callbacks to implement trigger-like
# behavior outside the original class. This is a great way to reduce the
# clutter that normally comes when the model class is burdened with
# functionality that doesn't pertain to the core responsibility of the
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index ae605d3e7a..b46c4b59a2 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -61,12 +61,14 @@ namespace :db do
@charset = ENV['CHARSET'] || 'utf8'
@collation = ENV['COLLATION'] || 'utf8_unicode_ci'
creation_options = {:charset => (config['charset'] || @charset), :collation => (config['collation'] || @collation)}
+ error_class = config['adapter'] == 'mysql2' ? Mysql2::Error : Mysql::Error
+ access_denied_error = 1045
begin
ActiveRecord::Base.establish_connection(config.merge('database' => nil))
ActiveRecord::Base.connection.create_database(config['database'], creation_options)
ActiveRecord::Base.establish_connection(config)
- rescue Mysql::Error => sqlerr
- if sqlerr.errno == Mysql::Error::ER_ACCESS_DENIED_ERROR
+ rescue error_class => sqlerr
+ if sqlerr.errno == access_denied_error
print "#{sqlerr.error}. \nPlease provide the root password for your mysql installation\n>"
root_password = $stdin.gets.strip
grant_statement = "GRANT ALL PRIVILEGES ON #{config['database']}.* " \
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 8ccc62c9d1..bb9cdaaefe 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -96,14 +96,14 @@ module ActiveRecord
end
def reverse_order
- order_clause = arel.send(:order_clauses).join(', ')
+ order_clause = arel.order_clauses.join(', ')
relation = except(:order)
- unless order_clauses.blank?
- relation.order(reverse_sql_order(order_clause))
- else
- relation.order("#{@klass.table_name}.#{@klass.primary_key} DESC")
- end
+ order = order_clause.blank? ?
+ "#{@klass.table_name}.#{@klass.primary_key} DESC" :
+ reverse_sql_order(order_clause)
+
+ relation.order Arel::SqlLiteral.new order
end
def arel
@@ -188,7 +188,7 @@ module ActiveRecord
association_joins << join if [Hash, Array, Symbol].include?(join.class) && !array_of_strings?(join)
end
- stashed_association_joins = joins.select {|j| j.is_a?(ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation)}
+ stashed_association_joins = joins.grep(ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation)
non_association_joins = (joins - association_joins - stashed_association_joins)
custom_joins = custom_join_sql(*non_association_joins)