Skip to content

Instantly share code, notes, and snippets.

@febeling
Created September 21, 2018 12:36
Show Gist options
  • Save febeling/06e1da8ad34d5a9c45d41420efbe58bc to your computer and use it in GitHub Desktop.
Save febeling/06e1da8ad34d5a9c45d41420efbe58bc to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
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"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
# gem "activerecord", "5.2.1"
gem "activerecord", :path => './rails/activerecord'
gem "activesupport", :path => './rails/activesupport'
gem "activemodel", :path => './rails/activemodel'
gem "sqlite3"
end
require "active_record"
require "minitest/autorun"
require "logger"
# Ensure backward compatibility with minitest 4.
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# 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 :orders, force: true do |t|
end
create_table :items, force: true do |t|
end
create_table :item_orders, force: true do |t|
t.integer :item_id
t.integer :order_id
end
end
class Order < ActiveRecord::Base
has_many :item_orders
has_many :items, through: :item_orders
end
class Item < ActiveRecord::Base
has_many :item_orders
has_many :orders, through: :item_orders
end
class ItemOrder < ActiveRecord::Base
belongs_to :item
belongs_to :order
end
class HasManyThroughJoinModelAndDuplicateBugTest < Minitest::Test
attr_reader :item, :order
def teardown
Item.destroy_all
end
def setup
@item = Item.create!
@order = Order.create!
end
# Objects
def test_append_collection # ok
order.items << item
order.items << item
assert_equal 2, order.items.count
end
def test_replace_collection # ok
order.items.replace([item, item])
assert_equal 2, order.items.count
end
def test_assign_collection # ok
order.items = [item, item]
assert_equal 2, order.items.count
end
def test_replace_collection_preexisting # failing
order.items.replace([item])
order.items.replace([item, item])
assert_equal 2, order.items.count
end
def test_assign_collection_preexisting # failing
order.items = [item]
order.items = [item, item]
assert_equal 2, order.items.count
end
# IDs
def test_ids_writer_assignment_with_duplicates # ok
order.item_ids = [item.id, item.id]
assert_equal 2, order.items.count
end
def test_ids_writer_with_preexisting # failing
order.item_ids = [item.id]
order.item_ids = [item.id, item.id]
assert_equal 2, order.items.count
end
# Available workaround
def test_ids_writer_workaround
order.item_ids = [item.id]
order.item_ids.clear
order.item_ids = [item.id, item.id]
assert_equal 2, order.items.count
end
end
@febeling
Copy link
Author

Output with ruby ruby 2.4.3p205 (2017-12-14 revision 61247)

