Permalink
Browse files

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

  • Loading branch information...
1 parent 8c600e4 commit 5e47ba0a8510caf1b9a2691871126c869675a34f @kennyj kennyj committed Aug 21, 2012
View
9 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -298,13 +298,6 @@ def last_inserted_id(result)
@connection.insert_id
end
- class Result < ActiveRecord::Result
- def initialize(columns, rows, column_types)
- super(columns, rows)
- @column_types = column_types
- end
- end
-
module Fields
class Type
def type; end
@@ -437,7 +430,7 @@ def exec_without_stmt(sql, name = 'SQL') # :nodoc:
}
end
}
- result_set = Result.new(types.keys, result.to_a, types)
+ result_set = ActiveRecord::Result.new(types.keys, result.to_a, types)
result.free
else
result_set = ActiveRecord::Result.new([], [])
View
9 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -803,13 +803,6 @@ def substitute_at(column, index)
Arel::Nodes::BindParam.new "$#{index + 1}"
end
- class Result < ActiveRecord::Result
- def initialize(columns, rows, column_types)
- super(columns, rows)
- @column_types = column_types
- end
- end
-
def exec_query(sql, name = 'SQL', binds = [])
log(sql, name, binds) do
result = binds.empty? ? exec_no_cache(sql, binds) :
@@ -825,7 +818,7 @@ def exec_query(sql, name = 'SQL', binds = [])
}
end
- ret = Result.new(result.fields, result.values, types)
+ ret = ActiveRecord::Result.new(result.fields, result.values, types)
result.clear
return ret
end
View
4 activerecord/lib/active_record/result.rb
@@ -10,11 +10,11 @@ class Result
attr_reader :columns, :rows, :column_types
- def initialize(columns, rows)
+ def initialize(columns, rows, column_types = {})
@columns = columns
@rows = rows
@hash_rows = nil
- @column_types = {}
+ @column_types = column_types
end
def each

0 comments on commit 5e47ba0

Please sign in to comment.