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

[9.x] db:table command properly handle table who doesn't exist #43669

Merged
merged 6 commits into from Aug 15, 2022
Merged

[9.x] db:table command properly handle table who doesn't exist #43669

merged 6 commits into from Aug 15, 2022

Conversation

kichetof
Copy link
Contributor

New db:table doesn't proper handle table who doesn't exist.

When I first tried it, I run artisan db:table user (forgot the s) and instead of getting an error message I got an error:

   ErrorException 

  Attempt to read property "size" on null

  at vendor/laravel/framework/src/Illuminate/Database/Console/DatabaseInspectionCommand.php:89
     85▕     {
     86▕         return $connection->selectOne('SELECT (data_length + index_length) AS size FROM information_schema.TABLES WHERE table_schema = ? AND table_name = ?', [
     87▕             $connection->getDatabaseName(),
     88▕             $table,
  ➜  89▕         ])->size;
     90▕     }
     91▕ 
     92▕     /**
     93▕      * Get the size of a Postgres table in bytes.

      +16 vendor frames 
  17  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

This PR fix it by checking if table exists before accessing any properties.

@kichetof kichetof changed the title db:table command properly handle table who doesn't exist. [9.x] db:table command properly handle table who doesn't exist. Aug 11, 2022
@driesvints driesvints changed the title [9.x] db:table command properly handle table who doesn't exist. [9.x] db:table command properly handle table who doesn't exist Aug 15, 2022
@taylorotwell taylorotwell merged commit bbb9493 into laravel:9.x Aug 15, 2022
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.

None yet

3 participants