Use save instead of update_columns in the OrderUpdater#425
Use save instead of update_columns in the OrderUpdater#425jhawthorn merged 3 commits intosolidusio:masterfrom
Conversation
|
I'm 👍, having recently made changes so that attribute changes are present for the order updater hooks:
Ideally, I wouldn't want to register an update hook with order here, but seeing as though the states I was interested in were only changing with update_columns, there was no other way I could add behavior around situations where those states change. Changing this to save would allow me to use Active Record hooks instead, which is considered the "proper" approach for the specific problem I was attempting to solve. I also have no idea what |
|
This is a great step in the right direction. 👍 |
|
Well, we're not multi-currency, so we don't care about Anyhow, I'm super excited about eliminating updates without callbacks, so 👍 on this approach. Still a little nervous about the potential impact of this. Perhaps we should put this on a dev box and see how it works for us? |
|
I would expect that the most significant issues would come with:
|
|
Another potential for issues: unpersisted associated records will now be saved on an update! |
|
To help a bit with the The So, no change of order currency is happening at the initial So, to my experience, there is no code or interface in Spree to actually change the currency of an order. Furthermore that
So, either delete it, or change it to only assign changes to the Order without persistence. I'm favouring deletion. |
|
As the person who wrote most of the initial multi-currency code, I should probably weigh in here. The intent when I was designing the multi-currency system was to explicitly not allow people to switch the currency of an order. If you switch currencies, you get a new order. This avoids all of the problems that I am in favour of removing it, with a note in the release notes to explain why it has gone. |
|
Does this still look like something we'd like to ship? It does to me! |
|
I don't see why not. Maybe @jhawthorn is a bit out of time. |
d285655 to
db34d0a
Compare
|
Rebased. This is still good to go by me. |
db34d0a to
6c98b1c
Compare
|
Rebased again |
|
I am pretty scared by the change of the persist_totals call. I'm very pro this change overall, but aren't comfortable merging it in just before we get 1.2 ready, so @jhawthorn has agreed to merge it very early in 1.3. Stores that heavily abuse callbacks could get affected by the extra ones running on the .save, and if there were problems caused by that change they might take a while to figure out something wrong is even happening, with potential large impact to a running store. In short: 👍 for 1.3 |
Use save instead of update_columns in the OrderUpdater
|
Merging. We want this to get as much testing and exposure as possible before our 1.3 release. |
This uses a plan-old
#save(validate: false)instead of usingupdate_columns. A few changes were needed to make this work:homogenize_line_item_currencies, which could cause an order update on an order save.Importer::Orderso thatorder.contents.addwasn't called with an unsaved shipment on the order.I don't think this would be considered a change to our public API, but it has some potential to cause issues in other stores. However, I think it's also a significant improvement, and would allow
after_saveand similar AR hooks to actually work as expected.Looking for thoughts on:
homogenize_line_item_currencies? It was unit tested, but I don't understand what sort of store would need this behaviour.