-
Notifications
You must be signed in to change notification settings - Fork 43
Fix Query count error when call to webservice fails #34
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -428,7 +428,11 @@ public function count() | |
| $this->_execute(); | ||
| } | ||
|
|
||
| return $this->__resultSet->total(); | ||
| if(is_a($this->__resultSet, '\Cake\Datasource\ResultSetInterface')) { | ||
| return $this->__resultSet->total(); | ||
| } else { | ||
| return false; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would think this should return 0 and not false.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning 0 if something wrong happens during the query execution would let think it really did return 0 items. Is it something that we really want ? If the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A count method implies a numerical return to me, I'd be confused if I asked for a count, expecting a integer and got a boolean. The count method should not care if the query executed successfully or not, it's not it's responsibility. Remember the S in SOLID.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alaxos When "something wrong happens" an exception should be thrown :) |
||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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.
Space needed after
if. Useinstanceofinstead ofis_a().