Skip to content
This repository
Browse code

Refactor AR::Result or inherits. Because we have redundant codes about

  • Loading branch information...
commit 5e47ba0a8510caf1b9a2691871126c869675a34f 1 parent 8c600e4
Toshinori Kajihara kennyj authored
9 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -298,13 +298,6 @@ def last_inserted_id(result)
298 298 @connection.insert_id
299 299 end
300 300
301   - class Result < ActiveRecord::Result
302   - def initialize(columns, rows, column_types)
303   - super(columns, rows)
304   - @column_types = column_types
305   - end
306   - end
307   -
308 301 module Fields
309 302 class Type
310 303 def type; end
@@ -437,7 +430,7 @@ def exec_without_stmt(sql, name = 'SQL') # :nodoc:
437 430 }
438 431 end
439 432 }
440   - result_set = Result.new(types.keys, result.to_a, types)
  433 + result_set = ActiveRecord::Result.new(types.keys, result.to_a, types)
441 434 result.free
442 435 else
443 436 result_set = ActiveRecord::Result.new([], [])
9 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -803,13 +803,6 @@ def substitute_at(column, index)
803 803 Arel::Nodes::BindParam.new "$#{index + 1}"
804 804 end
805 805
806   - class Result < ActiveRecord::Result
807   - def initialize(columns, rows, column_types)
808   - super(columns, rows)
809   - @column_types = column_types
810   - end
811   - end
812   -
813 806 def exec_query(sql, name = 'SQL', binds = [])
814 807 log(sql, name, binds) do
815 808 result = binds.empty? ? exec_no_cache(sql, binds) :
@@ -825,7 +818,7 @@ def exec_query(sql, name = 'SQL', binds = [])
825 818 }
826 819 end
827 820
828   - ret = Result.new(result.fields, result.values, types)
  821 + ret = ActiveRecord::Result.new(result.fields, result.values, types)
829 822 result.clear
830 823 return ret
831 824 end
4 activerecord/lib/active_record/result.rb
@@ -10,11 +10,11 @@ class Result
10 10
11 11 attr_reader :columns, :rows, :column_types
12 12
13   - def initialize(columns, rows)
  13 + def initialize(columns, rows, column_types = {})
14 14 @columns = columns
15 15 @rows = rows
16 16 @hash_rows = nil
17   - @column_types = {}
  17 + @column_types = column_types
18 18 end
19 19
20 20 def each

0 comments on commit 5e47ba0

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