Skip to content

Prefer native MySQL boolean type for SQL definition #7320

@Firehed

Description

@Firehed

Feature Request

What

Update the MySQL family (inc. MariaDB, etc) to use BOOLEAN instead of TINYINT for columns defined as boolean.

Why

#7221 changed the definition of a MySQL boolean column from TINYINT(1) to TINYINT, which MySQL then spits back as TINYINT(4) in several paths (SHOW CREATE TABLE, mysqldump, etc). While today's storage engines make that a meaningless change in terms of the actual data, this comment leads me to believe that may not always be true.

Probably of more immediate relevance, I'm trying to update a large legacy app to use Doctrine tooling, and this results in a diff in the schema. At best it'll cause some people to be concerned; more likely, it could lead to inadvertent ALTER statements.

I realize it's possible to work around this with a couple of different approaches, but that seems like it shouldn't be necessary.

How

The naive approach would be to change the getBooleanTypeDeclarationSQL() in AbstractMySQLPlatform to BOOLEAN. I suspected this wouldn't work since it's an alias, but I tried it with a local patch and it actually seemed fine (both with DBAL's and ORM's diff utilities), at least against MariaDB 11.8.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions