Skip to content

Assert data are unchanged during save #1053

Description

@mkrecek234

Use case: You have code which updates the total sum of an order. Now the customer adds an order position with price = 0.
You don't want to deal with it but just save the new total (which is identical to the old total).

Steps to reproduce:

  1. You have any model $model with an entity id=1, total_amount =100
  2. You do `$model->load(1)->save(['total_amount' => 100]);

You will get this error in recent develop branch:
Atk4\Data\Exception: Update failed, exactly 1 row was expected to be affected

I don't think this is an exception - testing for changes is done in save command - if not change happens because re-save of prior set values, then it is not an Exception. This behaviour was added with the recent changes in Atk4/Data

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions