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
I'm cleaning up a table in a SQLite database that has not yet had its "ip" column added. This results in an array being returned from R::exec(..), even though it promises to return an integer:
You can se the SQL statement being executed in the screenshot, as well as the exception being thrown, resulting in either null or array() being returned. The query function is called from exec.
In this particular case, wouldn't it be safe to return 0 (zero) when the column or table is missing? I understand query might be used somewhere else, so we'd probably need a $_calledFromExec argument to apply this rule.
If not, I'd rather have the actual exception re-thrown.
The text was updated successfully, but these errors were encountered:
If you freeze the database before running your queries then it will simply throw the exception.
Is that something you could use for your case?
Regarding the fact that exec should return an integer, I think we could probably just make it clear in the comments that it can return more types when executed in Fluid mode?
I'm not a fan of inconsistent behaviour, so personally I would prefer having the same behaviour during both development and when running in production.
exec is supposed to return number of affected rows, right? If so, I'm not sure why we would want it to return anything other than an integer. The API docs are not clear on this - it just states that an Integer is returned without further explaination: https://redbeanphp.com/api/classes/RedBeanPHP.Facade.html#method_exec
No matter the decision, please consider improving the description for exec.
Hi,
I'm cleaning up a table in a SQLite database that has not yet had its "ip" column added. This results in an array being returned from R::exec(..), even though it promises to return an integer:
You can se the SQL statement being executed in the screenshot, as well as the exception being thrown, resulting in either null or array() being returned. The query function is called from exec.
In this particular case, wouldn't it be safe to return 0 (zero) when the column or table is missing? I understand query might be used somewhere else, so we'd probably need a $_calledFromExec argument to apply this rule.
If not, I'd rather have the actual exception re-thrown.
The text was updated successfully, but these errors were encountered: