From 045ca303947e7e9209cee4b3fdede05f6dbb02c4 Mon Sep 17 00:00:00 2001 From: mjy Date: Thu, 3 Mar 2011 13:28:26 -0500 Subject: fixes a missmatched column in example --- activerecord/lib/active_record/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index b3204b2bda..4db08c774b 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -463,7 +463,7 @@ module ActiveRecord #:nodoc: # # # 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 = []) connection.select_all(sanitize_sql(sql), "#{name} Load", binds).collect! { |record| instantiate(record) } end -- cgit v1.2.3 From 74818a35432b40fef16fe74f248ea75d35405324 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sat, 5 Mar 2011 11:56:24 -0800 Subject: use Arel::Table#alias rather than passing the :as parameter --- activerecord/lib/active_record/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 4db08c774b..a5e1c91f47 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -636,7 +636,7 @@ module ActiveRecord #:nodoc: @quoted_table_name = nil define_attr_method :table_name, value, &block - @arel_table = Arel::Table.new(table_name, :engine => arel_engine) + @arel_table = Arel::Table.new(table_name, arel_engine) @relation = Relation.new(self, arel_table) end alias :table_name= :set_table_name @@ -1321,7 +1321,7 @@ MSG def sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name) attrs = expand_hash_conditions_for_aggregates(attrs) - table = Arel::Table.new(self.table_name, :engine => arel_engine, :as => default_table_name) + table = Arel::Table.new(table_name).alias(default_table_name) viz = Arel::Visitors.for(arel_engine) PredicateBuilder.build_from_hash(arel_engine, attrs, table).map { |b| viz.accept b -- cgit v1.2.3