Skip to content

Conversation

@kenjis
Copy link
Member

@kenjis kenjis commented May 27, 2022

The return type of write-type query methods are not unified.
Failures of writing to database are abnormal things, so Exceptions should be thrown.

  • change return type to void
  • add query return value checks

If you forget to check an error, you’ll get silent bugs. Unchecked error values are worse than uncaught exceptions.
https://programmingduck.com/articles/exceptions-error-values

Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this is a deficiency of the framework that we are always working around. Being in the Exceptions camp I am definitely in favor of this 🤗 but glad to see that Lonnie approves as well.

*
* @param array|User $data
*
* @TODO can't change the return type to void.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we should find a way to handle this with model callback events so we can catch update() etc. That would solve the return typing.

@kenjis kenjis merged commit 5259a70 into codeigniter4:develop May 27, 2022
@kenjis kenjis deleted the fix-Models-return-type branch May 27, 2022 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants