Respect new records for
Therefore, reverting the alias in
This method exists since the initial commit.
If we expects
Currently if `CollectionProxy` has more than one new record, `CollectionProxy#uniq` result is incorrect. And `CollectionProxy#uniq` was aliased to `distinct` in a1bb6c8. But the `uniq` method and the `SELECT DISTINCT` method are different methods. The doc in `CollectionProxy` is for the `SELECT DISTINCT` method, not for the `uniq` method. Therefore, reverting the alias in `CollectionProxy` to fix the inconsistency and to have the both methods.
It would be useful to backport this to 5.0.x. Here's my failing test and the
# Note that "good" and "bad" are reversed, because `git bisect` is only built to work in one direction. # I use the trick shown here: http://stackoverflow.com/a/36157747/2651774 to get around that. # git bisect start # git bisect bad master # git bisect good 5-0-stable^ # git bisect skip # git bisect run bash -c "! ruby test.rb" # fixed commit: 0ec967aa6655d62c92f72acb8d556a5b3f70762d begin require "bundler/inline" rescue LoadError => e $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" raise e end gemfile(true) do source "https://rubygems.org" gem "rails", path: "." gem "sqlite3" end require "active_record" require "minitest/autorun" require "logger" # This connection will do for database-independent bug reports. ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") ActiveRecord::Base.logger = Logger.new(STDOUT) ActiveRecord::Schema.define do create_table :posts, force: true do |t| end create_table :comments, force: true do |t| t.integer :post_id t.string :comment end end class Post < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :post end class BugTest < Minitest::Test def test_association_stuff post = Post.create! post.comments << Comment.create!(comment: 'test') post.comments << Comment.create!(comment: 'test') assert_equal ['test', 'test'], Post.last.comments.pluck(:comment) assert_equal ['test'], Post.last.comments.distinct.pluck(:comment) end end