From a1ffc4a31b38830ce72e9e2502db3c4b6b83d3f0 Mon Sep 17 00:00:00 2001 From: Carlos Duclos Date: Sat, 1 Dec 2012 12:52:45 -0500 Subject: remove unneeded Examples tag [ci skip] --- activerecord/lib/active_record/relation/spawn_methods.rb | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb index 352dee3826..d417e82548 100644 --- a/activerecord/lib/active_record/relation/spawn_methods.rb +++ b/activerecord/lib/active_record/relation/spawn_methods.rb @@ -12,9 +12,6 @@ module ActiveRecord # Merges in the conditions from other, if other is an ActiveRecord::Relation. # Returns an array representing the intersection of the resulting records with other, if other is an array. - # - # ==== Examples - # # Post.where(published: true).joins(:comments).merge( Comment.where(spam: false) ) # # Performs a single join query with both where conditions. # @@ -29,7 +26,6 @@ module ActiveRecord # # => Post.where(published: true).joins(:comments) # # This is mainly intended for sharing common conditions between multiple associations. - # def merge(other) if other.is_a?(Array) to_a & other @@ -51,11 +47,8 @@ module ActiveRecord # Removes from the query the condition(s) specified in +skips+. # - # Example: - # # Post.order('id asc').except(:order) # discards the order condition # Post.where('id > 10').order('id asc').except(:where) # discards the where condition but keeps the order - # def except(*skips) result = Relation.new(klass, table, values.except(*skips)) result.default_scoped = default_scoped @@ -65,11 +58,8 @@ module ActiveRecord # Removes any condition from the query other than the one(s) specified in +onlies+. # - # Example: - # # Post.order('id asc').only(:where) # discards the order condition # Post.order('id asc').only(:where, :order) # uses the specified order - # def only(*onlies) result = Relation.new(klass, table, values.slice(*onlies)) result.default_scoped = default_scoped -- cgit v1.2.3 From 5ff59704f68d284381606a1b76e4ffcfd73b2cfa Mon Sep 17 00:00:00 2001 From: Florent Guilleux Date: Sat, 1 Dec 2012 13:16:18 -0500 Subject: Add documentation to TransactionIsolationError [ci skip] --- activerecord/lib/active_record/errors.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb index c615d59725..52643828e4 100644 --- a/activerecord/lib/active_record/errors.rb +++ b/activerecord/lib/active_record/errors.rb @@ -207,6 +207,8 @@ module ActiveRecord class ImmutableRelation < ActiveRecordError end + # Raised in database transaction blocks in situations described + # in the DatabaseStatements#transaction documentation class TransactionIsolationError < ActiveRecordError end end -- cgit v1.2.3 From 90c887fa7d0c454b7533e208daefc342dea4d5f3 Mon Sep 17 00:00:00 2001 From: Florent Guilleux Date: Sat, 1 Dec 2012 13:20:39 -0500 Subject: Remove trailing whitespaces --- activerecord/lib/active_record/log_subscriber.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/log_subscriber.rb b/activerecord/lib/active_record/log_subscriber.rb index ca79950049..2b30c31219 100644 --- a/activerecord/lib/active_record/log_subscriber.rb +++ b/activerecord/lib/active_record/log_subscriber.rb @@ -1,7 +1,7 @@ module ActiveRecord class LogSubscriber < ActiveSupport::LogSubscriber IGNORE_PAYLOAD_NAMES = ["SCHEMA", "EXPLAIN"] - + def self.runtime=(value) Thread.current[:active_record_sql_runtime] = value end -- cgit v1.2.3 From 8dc4041a9b2fb0e8bc2bcb72ab93adb8722e62cd Mon Sep 17 00:00:00 2001 From: Florent Guilleux Date: Sat, 1 Dec 2012 13:22:49 -0500 Subject: Revert "Remove trailing whitespaces" This reverts commit 90c887fa7d0c454b7533e208daefc342dea4d5f3. --- activerecord/lib/active_record/log_subscriber.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/log_subscriber.rb b/activerecord/lib/active_record/log_subscriber.rb index 2b30c31219..ca79950049 100644 --- a/activerecord/lib/active_record/log_subscriber.rb +++ b/activerecord/lib/active_record/log_subscriber.rb @@ -1,7 +1,7 @@ module ActiveRecord class LogSubscriber < ActiveSupport::LogSubscriber IGNORE_PAYLOAD_NAMES = ["SCHEMA", "EXPLAIN"] - + def self.runtime=(value) Thread.current[:active_record_sql_runtime] = value end -- cgit v1.2.3 From 9bc16d0da2f699a7f67f243af4ff5b6b5d993c4a Mon Sep 17 00:00:00 2001 From: Carlos Duclos Date: Sat, 1 Dec 2012 14:49:45 -0500 Subject: update AR::Schema docs [ci skip] --- activerecord/lib/active_record/schema.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/schema.rb b/activerecord/lib/active_record/schema.rb index eaa4aa7086..3259dbbd80 100644 --- a/activerecord/lib/active_record/schema.rb +++ b/activerecord/lib/active_record/schema.rb @@ -29,11 +29,16 @@ module ActiveRecord # ActiveRecord::Schema is only supported by database adapters that also # support migrations, the two features being very similar. class Schema < Migration + + # Returns the migrations paths. + # + # ActiveRecord::Schema.new.migrations_paths + # # => ["db/migrate"] # Rails migration path by default. def migrations_paths ActiveRecord::Migrator.migrations_paths end - def define(info, &block) + def define(info, &block) # :nodoc: instance_eval(&block) unless info[:version].blank? -- cgit v1.2.3 From 4940d6d096a581d46addecd9b41bbd62af3e1888 Mon Sep 17 00:00:00 2001 From: Alvaro Pereyra Date: Sat, 1 Dec 2012 15:19:34 -0500 Subject: Cleans and removes useless 'Examples' tag [ci skip] --- activerecord/lib/active_record/relation/calculations.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 99e77e007a..ccc14dddeb 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -76,18 +76,17 @@ module ActiveRecord # # values = Person.group('last_name').maximum(:age) # puts values["Drake"] - # => 43 + # # => 43 # # drake = Family.find_by_last_name('Drake') # values = Person.group(:family).maximum(:age) # Person belongs_to :family # puts values[drake] - # => 43 + # # => 43 # # values.each do |family, max_age| # ... # end # - # Examples: # Person.calculate(:count, :all) # The same as Person.count # Person.average(:age) # SELECT AVG(age) FROM people... # @@ -124,8 +123,6 @@ module ActiveRecord # the plucked column names, if they can be deduced. Plucking an SQL fragment # returns String values by default. # - # Examples: - # # Person.pluck(:id) # # SELECT people.id FROM people # # => [1, 2, 3] @@ -182,8 +179,6 @@ module ActiveRecord # Pluck all the ID's for the relation using the table's primary key # - # Examples: - # # Person.ids # SELECT people.id FROM people # Person.joins(:companies).ids # SELECT people.id FROM people INNER JOIN companies ON companies.person_id = people.id def ids -- cgit v1.2.3 From b1e2d7b96842f5b8b2a8fe911a6d31626c01effc Mon Sep 17 00:00:00 2001 From: Alvaro Pereyra Date: Sat, 1 Dec 2012 15:35:04 -0500 Subject: Cleans and removes 'Examples' tag [ci skip] --- activerecord/lib/active_record/autosave_association.rb | 2 -- activerecord/lib/active_record/integration.rb | 2 -- activerecord/lib/active_record/query_cache.rb | 2 ++ activerecord/lib/active_record/querying.rb | 7 ++----- 4 files changed, 4 insertions(+), 9 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index 907fe70522..704998301c 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -32,8 +32,6 @@ module ActiveRecord # autosave callbacks are executed. Placing your callbacks after # associations is usually a good practice. # - # == Examples - # # === One-to-one Example # # class Post diff --git a/activerecord/lib/active_record/integration.rb b/activerecord/lib/active_record/integration.rb index 23c272ef12..7bdc1bd4c6 100644 --- a/activerecord/lib/active_record/integration.rb +++ b/activerecord/lib/active_record/integration.rb @@ -29,8 +29,6 @@ module ActiveRecord # Returns a cache key that can be used to identify this record. # - # ==== Examples - # # Product.new.cache_key # => "products/new" # Product.find(5).cache_key # => "products/5" (updated_at not available) # Person.find(5).cache_key # => "people/5-20071224150000" (updated_at available) diff --git a/activerecord/lib/active_record/query_cache.rb b/activerecord/lib/active_record/query_cache.rb index 38e18b32a4..2cf75bcfc4 100644 --- a/activerecord/lib/active_record/query_cache.rb +++ b/activerecord/lib/active_record/query_cache.rb @@ -4,6 +4,7 @@ module ActiveRecord class QueryCache module ClassMethods # Enable the query cache within the block if Active Record is configured. + # If it's not, it willl execute the given block. def cache(&block) if ActiveRecord::Base.connected? connection.cache(&block) @@ -13,6 +14,7 @@ module ActiveRecord end # Disable the query cache within the block if Active Record is configured. + # If it's not, it willl execute the given block. def uncached(&block) if ActiveRecord::Base.connected? connection.uncached(&block) diff --git a/activerecord/lib/active_record/querying.rb b/activerecord/lib/active_record/querying.rb index 45f6a78428..5ddcaee6be 100644 --- a/activerecord/lib/active_record/querying.rb +++ b/activerecord/lib/active_record/querying.rb @@ -26,14 +26,13 @@ module ActiveRecord # MySQL specific terms will lock you to using that particular database engine or require you to # change your call if you switch engines. # - # ==== Examples # # A simple SQL query spanning multiple tables # Post.find_by_sql "SELECT p.title, c.author FROM posts p, comments c WHERE p.id = c.post_id" - # > [#"Ruby Meetup", "first_name"=>"Quentin"}>, ...] + # # => [#"Ruby Meetup", "first_name"=>"Quentin"}>, ...] # # # You can use the same string replacement techniques as you can with ActiveRecord#find # Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date] - # > [#"The Cheap Man Buys Twice"}>, ...] + # # => [#"The Cheap Man Buys Twice"}>, ...] def find_by_sql(sql, binds = []) logging_query_plan do result_set = connection.select_all(sanitize_sql(sql), "#{name} Load", binds) @@ -57,8 +56,6 @@ module ActiveRecord # # * +sql+ - An SQL statement which should return a count query from the database, see the example below. # - # ==== Examples - # # Product.count_by_sql "SELECT COUNT(*) FROM sales s, customers c WHERE s.customer_id = c.id" def count_by_sql(sql) logging_query_plan do -- cgit v1.2.3 From 43405a75bd0ba7ec2a0add751ccd0a179e3129de Mon Sep 17 00:00:00 2001 From: Matthew Robertson Date: Sun, 2 Dec 2012 19:00:12 -0800 Subject: increment_counter and decrement_counter can accept and array of ids as an arg --- activerecord/lib/active_record/counter_cache.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb index c53b7b3e78..4c5326ead6 100644 --- a/activerecord/lib/active_record/counter_cache.rb +++ b/activerecord/lib/active_record/counter_cache.rb @@ -88,7 +88,7 @@ module ActiveRecord # ==== Parameters # # * +counter_name+ - The name of the field that should be incremented. - # * +id+ - The id of the object that should be incremented. + # * +id+ - The id of the object that should be incremented or an Array of ids. # # ==== Examples # @@ -105,7 +105,7 @@ module ActiveRecord # ==== Parameters # # * +counter_name+ - The name of the field that should be decremented. - # * +id+ - The id of the object that should be decremented. + # * +id+ - The id of the object that should be decremented or an Array of ids. # # ==== Examples # -- cgit v1.2.3 From 0a178000f5394c08e32346f42b05b17451ce4e42 Mon Sep 17 00:00:00 2001 From: Matthew Robertson Date: Sun, 2 Dec 2012 19:35:35 -0800 Subject: grammar improvements for increment_counter and decrement_counter docs --- activerecord/lib/active_record/counter_cache.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb index 4c5326ead6..81f92db271 100644 --- a/activerecord/lib/active_record/counter_cache.rb +++ b/activerecord/lib/active_record/counter_cache.rb @@ -79,11 +79,12 @@ module ActiveRecord where(primary_key => id).update_all updates.join(', ') end - # Increment a number field by one, usually representing a count. + # Increment a numeric field by one, via a direct SQL update. # - # This is used for caching aggregate values, so that they don't need to be computed every time. - # For example, a DiscussionBoard may cache post_count and comment_count otherwise every time the board is - # shown it would have to run an SQL query to find how many posts and comments there are. + # This method is used primarily for maintaining counter_cache columns used to + # store aggregate values. For example, a DiscussionBoard may cache posts_count + # and comments_count to avoid running an SQL query to calculate the number of + # posts and comments there are each time it is displayed. # # ==== Parameters # @@ -98,9 +99,10 @@ module ActiveRecord update_counters(id, counter_name => 1) end - # Decrement a number field by one, usually representing a count. + # Decrement a numeric field by one, via a direct SQL update. # - # This works the same as increment_counter but reduces the column value by 1 instead of increasing it. + # This works the same as increment_counter but reduces the column value by + # 1 instead of increasing it. # # ==== Parameters # -- cgit v1.2.3 From b0662108231f6d6a22e2be9ab2555706e481f327 Mon Sep 17 00:00:00 2001 From: Hendy Tanata Date: Mon, 3 Dec 2012 12:37:45 +0800 Subject: Fix typo. --- activerecord/lib/active_record/query_cache.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/query_cache.rb b/activerecord/lib/active_record/query_cache.rb index 2cf75bcfc4..df8654e5c1 100644 --- a/activerecord/lib/active_record/query_cache.rb +++ b/activerecord/lib/active_record/query_cache.rb @@ -4,7 +4,7 @@ module ActiveRecord class QueryCache module ClassMethods # Enable the query cache within the block if Active Record is configured. - # If it's not, it willl execute the given block. + # If it's not, it will execute the given block. def cache(&block) if ActiveRecord::Base.connected? connection.cache(&block) @@ -14,7 +14,7 @@ module ActiveRecord end # Disable the query cache within the block if Active Record is configured. - # If it's not, it willl execute the given block. + # If it's not, it will execute the given block. def uncached(&block) if ActiveRecord::Base.connected? connection.uncached(&block) -- cgit v1.2.3 From b5de0ac6b0f12e5e61e944467cb509a0196dcd95 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Tue, 4 Dec 2012 21:56:21 +0530 Subject: Revert "Add documentation to TransactionIsolationError [ci skip]" This reverts commit 5ff59704f68d284381606a1b76e4ffcfd73b2cfa. Reason: Seems dubious and adds less value. [ci skip] --- activerecord/lib/active_record/errors.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb index 52643828e4..c615d59725 100644 --- a/activerecord/lib/active_record/errors.rb +++ b/activerecord/lib/active_record/errors.rb @@ -207,8 +207,6 @@ module ActiveRecord class ImmutableRelation < ActiveRecordError end - # Raised in database transaction blocks in situations described - # in the DatabaseStatements#transaction documentation class TransactionIsolationError < ActiveRecordError end end -- cgit v1.2.3