Return query result as object instead of array for laravel/database compatibility

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Unknown
    • laravel-5.0.0
    • Affects Version/s: None
    • Component/s: Laravel
    • None
    • PHP Drivers
    • Needed
    • 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

      Laravel’s Query Builder always returns objects (source).

      - ['typeMap' => ['root' => 'array', 'document' => 'array']]
      + ['typeMap' => ['root' => 'object', 'document' => 'array']]
      

      This is a major breaking change that requires changing all array access into property access. Returning a MongoDB\Model\BSONDocument and MongoDB\Model\BSONArray is not possible as the data is casted with native PHP cast feature in Laravel code: (object) $result and (array) $result.

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

              Created:
              Updated:
              Resolved: