1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib
claudiob ec981aa1f0 Remove duplicate 'select' database statement
The `select` method has the same definition in almost all database
adapters, so it can be moved from the database-specific adapters
(PostgreSQl, MySQL, SQLite) to the abstract `database_statement`:

```ruby
def select(sql, name = nil, binds = [])
  exec_query(sql, name, binds)
end
```

---

More details about this commit: the only two DB-specific adapters
that have a different definition of `select` are MySQLAdapter and
MySQL2Adapter.

In MySQLAdapter, `select` invokes `exec_query(sql, name, binds)`, so
calling `super` achieves the same goal with less repetition.

In MySQL2Adapter, `select` invokes `exec_query(sql, name)`, that is,
it does not pass the `binds` parameter like other methods do. However,
[MySQL2Adapter's `exec_query`](74a527cc63/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb (L228L231))
works exactly the same whether this parameters is passed or not, so the output
does not change:

```ruby
def exec_query(sql, name = 'SQL', binds = [])
  result = execute(sql, name)
  ActiveRecord::Result.new(result.fields, result.to_a)
end
```
2014-10-20 11:05:11 -07:00
..
active_record Remove duplicate 'select' database statement 2014-10-20 11:05:11 -07:00
rails/generators Merge pull request #16062 from sgrif/sg-required-generators 2014-08-17 22:57:21 -03:00
active_record.rb Revert "Revert "Merge pull request #16059 from jenncoop/json-serialized-attr"" 2014-07-15 08:43:18 -07:00