Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-565

MySQL 5.6, Doctrine\DBAL\DBALException: Unknown database type bit requested.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.3.4
    • Fix Version/s: None
    • Component/s: Platforms
    • Labels:
      None
    • Environment:
      Mysql 5.6.12, MacOS, PHP 5.4.16.

      Description

      Given the following db table connected with an ORM entity:

      CREATE TABLE `foo` (
        `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `bitField` bit(1) DEFAULT NULL,
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
      

      Running something like orm:validate-schema will result in the following exception.

      [Doctrine\DBAL\DBALException]
      Unknown database type bit requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.

      BIT datatype is available since mysql 5.0.3 but D2 Mysql platform doesn't seem to understand it

        Activity

        Hide
        Marco Pivetta added a comment -

        Arthur Bodera the platforms only support base types (common to all platforms) out of the box. If you want additional types, you need to register them.

        Show
        Marco Pivetta added a comment - Arthur Bodera the platforms only support base types (common to all platforms) out of the box. If you want additional types, you need to register them.
        Hide
        Arthur Bodera added a comment - - edited

        It seems that BIT(M) column represents packed bits and is not directly transferable to "boolean", nor to (unpacked) "binary" d2 types. This leaves this column type in an awkward position, where no d2 built-in type matches it perfectly. Mapping it to "boolean" limits its scope and could result in data loss. Mapping it to "binary" could result in unexpected behavior.

        Right now, the only 2 valid solutions I see are:

        Show
        Arthur Bodera added a comment - - edited It seems that BIT(M) column represents packed bits and is not directly transferable to "boolean", nor to (unpacked) "binary" d2 types. This leaves this column type in an awkward position, where no d2 built-in type matches it perfectly. Mapping it to "boolean" limits its scope and could result in data loss. Mapping it to "binary" could result in unexpected behavior. Right now, the only 2 valid solutions I see are: creating a custom doctrine2 type, or adding a type alias in user-land code to map BIN to something like boolean

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Arthur Bodera
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: