laravel-mongodb - Issue #3512: GroupBy with count does not work

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Laravel
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      mshamaseen has created Issue #3512: GroupBy with count does not work in laravel-mongodb. This Jira ticket was filed by GromNaN

      Issue Text:

      • Laravel-mongodb Version: 5.7
      • PHP Version: 8.4

      Description:

      `Message::where('broadcast_id', 3)>groupBy('status')>count();`

      result to
      <warning> WARNING </warning> Object of class Illuminate\Support\Collection could not be converted to int in vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php on line 3932.

      and the return value is always 1.

      The reason for that is:
      https://github.com/mongodb/laravel-mongodb/blob/7ae18756959ba9bc2b44c62d897d29bb1e39c5a2/src/Query/Builder.php#L610

      It returns a collection if groupBy exists.

      whereas Laravel count function on vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:3932 expects a number.

            Assignee:
            Jérôme Tamarelle
            Reporter:
            TPM Jira Automations Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: