Skip to content

Instantly share code, notes, and snippets.

@btoews
Last active May 5, 2023 14:22
Show Gist options
  • Save btoews/e7832364bff787c9aa68424af19c6374 to your computer and use it in GitHub Desktop.
Save btoews/e7832364bff787c9aa68424af19c6374 to your computer and use it in GitHub Desktop.
AR bug repro
# frozen_string_literal: true
require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '=6.1.5.1'
gem 'sqlite3'
end
require 'active_record'
require 'minitest/autorun'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define { create_table(:foos, force: true) }
Foo = Class.new(ActiveRecord::Base)
class BugTest < Minitest::Test
def test_association_stuff
5.times { Foo.create }
assert_equal [3], Foo.where(id: [1,2,3]).merge(Foo.where(id: [3,4,5])).pluck(:id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment