InfyOmLabs / laravel-generator

API and Admin Panel CRUD Generator for Laravel.
https://www.infyom.com/open-source
MIT License
3.79k stars 813 forks source link

Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it. #1065

Open gabriellaborghi opened 1 year ago

gabriellaborghi commented 1 year ago

The command: php artisan infyom:scaffold Questionario --fromTable --table=questionario --primary=que_id --plural=Questionari --connection=checkpoint works well in 5.4.1 version. Now it doesn't work and shows the error in the object. at vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php:454 450▕ 451▕ $dbType = strtolower($dbType); 452▕ 453▕ if (! isset($this->doctrineTypeMapping[$dbType])) { ➜ 454▕ throw new Exception( 455▕ 'Unknown database type ' . $dbType . ' requested, ' . static::class . ' may not support it.' 456▕ ); 457▕ } 458▕

  +23 vendor frames

24 artisan:37

ringkubd commented 1 year ago

I fixed the issue and created a pull request. Check this file InfyOm\Generator\Utils\GeneratorForeignKey line number 80. $this->tableDetails = $this->schemaManager->listTableDetails($this->tableName); initialized before custom doctrine mappings. Just add this line after mappings loop.

// Removed
        // $this->tableDetails = $this->schemaManager->listTableDetails($this->tableName);

        $mappings = config('laravel_generator.from_table.doctrine_mappings', []);
        $mappings = array_merge($mappings, $defaultMappings);
        foreach ($mappings as $dbType => $doctrineType) {
            $platform->registerDoctrineTypeMapping($dbType, $doctrineType);
        }
        // Added
        $this->tableDetails = $this->schemaManager->listTableDetails($this->tableName);