Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete SalePrice only delete relation #1

Open
ignacioverdejo opened this issue Apr 7, 2014 · 1 comment
Open

Delete SalePrice only delete relation #1

ignacioverdejo opened this issue Apr 7, 2014 · 1 comment

Comments

@ignacioverdejo
Copy link

In Spree backend, as Admin, when you delete a SalePrice associated to a product, the relation between Product, Price and SalePrice is removed, but SalePrice persist in the database keeping the relation between Variant, Price and SalePrice

@berkes
Copy link

berkes commented Aug 7, 2014

I cannot reproduce. In my setup (Spree 2.2, Rails 4) the record seems to be removed:

Started DELETE "/admin/products/ruby-on-rails-mug/sale_prices/13" for 127.0.0.1 at 2014-08-07 16:18:08 +0200
Processing by Spree::Admin::SalePricesController#destroy as JS
  Parameters: {"authenticity_token"=>"dvEJgMurZZ6cg5DjoPS2jdpg6Q1LCBlhCnjQCcKHnDQ=", "product_id"=>"ruby-on-rails-mug", "id"=>"13"}
  .... Cut out irrelevant Queries ....
  Spree::SalePrice Load (0.2ms)  SELECT "spree_sale_prices".* FROM "spree_sale_prices" WHERE "spree_sale_prices"."id" = ? LIMIT 1  [["id", "13"]]
   (0.1ms)  begin transaction
  Spree::Calculator Load (0.3ms)  SELECT "spree_calculators".* FROM "spree_calculators" WHERE "spree_calculators"."calculable_id" = ? AND "spree_calculators"."calculable_type" = ? LIMIT 1  [["calculable_id", 13], ["calculable_type", "Spree::SalePrice"]]
  SQL (0.5ms)  DELETE FROM "spree_calculators" WHERE "spree_calculators"."type" IN ('Spree::Calculator::DollarAmountSalePriceCalculator') AND "spree_calculators"."id" = ?  [["id", 19]]
  SQL (0.3ms)  DELETE FROM "spree_sale_prices" WHERE "spree_sale_prices"."id" = ?  [["id", 13]]
   (2.7ms)  commit transaction

The last query removes it.

Could it be that, when adding a sale-price it gets added twice? and on deletion only one is deleted? That is what happens with my setup (refer issue: #4). I mean: after deleting a newly added sale price: it is added twice. After removing one, one other persists, since it was added double.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants