Skip to content

Fix Undefined property: stdClass::$column_name#179

Open
stuheiss wants to merge 1 commit intoXethron:masterfrom
stuheiss:master
Open

Fix Undefined property: stdClass::$column_name#179
stuheiss wants to merge 1 commit intoXethron:masterfrom
stuheiss:master

Conversation

@stuheiss
Copy link
Copy Markdown

@stuheiss stuheiss commented Feb 4, 2019

Querying information_schema.columns returns upper cased column names on
some versions of mysqld. This is similar to an old bug in
laravel/framework. See laravel/framework#20190

Fix by changing
select column_name, column_type ...
to
select column_name as column_name, column_type as column_type ...

Querying information_schema.columns returns upper cased column names on
some versions of mysqld. This is similar to an old bug in
laravel/framework. See laravel/framework#20190

Fix by changing
    select column_name, column_type ...
to
    select column_name as column_name, column_type as column_type ...
@t4e192
Copy link
Copy Markdown

t4e192 commented Apr 25, 2019

I encountered the exact same error message while using xethron/migrations-generator ^2.0
However, I was using this in a Lumen 5.5.*, PHP 7.1.27 no OpCache implementation.
Bear in mind that OpCache will cause other problems.
Steps:

  1. composer require --dev "xethron/migrations-generator"

  2. bootstrap\app.php
    $app->register(\Way\Generators\GeneratorsServiceProvider::class);
    $app->register(\Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider::class);

  3. vendor\laravel\lumen-framework\src\Application.php at the bottom append the following:
    public function configPath($path = ''){
    return $this->basePath.DIRECTORY_SEPARATOR.'config'.($path ? DIRECTORY_SEPARATOR.$path : $path);
    }

  4. vendor\xethron\laravel-4-generators\src\config\config.php at the top add the following:
    function app_path($path = '') {
    return app('path') . ($path ? DIRECTORY_SEPARATOR . $path : $path);
    }

  5. vendor\xethron\laravel-4-generators\src\Way\Generators\GeneratorsServiceProvider.php
    Change the boot() function to the following:
    public function boot(){
    $path = 'generators.config.php';
    $basePath = '../../../../../../../../'; // this points back to the project base folder
    $this->publishes([
    DIR.'/../../config/config.php' => $basePath.DIRECTORY_SEPARATOR.'config'.($path ? DIRECTORY_SEPARATOR.$path : $path),
    ]);
    }

  6. vendor\xethron\laravel-4-generators\src\Way\Generators\Commands\GeneratorCommand.php
    comment out //use Config
    and replace it with use Illuminate\Support\Fascades\Config;

  7. php artisan --> should work normally now

  8. try to do a "php artisan migrate:generate" and see if the same error message appears or not.
    If it does, then take a look at your table schema and change enum's to chars instead.

--Jemmy

@zack6849
Copy link
Copy Markdown

I encountered this issue and the PR fixed it for me, it seems to happen specifically when running laradock, at least for me, +1

@skcin7
Copy link
Copy Markdown

skcin7 commented Mar 11, 2020

Okay, so any ideas how best to fix this?

I'm getting this issue now for one of my tables which has an ENUM field, for whatever reason.

@sevba
Copy link
Copy Markdown

sevba commented May 13, 2020

Also interested in a fix for this one.

@hughsmith10
Copy link
Copy Markdown

Any chance this issue could be fixed? Or maybe even upgraded to Laravel 7.x?

@jafarchoupan
Copy link
Copy Markdown

i have same problem .
any body have resolve for this issue ?

configuration :
php7.1
laravel 5.3
mysql 8.0.22

ErrorException in MySqlProcessor.php line 18:
Undefined property: stdClass::$column_name

@tjventurini
Copy link
Copy Markdown

The simple workaround for now is to update the file vendor/xethron/migrations-generator/src/Xethron/MigrationsGenerator/Generators/FieldGenerator.php. On line 82 and 83, change column_name to COLUMN_NAME and column_type to COLUMN_TYPE.

Then the command should run through 👍

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.

8 participants