sethsandaru / eloquent-docs

Generate phpDoc for your Eloquent Models with ease

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unknown database type bit requested, Doctrine\DBAL\Platforms\MySQLPlatform may not support it

TalionOak opened this issue · comments

currently i am using bit as boolean

at vendor/doctrine/dbal/src/Platforms/AbstractPlatform.php:441
    $dbType = strtolower($dbType);
    if (! isset($this->doctrineTypeMapping[$dbType])) {
   throw new Exception(
    'Unknown database type ' . $dbType . ' requested, ' . static::class . ' may not support it.',
    );
    }
    

what i should do after this?

can you share your table's structure @TalionOak ?

I think in this case, we have 2 approaches:

1. Register as string

https://github.com/sethsandaru/eloquent-docs/blob/main/src/EloquentDocsServiceProvider.php#L20-L25

Looks to me, bit(1) or bit(n) stores the "010101010111" value, and it is basically a string.

I'd add this improvement for EloquentDocs. But honestly, it is really rare case to use "bit", I'd suggest using "tinyint(1)" for boolean.

2. Register as boolean from userland

Add this to your own project, register bit as boolean

// AppServiceProvider.php

public function boot(): void
{
    DB::connection()
        ->getDoctrineConnection()
        ->getDatabasePlatform()
        ->registerDoctrineTypeMapping('bit', 'boolean');
}