Test and fix Query\Builder::groupBy expression

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Works as Designed
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: Laravel
    • None
    • 🔵 Done
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • 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:
              Resolved:

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