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

Fix "php artisan db:table" and "db:show" with MongoDB connection

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • laravel-4.7.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?

      Since laravel-mongodb 4.7, it's possible to use the Laravel commands:

      • db:tables list all the tables from the configured database
      • db:show list all the fields of the existing document (nothing for empty collection, which is different from SQL)

      Suggest using Compass of the Atlas UI to get complete view of the collections and fields.

      New supported methods:

      • Schema::getColumns list all the fields in existing document. Using a sample for documents and limited to the 1000 top most used fields.
      • Schema::hasColumn(string $column) checks if at least one document has this field
      • Schema::hasColumns(string[] $columns) checks if at least one document has this field
      • Schema::getTables() list all the existing collections with the storage size
      • Schema::getTableListing() list all the existing collections names

      Note: the new Connection::getServerVersion should not be documented, because the implementation is partial due to the restrictive Laravel API.

      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? Since laravel-mongodb 4.7, it's possible to use the Laravel commands: db:tables list all the tables from the configured database db:show list all the fields of the existing document (nothing for empty collection, which is different from SQL) Suggest using Compass of the Atlas UI to get complete view of the collections and fields. New supported methods: Schema::getColumns list all the fields in existing document. Using a sample for documents and limited to the 1000 top most used fields. Schema::hasColumn(string $column) checks if at least one document has this field Schema::hasColumns(string[] $columns) checks if at least one document has this field Schema::getTables() list all the existing collections with the storage size Schema::getTableListing() list all the existing collections names Note: the new Connection::getServerVersion should not be documented, because the implementation is partial due to the restrictive Laravel API.

       php artisan db:table 
      
         BadMethodCallException 
      
        Method MongoDB\Laravel\Schema\Grammar::compileTables does not exist.
      
        at vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:115
          111▕      */
          112▕     public function __call($method, $parameters)
          113▕     {
          114▕         if (! static::hasMacro($method)) {
        ➜ 115▕             throw new BadMethodCallException(sprintf(
          116▕                 'Method %s::%s does not exist.', static::class, $method
          117▕             ));
          118▕         }
          119▕ 
      
            +15 vendor frames 
      
      
       php artisan db:show 
      
         Error 
      
        Call to a member function getAttribute() on null
      
        at vendor/laravel/framework/src/Illuminate/Database/Connection.php:1632
          1628▕      * @return string
          1629▕      */
          1630▕     public function getServerVersion(): string
          1631▕     {
        ➜ 1632▕         return $this->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
          1633▕     }
          1634▕ 
          1635▕     /**
          1636▕      * Register a connection resolver.
      
            +14 vendor frames 
      

        There are no Sub-Tasks for this issue.

            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:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: