You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
recently, I've been exploring source code of some database entities and I've noticed, that in method update of object ActiveRow is one small bug. Well to be precise, it's not a bug, but I think It's not a valid behavior of method too.
The code of method looks like this:
publicfunction update($data) {
$selection = $this->table->createSelectionInstance()->wherePrimary($this->getPrimary());
if ($selection->update($data)) {
selection->select('*');
if (($row = $selection->fetch()) === FALSE) {
thrownewNette\InvalidStateException('Database refetch failed; row does not exist!');
}
$this->data = $row->data;
returnTRUE;
else {
return FALSE;
}
}
How you can see, if I’ll be updating primary key of ActiveRow, the primary key will be in database updated (if I don’t have defined any references on it), but I’ll end up with an exception “Database fetch failed;…” because in the query is used an old value of the primary key.
I think that a better behavior this method will be the one from below:
To disable update of a primary column(s), and throw an exception before update in DB
Or to fetch updated row for from DB on updated key (my option)
If you don't have anything against this, I'd like to resolve this issue & create pull request. (Because this term at school I have a subject called Open-Source Programming in which I have to join some running open source project & resolve some issues.) :D
Thanks for your attention,
and I'll look forward to your reply.
The text was updated successfully, but these errors were encountered:
Hi,
recently, I've been exploring source code of some database entities and I've noticed, that in method update of object ActiveRow is one small bug. Well to be precise, it's not a bug, but I think It's not a valid behavior of method too.
The code of method looks like this:
How you can see, if I’ll be updating primary key of ActiveRow, the primary key will be in database updated (if I don’t have defined any references on it), but I’ll end up with an exception “Database fetch failed;…” because in the query is used an old value of the primary key.
I think that a better behavior this method will be the one from below:
If you don't have anything against this, I'd like to resolve this issue & create pull request. (Because this term at school I have a subject called Open-Source Programming in which I have to join some running open source project & resolve some issues.) :D
Thanks for your attention,
and I'll look forward to your reply.
The text was updated successfully, but these errors were encountered: