- πΊπΈUnited States smustgrave
With so many years of inactivity wonder if this is still a desired feature request for D10+
- Status changed to Active
about 1 year ago 11:11am 18 October 2023 - π©πͺGermany Anybody Porta Westfalica
Just ran into this with a hook_schema for a custom field item.
And yes, I think the request still makes sense.
DataDefinition::create('boolean')
exists, while'enabled' => [ 'type' => 'boolean', 'not null' => TRUE, 'default' => TRUE, 'description' => 'Enabled status', ],
is not possible and you have to use
'enabled' => [ 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 1, 'description' => 'Enabled status', ],
Several database engines support a boolean type:
- https://mariadb.com/kb/en/boolean/
- https://www.mysqltutorial.org/mysql-boolean/
- https://www.postgresql.org/docs/9.1/datatype-boolean.html
Sone don't and use
int
:Still I thnk it would make sense to add the boolean type for Drupal and implement the fallback to
'type' => 'int', 'size' => 'tiny',
in the database-specific implementations. So we could hide that complexity.
What do you think?