提交 e20a790b 编写于 作者: J Jon Leighton

Merge pull request #4976 from kreynolds/fix_eager_without_pkey

Fix eagerly loading associations without primary keys
......@@ -54,7 +54,7 @@ def column_names_with_alias
unless @column_names_with_alias
@column_names_with_alias = []
([primary_key] + (column_names - [primary_key])).each_with_index do |column_name, i|
([primary_key] + (column_names - [primary_key])).compact.each_with_index do |column_name, i|
@column_names_with_alias << [column_name, "#{aliased_prefix}_r#{i}"]
end
end
......
require "cases/helper"
require 'models/edge'
class JoinDependencyTest < ActiveRecord::TestCase
def test_column_names_with_alias_handles_nil_primary_key
assert_equal Edge.column_names, ActiveRecord::Associations::JoinDependency::JoinBase.new(Edge).column_names_with_alias.map(&:first)
end
end
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册