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

Feature request: rollback a transaction left object in a valid state #284

Open
kumy opened this issue Aug 29, 2019 · 1 comment
Open

Feature request: rollback a transaction left object in a valid state #284

kumy opened this issue Aug 29, 2019 · 1 comment
Labels

Comments

@kumy
Copy link
Contributor

kumy commented Aug 29, 2019

(Moved from ikkez/f3-cortex#90)

When we rollback a transaction, the previously saved objects stay in a valid state (valid per use of dry()/valid() functions).

I would have expected the dry() function to return true.

here is a little example:

$f3->get('DB')->begin();
$move = new Move();
$move->comment = 'Some comment';

var_dump(move->dry());
$move->save();
var_dump(move->dry());

$f3->get('DB')->rollback();
var_dump(move->dry());

This outputs:

bool(true)
bool(false)
bool(false)

But I expect it to return:

bool(true)
bool(false)
bool(true)
@xfra35
Copy link
Member

xfra35 commented Aug 30, 2019

That's not possible since the DB class is not aware of all the mappers relying on it.

Just call reset() when the rollback is successful:

$f3->get('DB')->rollback() && $move->reset();

@ikkez ikkez added the wontfix label Nov 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants