Skip to content

Fix count method return value. #4.1 #4069

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

Merged
merged 2 commits into from
Apr 7, 2014
Merged

Fix count method return value. #4.1 #4069

merged 2 commits into from
Apr 7, 2014

Conversation

Andreyco
Copy link
Contributor

@Andreyco Andreyco commented Apr 7, 2014

Hi there, I have very simple query

dd($this->borrowings()->count());

Actual output

string(1) "1"

Expected output

int(1)

Happens on 4.1.x, but probably on 4.x versions as well.
Since this, we cannot relly on === comparsion operator, which result into false all the time.
Is this behaviour by design, or just a flaw?

Return number represented as integer instead of string.
@Andreyco Andreyco changed the title Fix count method return value. Fix count method return value. #4.1 Apr 7, 2014
@@ -1586,7 +1586,7 @@ public function exists()
*/
public function count($column = '*')
{
return $this->aggregate(__FUNCTION__, array($column));
return (int)$this->aggregate(__FUNCTION__, array($column));
Copy link
Member

Choose a reason for hiding this comment

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

Can you put a space in between the cast and the function call?

@Andreyco
Copy link
Contributor Author

Andreyco commented Apr 7, 2014

I did.

taylorotwell added a commit that referenced this pull request Apr 7, 2014
Fix `count` method return value. #4.1
@taylorotwell taylorotwell merged commit 618910c into laravel:4.1 Apr 7, 2014
@Andreyco Andreyco deleted the 4.1 branch April 7, 2014 21:39
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.

2 participants