Uploaded image for project: 'PHP ORMs'
  1. PHP ORMs
  2. PHPORM-45

Add the method Query\Builder::toMql()

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Laravel
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Add the method Mongodb\Query\Builder::toMql() to mimic the Illuminate\Database\Query::toSql(). No need for a toRawSql() equivalent because there is no data binding.

      This will help writing comprehensive tests on query builder. PHPORM-33

      The MQL format (my proposition)

      MQL is a javascript-like format.

      The collection name is not in the dumped format.

      db.users.find().skip(5).take(10)
      [
          'find' => [
              [],
              ['skip' => 5, 'limit' => 10]
          ],
      ]

      Or in split version:

      [
          'find' => [],
          'skip' => [5],
          'take' => [10],
      ]

      When chaining, add several calls to the array. This does not accept calls to the same method. But the query builder never use method chaining.

      db.users.find({"name.family": "Smith"}).count()
      
      [
          'find' => [['name.family' => 'Smith']],
          'count' => [],
      ]
      

       

       

            Assignee:
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Reporter:
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              None
              None
              None
              None