aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2014-01-29 21:17:10 -0500
committerArthur Neves <arthurnn@gmail.com>2014-01-30 14:06:40 -0500
commitb7fcad8ff04411a8d00f85094b172b6b99402190 (patch)
treeee2715f365812a464057bb64faa0dca3c587bbb2 /activerecord/lib/active_record/connection_adapters/postgresql
parentdb5d6bf74f3f6423e56120198685b8665e59616e (diff)
downloadrails-b7fcad8ff04411a8d00f85094b172b6b99402190.tar.gz
rails-b7fcad8ff04411a8d00f85094b172b6b99402190.tar.bz2
rails-b7fcad8ff04411a8d00f85094b172b6b99402190.zip
Fix regression on `.select_*` methods.
This was a common pattern: ``` query = author.posts.select(:title) connection.select_one(query) ``` However `.select` returns a ActiveRecord::AssociationRelation, which has the bind information, so we can use that to get the right sql query. Also fix select_rows on postgress and sqlite3 that were not using the binds [fixes #7538] [fixes #12017] [related #13731] [related #12056]
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
index f349c37724..51ee2829b2 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
@@ -46,8 +46,8 @@ module ActiveRecord
# Executes a SELECT query and returns an array of rows. Each row is an
# array of field values.
- def select_rows(sql, name = nil)
- select_raw(sql, name).last
+ def select_rows(sql, name = nil, binds = [])
+ exec_query(sql, name, binds).rows
end
# Executes an INSERT query and returns the new record's ID