Skip to content

Conversation

@alaxos
Copy link

@alaxos alaxos commented Mar 3, 2017

Closes #33

if(is_a($this->__resultSet, '\Cake\Datasource\ResultSetInterface')) {
return $this->__resultSet->total();
} else {
return false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would think this should return 0 and not false.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the count() method is supposed to return integer.

Copy link
Author

Choose a reason for hiding this comment

The 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 execute() method can return false, couldn't the count() method do the same ?

Copy link
Collaborator

@davidyell davidyell Jul 25, 2017

Choose a reason for hiding this comment

The 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.

Copy link
Member

@ADmad ADmad Jul 25, 2017

Choose a reason for hiding this comment

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

@alaxos When "something wrong happens" an exception should be thrown :)

if(is_a($this->__resultSet, '\Cake\Datasource\ResultSetInterface')) {
return $this->__resultSet->total();
} else {
return false;
Copy link
Member

Choose a reason for hiding this comment

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

Yes, the count() method is supposed to return integer.

}

return $this->__resultSet->total();
if(is_a($this->__resultSet, '\Cake\Datasource\ResultSetInterface')) {
Copy link
Member

Choose a reason for hiding this comment

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

Space needed after if. Use instanceof instead of is_a().

@ADmad
Copy link
Member

ADmad commented Jul 14, 2017

@alaxos Ping

ADmad added a commit that referenced this pull request Aug 16, 2017
@ADmad
Copy link
Member

ADmad commented Nov 3, 2017

Fixed in #44

@ADmad ADmad closed this Nov 3, 2017
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