$ ruby active_record_gem.rb                                                                                           [14:32:29]
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Using concurrent-ruby 1.0.5
Using i18n 1.1.0
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 6.0.0.alpha from source at `./rails/activesupport`
Using activemodel 6.0.0.alpha from source at `./rails/activemodel`
Using activerecord 6.0.0.alpha from source at `./rails/activerecord`
Using bundler 1.16.4
Using sqlite3 1.3.13
-- create_table(:orders, {:force=>true})
D, [2018-09-21T14:33:06.652740 #12954] DEBUG -- :    (1.1ms)  SELECT sqlite_version(*)
D, [2018-09-21T14:33:06.653487 #12954] DEBUG -- :    (0.2ms)  DROP TABLE IF EXISTS "orders"
D, [2018-09-21T14:33:06.653924 #12954] DEBUG -- :    (0.3ms)  CREATE TABLE "orders" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)
   -> 0.0047s
-- create_table(:items, {:force=>true})
D, [2018-09-21T14:33:06.654215 #12954] DEBUG -- :    (0.0ms)  DROP TABLE IF EXISTS "items"
D, [2018-09-21T14:33:06.654419 #12954] DEBUG -- :    (0.1ms)  CREATE TABLE "items" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)
   -> 0.0004s
-- create_table(:item_orders, {:force=>true})
D, [2018-09-21T14:33:06.654679 #12954] DEBUG -- :    (0.0ms)  DROP TABLE IF EXISTS "item_orders"
D, [2018-09-21T14:33:06.654910 #12954] DEBUG -- :    (0.1ms)  CREATE TABLE "item_orders" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "item_id" integer, "order_id" integer)
   -> 0.0004s
D, [2018-09-21T14:33:06.680902 #12954] DEBUG -- :    (0.2ms)  CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
D, [2018-09-21T14:33:06.692184 #12954] DEBUG -- :   ActiveRecord::InternalMetadata Load (0.1ms)  SELECT  "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?  [["key", "environment"], ["LIMIT", 1]]
D, [2018-09-21T14:33:06.698585 #12954] DEBUG -- :    (0.1ms)  begin transaction
D, [2018-09-21T14:33:06.698969 #12954] DEBUG -- :   ActiveRecord::InternalMetadata Create (0.1ms)  INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)  [["key", "environment"], ["value", "default_env"], ["created_at", "2018-09-21 12:33:06.697874"], ["updated_at", "2018-09-21 12:33:06.697874"]]
D, [2018-09-21T14:33:06.699163 #12954] DEBUG -- :    (0.0ms)  commit transaction
Run options: --seed 53495

# Running:

D, [2018-09-21T14:33:06.715612 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.715764 #12954] DEBUG -- :   Item Create (0.1ms)  INSERT INTO "items" DEFAULT VALUES
D, [2018-09-21T14:33:06.715983 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.717968 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.718108 #12954] DEBUG -- :   Order Create (0.1ms)  INSERT INTO "orders" DEFAULT VALUES
D, [2018-09-21T14:33:06.718397 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.724459 #12954] DEBUG -- :   Item Load (0.1ms)  SELECT "items".* FROM "items" WHERE "items"."id" = ?  [["id", 1]]
D, [2018-09-21T14:33:06.730401 #12954] DEBUG -- :   Item Load (0.1ms)  SELECT "items".* FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 1]]
D, [2018-09-21T14:33:06.731025 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.735938 #12954] DEBUG -- :   ItemOrder Create (0.1ms)  INSERT INTO "item_orders" ("item_id", "order_id") VALUES (?, ?)  [["item_id", 1], ["order_id", 1]]
D, [2018-09-21T14:33:06.736156 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.736719 #12954] DEBUG -- :   Item Load (0.1ms)  SELECT "items".* FROM "items" WHERE "items"."id" IN (?, ?)  [["id", 1], ["id", 1]]
D, [2018-09-21T14:33:06.737588 #12954] DEBUG -- :    (0.1ms)  SELECT COUNT(*) FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 1]]
D, [2018-09-21T14:33:06.737861 #12954] DEBUG -- :   Item Load (0.1ms)  SELECT "items".* FROM "items"
D, [2018-09-21T14:33:06.738173 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.738320 #12954] DEBUG -- :   Item Destroy (0.1ms)  DELETE FROM "items" WHERE "items"."id" = ?  [["id", 1]]
D, [2018-09-21T14:33:06.738468 #12954] DEBUG -- :    (0.0ms)  commit transaction
FD, [2018-09-21T14:33:06.738930 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.739047 #12954] DEBUG -- :   Item Create (0.1ms)  INSERT INTO "items" DEFAULT VALUES
D, [2018-09-21T14:33:06.739214 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.739588 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.739749 #12954] DEBUG -- :   Order Create (0.1ms)  INSERT INTO "orders" DEFAULT VALUES
D, [2018-09-21T14:33:06.739942 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.740620 #12954] DEBUG -- :   Item Load (0.1ms)  SELECT "items".* FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 2]]
D, [2018-09-21T14:33:06.741538 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.741694 #12954] DEBUG -- :   ItemOrder Create (0.1ms)  INSERT INTO "item_orders" ("item_id", "order_id") VALUES (?, ?)  [["item_id", 2], ["order_id", 2]]
D, [2018-09-21T14:33:06.742511 #12954] DEBUG -- :   ItemOrder Create (0.1ms)  INSERT INTO "item_orders" ("item_id", "order_id") VALUES (?, ?)  [["item_id", 2], ["order_id", 2]]
D, [2018-09-21T14:33:06.742675 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.743207 #12954] DEBUG -- :    (0.1ms)  SELECT COUNT(*) FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 2]]
D, [2018-09-21T14:33:06.743435 #12954] DEBUG -- :   Item Load (0.0ms)  SELECT "items".* FROM "items"
D, [2018-09-21T14:33:06.743726 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.743904 #12954] DEBUG -- :   Item Destroy (0.1ms)  DELETE FROM "items" WHERE "items"."id" = ?  [["id", 2]]
D, [2018-09-21T14:33:06.744035 #12954] DEBUG -- :    (0.0ms)  commit transaction
.D, [2018-09-21T14:33:06.744465 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.744582 #12954] DEBUG -- :   Item Create (0.0ms)  INSERT INTO "items" DEFAULT VALUES
D, [2018-09-21T14:33:06.744741 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.745094 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.745288 #12954] DEBUG -- :   Order Create (0.1ms)  INSERT INTO "orders" DEFAULT VALUES
D, [2018-09-21T14:33:06.745506 #12954] DEBUG -- :    (0.1ms)  commit transaction
D, [2018-09-21T14:33:06.745871 #12954] DEBUG -- :   Item Load (0.0ms)  SELECT "items".* FROM "items" WHERE "items"."id" = ?  [["id", 3]]
D, [2018-09-21T14:33:06.746358 #12954] DEBUG -- :   Item Load (0.0ms)  SELECT "items".* FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 3]]
D, [2018-09-21T14:33:06.747217 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.747412 #12954] DEBUG -- :   ItemOrder Create (0.1ms)  INSERT INTO "item_orders" ("item_id", "order_id") VALUES (?, ?)  [["item_id", 3], ["order_id", 3]]
D, [2018-09-21T14:33:06.747626 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.748047 #12954] DEBUG -- :   Item Load (0.1ms)  SELECT "items".* FROM "items" WHERE "items"."id" IN (?, ?)  [["id", 3], ["id", 3]]
D, [2018-09-21T14:33:06.748683 #12954] DEBUG -- :    (0.1ms)  SELECT COUNT(*) FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 3]]
D, [2018-09-21T14:33:06.749006 #12954] DEBUG -- :   Item Load (0.0ms)  SELECT "items".* FROM "items"
D, [2018-09-21T14:33:06.749431 #12954] DEBUG -- :    (0.1ms)  begin transaction
D, [2018-09-21T14:33:06.749581 #12954] DEBUG -- :   Item Destroy (0.1ms)  DELETE FROM "items" WHERE "items"."id" = ?  [["id", 3]]
D, [2018-09-21T14:33:06.749709 #12954] DEBUG -- :    (0.0ms)  commit transaction
FD, [2018-09-21T14:33:06.750224 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.750349 #12954] DEBUG -- :   Item Create (0.1ms)  INSERT INTO "items" DEFAULT VALUES
D, [2018-09-21T14:33:06.750547 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.750940 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.751061 #12954] DEBUG -- :   Order Create (0.1ms)  INSERT INTO "orders" DEFAULT VALUES
D, [2018-09-21T14:33:06.751221 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.751694 #12954] DEBUG -- :   Item Load (0.1ms)  SELECT "items".* FROM "items" WHERE "items"."id" IN (?, ?)  [["id", 4], ["id", 4]]
D, [2018-09-21T14:33:06.752259 #12954] DEBUG -- :   Item Load (0.1ms)  SELECT "items".* FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 4]]
D, [2018-09-21T14:33:06.753319 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.753511 #12954] DEBUG -- :   ItemOrder Create (0.1ms)  INSERT INTO "item_orders" ("item_id", "order_id") VALUES (?, ?)  [["item_id", 4], ["order_id", 4]]
D, [2018-09-21T14:33:06.754476 #12954] DEBUG -- :   ItemOrder Create (0.1ms)  INSERT INTO "item_orders" ("item_id", "order_id") VALUES (?, ?)  [["item_id", 4], ["order_id", 4]]
D, [2018-09-21T14:33:06.754665 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.755275 #12954] DEBUG -- :    (0.1ms)  SELECT COUNT(*) FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 4]]
D, [2018-09-21T14:33:06.755495 #12954] DEBUG -- :   Item Load (0.0ms)  SELECT "items".* FROM "items"
D, [2018-09-21T14:33:06.755782 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.755948 #12954] DEBUG -- :   Item Destroy (0.1ms)  DELETE FROM "items" WHERE "items"."id" = ?  [["id", 4]]
D, [2018-09-21T14:33:06.756085 #12954] DEBUG -- :    (0.0ms)  commit transaction
.D, [2018-09-21T14:33:06.756521 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.756648 #12954] DEBUG -- :   Item Create (0.1ms)  INSERT INTO "items" DEFAULT VALUES
D, [2018-09-21T14:33:06.756841 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.757275 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.757404 #12954] DEBUG -- :   Order Create (0.1ms)  INSERT INTO "orders" DEFAULT VALUES
D, [2018-09-21T14:33:06.757595 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.758108 #12954] DEBUG -- :   Item Load (0.1ms)  SELECT "items".* FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 5]]
D, [2018-09-21T14:33:06.758945 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.759115 #12954] DEBUG -- :   ItemOrder Create (0.1ms)  INSERT INTO "item_orders" ("item_id", "order_id") VALUES (?, ?)  [["item_id", 5], ["order_id", 5]]
D, [2018-09-21T14:33:06.759281 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.759878 #12954] DEBUG -- :    (0.1ms)  SELECT COUNT(*) FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 5]]
D, [2018-09-21T14:33:06.760104 #12954] DEBUG -- :   Item Load (0.0ms)  SELECT "items".* FROM "items"
D, [2018-09-21T14:33:06.760364 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.760503 #12954] DEBUG -- :   Item Destroy (0.1ms)  DELETE FROM "items" WHERE "items"."id" = ?  [["id", 5]]
D, [2018-09-21T14:33:06.760640 #12954] DEBUG -- :    (0.1ms)  commit transaction
FD, [2018-09-21T14:33:06.761071 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.761203 #12954] DEBUG -- :   Item Create (0.1ms)  INSERT INTO "items" DEFAULT VALUES
D, [2018-09-21T14:33:06.761394 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.761733 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.761860 #12954] DEBUG -- :   Order Create (0.1ms)  INSERT INTO "orders" DEFAULT VALUES
D, [2018-09-21T14:33:06.762025 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.762967 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.763131 #12954] DEBUG -- :   ItemOrder Create (0.1ms)  INSERT INTO "item_orders" ("item_id", "order_id") VALUES (?, ?)  [["item_id", 6], ["order_id", 6]]
D, [2018-09-21T14:33:06.763317 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.763951 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.764113 #12954] DEBUG -- :   ItemOrder Create (0.1ms)  INSERT INTO "item_orders" ("item_id", "order_id") VALUES (?, ?)  [["item_id", 6], ["order_id", 6]]
D, [2018-09-21T14:33:06.764268 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.764724 #12954] DEBUG -- :    (0.1ms)  SELECT COUNT(*) FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 6]]
D, [2018-09-21T14:33:06.764919 #12954] DEBUG -- :   Item Load (0.0ms)  SELECT "items".* FROM "items"
D, [2018-09-21T14:33:06.765177 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.765352 #12954] DEBUG -- :   Item Destroy (0.1ms)  DELETE FROM "items" WHERE "items"."id" = ?  [["id", 6]]
D, [2018-09-21T14:33:06.765530 #12954] DEBUG -- :    (0.1ms)  commit transaction
.D, [2018-09-21T14:33:06.765921 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.766057 #12954] DEBUG -- :   Item Create (0.0ms)  INSERT INTO "items" DEFAULT VALUES
D, [2018-09-21T14:33:06.766223 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.766596 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.766830 #12954] DEBUG -- :   Order Create (0.1ms)  INSERT INTO "orders" DEFAULT VALUES
D, [2018-09-21T14:33:06.767047 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.767690 #12954] DEBUG -- :   Item Load (0.1ms)  SELECT "items".* FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 7]]
D, [2018-09-21T14:33:06.769084 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.769377 #12954] DEBUG -- :   ItemOrder Create (0.1ms)  INSERT INTO "item_orders" ("item_id", "order_id") VALUES (?, ?)  [["item_id", 7], ["order_id", 7]]
D, [2018-09-21T14:33:06.770513 #12954] DEBUG -- :   ItemOrder Create (0.1ms)  INSERT INTO "item_orders" ("item_id", "order_id") VALUES (?, ?)  [["item_id", 7], ["order_id", 7]]
D, [2018-09-21T14:33:06.770695 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.771262 #12954] DEBUG -- :    (0.1ms)  SELECT COUNT(*) FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 7]]
D, [2018-09-21T14:33:06.771460 #12954] DEBUG -- :   Item Load (0.0ms)  SELECT "items".* FROM "items"
D, [2018-09-21T14:33:06.771729 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.771879 #12954] DEBUG -- :   Item Destroy (0.1ms)  DELETE FROM "items" WHERE "items"."id" = ?  [["id", 7]]
D, [2018-09-21T14:33:06.772032 #12954] DEBUG -- :    (0.0ms)  commit transaction
.D, [2018-09-21T14:33:06.772480 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.772606 #12954] DEBUG -- :   Item Create (0.1ms)  INSERT INTO "items" DEFAULT VALUES
D, [2018-09-21T14:33:06.772793 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.773114 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.773240 #12954] DEBUG -- :   Order Create (0.1ms)  INSERT INTO "orders" DEFAULT VALUES
D, [2018-09-21T14:33:06.773404 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.773942 #12954] DEBUG -- :   Item Load (0.1ms)  SELECT "items".* FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 8]]
D, [2018-09-21T14:33:06.774848 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.775016 #12954] DEBUG -- :   ItemOrder Create (0.1ms)  INSERT INTO "item_orders" ("item_id", "order_id") VALUES (?, ?)  [["item_id", 8], ["order_id", 8]]
D, [2018-09-21T14:33:06.775180 #12954] DEBUG -- :    (0.0ms)  commit transaction
D, [2018-09-21T14:33:06.775732 #12954] DEBUG -- :    (0.1ms)  SELECT COUNT(*) FROM "items" INNER JOIN "item_orders" ON "items"."id" = "item_orders"."item_id" WHERE "item_orders"."order_id" = ?  [["order_id", 8]]
D, [2018-09-21T14:33:06.775954 #12954] DEBUG -- :   Item Load (0.0ms)  SELECT "items".* FROM "items"
D, [2018-09-21T14:33:06.776208 #12954] DEBUG -- :    (0.0ms)  begin transaction
D, [2018-09-21T14:33:06.776354 #12954] DEBUG -- :   Item Destroy (0.1ms)  DELETE FROM "items" WHERE "items"."id" = ?  [["id", 8]]
D, [2018-09-21T14:33:06.776483 #12954] DEBUG -- :    (0.0ms)  commit transaction
F

Finished in 0.063715s, 125.5591 runs/s, 125.5591 assertions/s.

  1) Failure:
HasManyThroughJoinModelAndDuplicateBugTest#test_ids_writer_with_preexisting [active_record_gem.rb:123]:
Expected: 2
  Actual: 1

  2) Failure:
HasManyThroughJoinModelAndDuplicateBugTest#test_ids_writer_workaround [active_record_gem.rb:133]:
Expected: 2
  Actual: 1

  3) Failure:
HasManyThroughJoinModelAndDuplicateBugTest#test_replace_collection_preexisting [active_record_gem.rb:101]:
Expected: 2
  Actual: 1

  4) Failure:
HasManyThroughJoinModelAndDuplicateBugTest#test_assign_collection_preexisting [active_record_gem.rb:108]:
Expected: 2
  Actual: 1

8 runs, 8 assertions, 4 failures, 0 errors, 0 skips

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment