Test and fix Query\Builder::groupBy expression

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: Laravel
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      https://github.com/GromNaN/laravel-mongodb-private/pull/4#discussion_r1259060154

       

      This looks like a bug in:
      laravel-mongodb-private/src/Query/Builder.php

      Lines 251 to 257 in 06d3624

      I'm not sure why $last is used (the MySQL reference is lost on me), but there definitely needs to be some logic to avoid clobbering the _id field of the $group stage. If you actually want the incoming document's _id field to end up in a grouping, you need to project it into another field name. I'm not sure if there's an easy way to do that given the existing API but adding ['$last' => '$_id'] to the group ID seems very incorrect (even before we consider it being omitted from the output alongside "email").
       

              Assignee:
              Jérôme Tamarelle
              Reporter:
              Jérôme Tamarelle
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:

                  Estimated:
                  Original Estimate - 1 week
                  1w
                  Remaining:
                  Remaining Estimate - 1 week
                  1w
                  Logged:
                  Time Spent - Not Specified
                  Not Specified