spree/spree — pull request #5720 by BenMorganIO (2014-12-05 21:19:23+00:00)
Title: include product for variant stock items update

before:
```sql
[1m[36mSpree::Product Load (0.2ms)[0m [1mSELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."id" = $1 LIMIT 1[0m [["id", 48]]
[1m[35mSQL (0.6ms)[0m UPDATE "spree_products" SET "updated_at" = '2014-12-05 20:44:35.209321' WHERE "spree_products"."id" = 48
[1m[36mSpree::Taxon Load (0.3ms)[0m [1mSELECT "spree_taxons".* FROM "spree_taxons" INNER JOIN "spree_products_taxons" ON "spree_taxons"."id" = "spree_products_taxons"."taxon_id" WHERE "spree_products_taxons"."product_id" = $1[0m [["product_id", 48]]
[1m[35mSQL (0.5ms)[0m UPDATE "spree_taxons" SET "updated_at" = '2014-12-05 20:44:35.220962' WHERE 1=0
[1m[36mSQL (1.2ms)[0m [1mUPDATE "spree_taxonomies" SET "updated_at" = '2014-12-05 20:44:35.228086' WHERE "spree_taxonomies"."id" IN (SELECT "spree_taxonomies"."id" FROM "spree_taxonomies" WHERE 1=0 ORDER BY spree_taxonomies.position)[0m
[1m[35mSpree::StockItem Exists (1.1ms)[0m SELECT 1 AS one FROM "spree_stock_items" WHERE ("spree_stock_items"."variant_id" = 1200 AND "spree_stock_items"."stock_location_id" = 2 AND "spree_stock_items"."deleted_at" IS NULL) LIMIT 1
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "spree_stock_items" ("backorderable", "created_at", "stock_location_id", "updated_at", "variant_id") VALUES ($1, $2, $3, $4, $5) RETURNING "id"[0m [["backorderable", "t"], ["created_at", "2014-12-05 20:44:35.243198"], ["stock_location_id", 2], ["updated_at", "2014-12-05 20:44:35.243198"], ["variant_id", 1200]]
[1m[35mSQL (0.6ms)[0m UPDATE "spree_variants" SET "stock_items_count" = COALESCE("stock_items_count", 0) + 1 WHERE "spree_variants"."id" = 1200
[1m[36mSQL (0.5ms)[0m [1mUPDATE "spree_variants" SET "updated_at" = '2014-12-05 20:44:35.255686' WHERE "spree_variants"."id" = 1200[0m
[1m[35mSpree::Product Load (0.2ms)[0m SELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."id" = $1 LIMIT 1 [["id", 49]]
[1m[36mSQL (0.7ms)[0m [1mUPDATE "spree_products" SET "updated_at" = '2014-12-05 20:44:35.266612' WHERE "spree_products"."id" = 49[0m
[1m[35mSpree::Taxon Load (0.3ms)[0m SELECT "spree_taxons".* FROM "spree_taxons" INNER JOIN "spree_products_taxons" ON "spree_taxons"."id" = "spree_products_taxons"."taxon_id" WHERE "spree_products_taxons"."product_id" = $1 [["product_id", 49]]
[1m[36mSQL (0.4ms)[0m [1mUPDATE "spree_taxons" SET "updated_at" = '2014-12-05 20:44:35.276972' WHERE 1=0[0m
[1m[35mSQL (0.7ms)[0m UPDATE "spree_taxonomies" SET "updated_at" = '2014-12-05 20:44:35.281617' WHERE "spree_taxonomies"."id" IN (SELECT "spree_taxonomies"."id" FROM "spree_taxonomies" WHERE 1=0 ORDER BY spree_taxonomies.position)
[1m[36mSpree::StockItem Exists (1.1ms)[0m [1mSELECT 1 AS one FROM "spree_stock_items" WHERE ("spree_stock_items"."variant_id" = 1201 AND "spree_stock_items"."stock_location_id" = 2 AND "spree_stock_items"."deleted_at" IS NULL) LIMIT 1[0m
[1m[35mSQL (0.4ms)[0m INSERT INTO "spree_stock_items" ("backorderable", "created_at", "stock_location_id", "updated_at", "variant_id") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["backorderable", "t"], ["created_at", "2014-12-05 20:44:35.295995"], ["stock_location_id", 2], ["updated_at", "2014-12-05 20:44:35.295995"], ["variant_id", 1201]]
[1m[36mSQL (1.0ms)[0m [1mUPDATE "spree_variants" SET "stock_items_count" = COALESCE("stock_items_count", 0) + 1 WHERE "spree_variants"."id" = 1201[0m
[1m[35mSQL (0.5ms)[0m UPDATE "spree_variants" SET "updated_at" = '2014-12-05 20:44:35.309236' WHERE "spree_variants"."id" = 1201
[1m[36mSpree::Product Load (0.2ms)[0m [1mSELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."id" = $1 LIMIT 1[0m [["id", 50]]
[1m[35mSQL (0.6ms)[0m UPDATE "spree_products" SET "updated_at" = '2014-12-05 20:44:35.320524' WHERE "spree_products"."id" = 50
[1m[36mSpree::Taxon Load (0.3ms)[0m [1mSELECT "spree_taxons".* FROM "spree_taxons" INNER JOIN "spree_products_taxons" ON "spree_taxons"."id" = "spree_products_taxons"."taxon_id" WHERE "spree_products_taxons"."product_id" = $1[0m [["product_id", 50]]
[1m[35mSQL (0.4ms)[0m UPDATE "spree_taxons" SET "updated_at" = '2014-12-05 20:44:35.330766' WHERE 1=0
[1m[36mSQL (0.8ms)[0m [1mUPDATE "spree_taxonomies" SET "updated_at" = '2014-12-05 20:44:35.336042' WHERE "spree_taxonomies"."id" IN (SELECT "spree_taxonomies"."id" FROM "spree_taxonomies" WHERE 1=0 ORDER BY spree_taxonomies.position)[0m
[1m[35mSpree::StockItem Exists (1.3ms)[0m SELECT 1 AS one FROM "spree_stock_items" WHERE ("spree_stock_items"."variant_id" = 1202 AND "spree_stock_items"."stock_location_id" = 2 AND "spree_stock_items"."deleted_at" IS NULL) LIMIT 1
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "spree_stock_items" ("backorderable", "created_at", "stock_location_id", "updated_at", "variant_id") VALUES ($1, $2, $3, $4, $5) RETURNING "id"[0m [["backorderable", "t"], ["created_at", "2014-12-05 20:44:35.349824"], ["stock_location_id", 2], ["updated_at", "2014-12-05 20:44:35.349824"], ["variant_id", 1202]]
[1m[35mSQL (0.6ms)[0m UPDATE "spree_variants" SET "stock_items_count" = COALESCE("stock_items_count", 0) + 1 WHERE "spree_variants"."id" = 1202
[1m[36mSQL (0.5ms)[0m [1mUPDATE "spree_variants" SET "updated_at" = '2014-12-05 20:44:35.361634' WHERE "spree_variants"."id" = 1202[0m
[1m[35mSpree::Product Load (0.2ms)[0m SELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."id" = $1 LIMIT 1 [["id", 51]]
[1m[36mSQL (0.6ms)[0m [1mUPDATE "spree_products" SET "updated_at" = '2014-12-05 20:44:35.372091' WHERE "spree_products"."id" = 51[0m
[1m[35mSpree::Taxon Load (0.3ms)[0m SELECT "spree_taxons".* FROM "spree_taxons" INNER JOIN "spree_products_taxons" ON "spree_taxons"."id" = "spree_products_taxons"."taxon_id" WHERE "spree_products_taxons"."product_id" = $1 [["product_id", 51]]
[1m[36mSQL (0.4ms)[0m [1mUPDATE "spree_taxons" SET "updated_at" = '2014-12-05 20:44:35.382433' WHERE 1=0[0m
[1m[35mSQL (0.8ms)[0m UPDATE "spree_taxonomies" SET "updated_at" = '2014-12-05 20:44:35.387449' WHERE "spree_taxonomies"."id" IN (SELECT "spree_taxonomies"."id" FROM "spree_taxonomies" WHERE 1=0 ORDER BY spree_taxonomies.position)
[1m[36mSpree::StockLocation Load (0.7ms)[0m [1mSELECT "spree_stock_locations".* FROM "spree_stock_locations" WHERE "spree_stock_locations"."default" = 't' AND ("spree_stock_locations"."id" != 2)[0m
[1m[35mSQL (0.5ms)[0m UPDATE "spree_stock_locations" SET "default" = $1, "updated_at" = $2 WHERE "spree_stock_locations"."id" = 1 [["default", "f"], ["updated_at", "2014-12-05 20:44:35.398857"]]
[1m[36m (0.7ms)[0m [1mCOMMIT[0m
Redirected to http://localhost:3000/admin/stock_locations
Completed 302 Found in 102734ms (ActiveRecord: 8174.3ms)
```

after:

```sql
13:17:22 web.1 | Spree::StockItem Exists (1.3ms) SELECT 1 AS one FROM "spree_stock_items" WHERE ("spree_stock_items"."variant_id" = 1199 AND "spree_stock_items"."stock_location_id" = 8 AND "spree_stock_items"."deleted_at" IS NULL) LIMIT 1
13:17:22 web.1 | SQL (0.4ms) INSERT INTO "spree_stock_items" ("backorderable", "created_at", "stock_location_id", "updated_at", "variant_id") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["backorderable", "t"], ["created_at", "2014-12-05 21:17:22.777241"], ["stock_location_id", 8], ["updated_at", "2014-12-05 21:17:22.777241"], ["variant_id", 1199]]
13:17:22 web.1 | SQL (0.7ms) UPDATE "spree_variants" SET "stock_items_count" = COALESCE("stock_items_count", 0) + 1 WHERE "spree_variants"."id" = 1199
13:17:22 web.1 | SQL (0.8ms) UPDATE "spree_variants" SET "updated_at" = '2014-12-05 21:17:22.791971' WHERE "spree_variants"."id" = 1199
13:17:22 web.1 | SQL (0.7ms) UPDATE "spree_products" SET "updated_at" = '2014-12-05 21:17:22.798253' WHERE "spree_products"."id" = 48
13:17:22 web.1 | SQL (0.5ms) UPDATE "spree_taxons" SET "updated_at" = '2014-12-05 21:17:22.804634' WHERE 1=0
13:17:22 web.1 | SQL (0.8ms) UPDATE "spree_taxonomies" SET "updated_at" = '2014-12-05 21:17:22.809754' WHERE "spree_taxonomies"."id" IN (SELECT "spree_taxonomies"."id" FROM "spree_taxonomies" WHERE 1=0 ORDER BY spree_taxonomies.position)
13:17:22 web.1 | Spree::StockItem Exists (1.2ms) SELECT 1 AS one FROM "spree_stock_items" WHERE ("spree_stock_items"."variant_id" = 1200 AND "spree_stock_items"."stock_location_id" = 8 AND "spree_stock_items"."deleted_at" IS NULL) LIMIT 1
13:17:22 web.1 | SQL (0.4ms) INSERT INTO "spree_stock_items" ("backorderable", "created_at", "stock_location_id", "updated_at", "variant_id") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["backorderable", "t"], ["created_at", "2014-12-05 21:17:22.824299"], ["stock_location_id", 8], ["updated_at", "2014-12-05 21:17:22.824299"], ["variant_id", 1200]]
13:17:22 web.1 | SQL (0.6ms) UPDATE "spree_variants" SET "stock_items_count" = COALESCE("stock_items_count", 0) + 1 WHERE "spree_variants"."id" = 1200
13:17:22 web.1 | SQL (0.8ms) UPDATE "spree_variants" SET "updated_at" = '2014-12-05 21:17:22.836112' WHERE "spree_variants"."id" = 1200
13:17:22 web.1 | SQL (0.7ms) UPDATE "spree_products" SET "updated_at" = '2014-12-05 21:17:22.841494' WHERE "spree_products"."id" = 49
13:17:22 web.1 | SQL (0.6ms) UPDATE "spree_taxons" SET "updated_at" = '2014-12-05 21:17:22.847621' WHERE 1=0
13:17:22 web.1 | SQL (0.8ms) UPDATE "spree_taxonomies" SET "updated_at" = '2014-12-05 21:17:22.853794' WHERE "spree_taxonomies"."id" IN (SELECT "spree_taxonomies"."id" FROM "spree_taxonomies" WHERE 1=0 ORDER BY spree_taxonomies.position)
13:17:22 web.1 | Spree::StockItem Exists (1.2ms) SELECT 1 AS one FROM "spree_stock_items" WHERE ("spree_stock_items"."variant_id" = 1201 AND "spree_stock_items"."stock_location_id" = 8 AND "spree_stock_items"."deleted_at" IS NULL) LIMIT 1
13:17:22 web.1 | SQL (0.4ms) INSERT INTO "spree_stock_items" ("backorderable", "created_at", "stock_location_id", "updated_at", "variant_id") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["backorderable", "t"], ["created_at", "2014-12-05 21:17:22.869731"], ["stock_location_id", 8], ["updated_at", "2014-12-05 21:17:22.869731"], ["variant_id", 1201]]
13:17:22 web.1 | SQL (0.9ms) UPDATE "spree_variants" SET "stock_items_count" = COALESCE("stock_items_count", 0) + 1 WHERE "spree_variants"."id" = 1201
13:17:22 web.1 | SQL (0.7ms) UPDATE "spree_variants" SET "updated_at" = '2014-12-05 21:17:22.881962' WHERE "spree_variants"."id" = 1201
13:17:22 web.1 | SQL (0.7ms) UPDATE "spree_products" SET "updated_at" = '2014-12-05 21:17:22.887452' WHERE "spree_products"."id" = 50
13:17:22 web.1 | SQL (0.8ms) UPDATE "spree_taxons" SET "updated_at" = '2014-12-05 21:17:22.893192' WHERE 1=0
13:17:22 web.1 | SQL (1.1ms) UPDATE "spree_taxonomies" SET "updated_at" = '2014-12-05 21:17:22.899012' WHERE "spree_taxonomies"."id" IN (SELECT "spree_taxonomies"."id" FROM "spree_taxonomies" WHERE 1=0 ORDER BY spree_taxonomies.position)
13:17:22 web.1 | Spree::StockItem Exists (1.3ms) SELECT 1 AS one FROM "spree_stock_items" WHERE ("spree_stock_items"."variant_id" = 1202 AND "spree_stock_items"."stock_location_id" = 8 AND "spree_stock_items"."deleted_at" IS NULL) LIMIT 1
13:17:22 web.1 | SQL (0.5ms) INSERT INTO "spree_stock_items" ("backorderable", "created_at", "stock_location_id", "updated_at", "variant_id") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["backorderable", "t"], ["created_at", "2014-12-05 21:17:22.914103"], ["stock_location_id", 8], ["updated_at", "2014-12-05 21:17:22.914103"], ["variant_id", 1202]]
13:17:22 web.1 | SQL (0.6ms) UPDATE "spree_variants" SET "stock_items_count" = COALESCE("stock_items_count", 0) + 1 WHERE "spree_variants"."id" = 1202
13:17:22 web.1 | SQL (0.7ms) UPDATE "spree_variants" SET "updated_at" = '2014-12-05 21:17:22.928322' WHERE "spree_variants"."id" = 1202
13:17:22 web.1 | SQL (0.7ms) UPDATE "spree_products" SET "updated_at" = '2014-12-05 21:17:22.933760' WHERE "spree_products"."id" = 51
13:17:22 web.1 | SQL (0.5ms) UPDATE "spree_taxons" SET "updated_at" = '2014-12-05 21:17:22.939182' WHERE 1=0
13:17:22 web.1 | SQL (1.0ms) UPDATE "spree_taxonomies" SET "updated_at" = '2014-12-05 21:17:22.944406' WHERE "spree_taxonomies"."id" IN (SELECT "spree_taxonomies"."id" FROM "spree_taxonomies" WHERE 1=0 ORDER BY spree_taxonomies.position)
13:17:22 web.1 | Spree::StockLocation Load (0.5ms) SELECT "spree_stock_locations".* FROM "spree_stock_locations" WHERE "spree_stock_locations"."default" = 't' AND ("spree_stock_locations"."id" != 8)
13:17:22 web.1 | SQL (0.4ms) UPDATE "spree_stock_locations" SET "default" = $1, "updated_at" = $2 WHERE "spree_stock_locations"."id" = 7 [["default", "f"], ["updated_at", "2014-12-05 21:17:22.956597"]]
13:17:22 web.1 | (8.9ms) COMMIT
13:17:23 web.1 | Redirected to http://localhost:3000/admin/stock_locations
13:17:23 web.1 | Completed 302 Found in 82226ms (ActiveRecord: 7246.4ms)
```