Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
- index 07c5545..dc3353b 100755
- --- a/activerecord/lib/active_record/base.rb
- +++ b/activerecord/lib/active_record/base.rb
- @@ -1506,7 +1506,7 @@ module ActiveRecord #:nodoc:
- end
- def arel_table(table = nil)
- - Relation.new(self, Arel::Table.new(table || table_name))
- + Relation.new(self, Arel::Table.new(table || table_name, Arel::Sql::Engine.new(self)))
- end
- private
- diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
- index ae03e1d..5336a1a 100644
- --- a/activerecord/lib/active_record/relation.rb
- +++ b/activerecord/lib/active_record/relation.rb
- @@ -132,6 +132,16 @@ module ActiveRecord
- relation
- end
- + def table
- + return @table if @table
- +
- + if @relation.kind_of?(Arel::Table)
- + @table = @relation
- + else
- + @table = @relation.table
- + end
- + end
- +
- protected
- def method_missing(method, *args, &block)
- diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
- index 7a1d6fc..99391b5 100644
- --- a/activerecord/lib/active_record/relation/finder_methods.rb
- +++ b/activerecord/lib/active_record/relation/finder_methods.rb
- @@ -78,7 +78,7 @@ module ActiveRecord
- end
- def find_one(id)
- - record = where(@klass.primary_key => id).first
- + record = where(table[@klass.primary_key].eq(id)).first
- unless record
- conditions = where_clause(', ')
Add Comment
Please, Sign In to add comment