Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Fix db:show's --counts option #51140

Merged
merged 1 commit into from
Apr 19, 2024
Merged

Conversation

xuchunyang
Copy link
Contributor

I found a bug of db:show's --counts option, I believe it occurs in any new laravel apps

laravel-cms git:(main) artisan db:show --counts

   Error

  Call to a member function getName() on array

  at vendor/laravel/framework/src/Illuminate/Database/Console/ShowCommand.php:82
     78▕             '_' => ray($table),
     79▕             'table' => $table['name'],
     80▕             'schema' => $table['schema'],
     81▕             'size' => $table['size'],
  ➜  82▕             'rows' => $this->option('counts') ? $connection->table($table->getName())->count() : null,
     83▕             'engine' => $table['engine'],
     84▕             'collation' => $table['collation'],
     85▕             'comment' => $table['comment'],
     86▕         ]);

  1   [internal]:0
      Illuminate\Database\Console\ShowCommand::Illuminate\Database\Console\{closure}()
      +17 vendor frames

  19  artisan:13
      Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))

with the fix, now the command works fine

➜  laravel-cms git:(main) artisan db:show --counts

  SQLite ............................................................................................... 3.43.2
  Database ........................................................................... database/database.sqlite
  Host ........................................................................................................
  Port ........................................................................................................
  Username ....................................................................................................
  URL .........................................................................................................
  Open Connections ............................................................................................
  Tables ................................................................................................... 19

  Table ........................................................................................... Size / Rows
  banner_categories ..................................................................................... — / 5
  banners .............................................................................................. — / 10
  cache ................................................................................................. — / 1
  cache_locks ........................................................................................... — / 0
  failed_jobs ........................................................................................... — / 0
  job_batches ........................................................................................... — / 0
  jobs .................................................................................................. — / 0
  menu_categories ....................................................................................... — / 3
  menus ................................................................................................ — / 15
  messages ............................................................................................. — / 50
  migrations ........................................................................................... — / 14
  pages ................................................................................................ — / 10
  password_reset_tokens ................................................................................. — / 0
  personal_access_tokens ................................................................................ — / 0
  product_categories ................................................................................... — / 10
  products ............................................................................................. — / 50
  sessions .............................................................................................. — / 1
  settings .............................................................................................. — / 1
  users ................................................................................................ — / 5

@driesvints driesvints changed the title Fix db:show's --counts option [11.x] Fix db:show's --counts option Apr 19, 2024
@taylorotwell taylorotwell merged commit a4bd642 into laravel:11.x Apr 19, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants