beyondcode / invoker-community

74 stars 2 forks source link

[Bug]: Tinyint database field interpreted as boolean #312

Closed tobya closed 1 year ago

tobya commented 1 year ago

Operating system

Windows 10

Laravel Version

v8.12

PHP Version

8.0

Project Location

Remote (Server)

Bug description

the field on my mysql table which is defined as a tinyint is being interpreted as a boolena

$table->tinyInteger('discoverable_type',false, true)->default(0);

I use values 1 - 20 to specify differnt things, they should not be considered boolean.

Steps to reproduce

Create a tabel with a field type of tinyint

invoker will interpert it as a boolean

Relevant log output

No response

mpociot commented 1 year ago

This seems to be an issue related to Doctrine's way of detecting column types. Doctrine automatically detects a MySQL tinyint column as Boolean so there's no way for us to figure out if a column is an actual boolean or a tiny integer.

As a workaround, you can add a custom int casting to the affected model:

protected $casts = [
    'tinyint' => 'int',
];