1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix that #pluck wasn't rescuing ThrowResult, meaning it would blow up when failing to construct_limited_ids_condition.

This commit is contained in:
Ben Woosley 2013-05-10 19:24:56 +02:00
parent 1f11dbf0b4
commit 2fcafee250
2 changed files with 8 additions and 0 deletions

View file

@ -189,6 +189,8 @@ module ActiveRecord
end
columns.one? ? result.map!(&:first) : result
end
rescue ThrowResult
[]
end
# Pluck all the ID's for the relation using the table's primary key

View file

@ -6,6 +6,7 @@ require 'models/edge'
require 'models/organization'
require 'models/possession'
require 'models/topic'
require 'models/reply'
require 'models/minivan'
require 'models/speedometer'
require 'models/ship_part'
@ -539,6 +540,11 @@ class CalculationsTest < ActiveRecord::TestCase
assert_equal Company.all.map(&:id).sort, Company.ids.sort
end
def test_pluck_with_includes_limit_and_empty_result
assert_equal [], Topic.includes(:replies).limit(0).pluck(:id)
assert_equal [], Topic.includes(:replies).limit(1).where('0 = 1').pluck(:id)
end
def test_pluck_not_auto_table_name_prefix_if_column_included
Company.create!(:name => "test", :contracts => [Contract.new(:developer_id => 7)])
ids = Company.includes(:contracts).pluck(:developer_id)