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
Describe what you are trying to achieve and what goes wrong.
As described in this forum post I have a ResultSet returned from a simple Model::find().
I then attempt to update the returned records as recommended by the docs when operating on ResultSets:
I had a database schema violation due to some old, non-conforming rows in the test database.
That meant that the update of the resultset did not succeed. However, $result always returned true, even on a failed update.
When looking at the source code for the update method, it seems that ResultSet::update returns true unconditionally.
I believe this behaviour to be a bug, since the regular way of detecting errors now doesn't work anymore:
I have not been able to work on a fix, but from my limited understanding of the code I have the following fix in mind.
The transaction variable in the update method seems to track failure so my proposed fix would simply be:
Database: mysql Ver 15.1 Distrib 10.2.22-MariaDB, for Linux (x86_64) using readline 5.1
The text was updated successfully, but these errors were encountered:
gytsen
changed the title
Resultset's returned value is always true regardless of transaction failure
[Resultset::update] returned value is always true regardless of transaction failure
Aug 8, 2019
Expected and Actual Behavior
As described in this forum post I have a
ResultSet
returned from a simpleModel::find()
.I then attempt to update the returned records as recommended by the docs when operating on ResultSets:
I had a database schema violation due to some old, non-conforming rows in the test database.
That meant that the update of the resultset did not succeed. However,
$result
always returnedtrue
, even on a failed update.When looking at the source code for the update method, it seems that
ResultSet::update
returnstrue
unconditionally.I believe this behaviour to be a bug, since the regular way of detecting errors now doesn't work anymore:
Right now I work around this issue by checking the message count of the resultset, but I feel that this is a bit hacky:
Suggested Fix
I have not been able to work on a fix, but from my limited understanding of the code I have the following fix in mind.
The
transaction
variable in the update method seems to track failure so my proposed fix would simply be:However, since I have only looked at the code at a glance, I am unsure if this is the right approach.
If there is anything else I can do to help, feel free to ask.
Details
7.2.17
Fedora 28 GNU/Linux 5.0.9-100.fc28.x86_64
nginx/1.12.1
mysql Ver 15.1 Distrib 10.2.22-MariaDB, for Linux (x86_64) using readline 5.1
The text was updated successfully, but these errors were encountered: