-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: BasePreparedQuery class to return boolean values for write-type queries #6750
Conversation
* @return ResultInterface | ||
* @return bool|ResultInterface | ||
* | ||
* @throws Exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why throws Exception
?
If the query execution fails, it seems it should throw DatabaseException
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it will throw different exceptions depending on the driver. For MySQL it will be mysqli_sql_exception
for others ErrorException
. There is no point in changing this and hiding the actual exception - at least I don't think it would be appropriate. I believe that the DatabaseException
should be used for things that are coming from the framework side and are in our gesture to handle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have changed the exception classes already in v4.3.
See #6163 and https://github.com/codeigniter4/CodeIgniter4/blob/4.3/user_guide_src/source/changelogs/v4.3.0.rst#id1
When CI throws many kind of Exception, if we switch DBMS, our code will break when we want to catch the execption.
Or we must always catch Exception
. But it is too wide. It is not good practice.
Anyway this PR is for develop
. So it seems okay. But what about 4.3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... blame on me. I wasn't aware of these changes in 4.3 branch. Making these changes in 4.2 branch has no real sense then. I switched the target branch to 4.3.
f49ebf6
to
5461477
Compare
What's the status on this? Can we get it in soon for 4.3? |
Description
Fixes #4342
This PR fixes the behavior of Prepared Queries, which always return a
Result
object.Some time ago, we fixed the regular query: #4176, but somehow Prepared Queries were forgotten.
Desired behavior is the same as for regular queries, return:
Result
object for "read" queriesbool
value for "write" queriesPotentially this is a breaking change, but we should treat it as a bug fix.
Checklist: