Uploaded image for project: 'PHP Driver: Library'
  1. PHP Driver: Library
  2. PHPLIB-107

DropCollection should not throw exception for nonexistent collection

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

      When writing tests (and importing scripts) it is very common to clear out a collection at the start of a script.

      Right now however, when dropping a collection (haven't checked database), you get an exception if the collection does not exist with the base driver:

      <?php
      use MongoDB\Driver;
      
      $a = new StdClass;
      $a->foo = 42;
      $a->bar = array( 5, 6, 7 );
      $a->obj = array( "foo" => 44 );
      
      $m = new Driver\Manager('mongodb://localhost:27017');
      
      $c = new Driver\Command( [ 'drop' => 'doesnotexist'] );
      $cursor = $m->executeCommand( 'demo', $c );
      

      This is fine behaviour for the base drivers, but the "convenience library" should really wrap this, and IMO, ignore the "ns does not exist" exception, just like the legacy driver does.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            derick Derick Rethans
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: