From b7fcad8ff04411a8d00f85094b172b6b99402190 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Wed, 29 Jan 2014 21:17:10 -0500 Subject: 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] --- .../connection_adapters/postgresql/database_statements.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb') 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 -- cgit v1.2.3