Permalink
Browse files

Merge pull request #11579 from kennyj/refactor_20130724

Simplify select_one method.
  • Loading branch information...
2 parents 82a76df + 098c9c8 commit 758b2c37776cb0871c65c44061e96076dc5f4dfa @rafaelfranca rafaelfranca committed Jul 24, 2013
Showing with 9 additions and 10 deletions.
  1. +9 −10 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
@@ -26,8 +26,7 @@ def select_all(arel, name = nil, binds = [])
# Returns a record hash with the column names as keys and column values
# as values.
def select_one(arel, name = nil, binds = [])
- result = select_all(arel, name, binds)
- result.first if result
+ select_all(arel, name, binds).first
end
# Returns a single value from a record
@@ -375,14 +374,14 @@ def delete_sql(sql, name = nil)
update_sql(sql, name)
end
- def sql_for_insert(sql, pk, id_value, sequence_name, binds)
- [sql, binds]
- end
-
- def last_inserted_id(result)
- row = result.rows.first
- row && row.first
- end
+ def sql_for_insert(sql, pk, id_value, sequence_name, binds)
+ [sql, binds]
+ end
+
+ def last_inserted_id(result)
+ row = result.rows.first
+ row && row.first
+ end
end
end
end

0 comments on commit 758b2c3

Please sign in to comment.