Skip to content

Doctrine UUID/ULID types not recognized #38658

@secit-pl

Description

@secit-pl

Symfony version(s) affected: 5.2.0-BETA2

Description
As blog post and documentation says the UUID/ULID types should be automatically registered in doctrine when symfony/uuid component is used

https://symfony.com/blog/new-in-symfony-5-2-doctrine-types-for-uuid-and-ulid
https://symfony.com/doc/current/components/uid.html#ulids

The feature was introduced in #37678

How to reproduce

composer req symfony/uid

create an entity with:

    /**
     * @ORM\Id
     * @ORM\Column(type="ulid", unique=true)
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class=UlidGenerator::class)
     *
     * @JMS\Expose
     * @JMS\Groups({"basic"})
     * @JMS\Type("string")
     */
    private ?string $id = null;

php bin/console doctrine:schema:update --force

In DBALException.php line 282:
                                                                                                                                                                                                                                     
  Unknown column type "ulid" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If   
  this error occurs during database introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#get  
  MappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information.                                                                                                       
                                                                                                                                                                                                                                     

doctrine:schema:update [--complete] [--dump-sql] [-f|--force] [--em [EM]]

exit status 1

Possible Solution

After quick check I found that the types are added in Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterUidTypePass but I cannot find the place where this compiler pass is added (I guess it should be done in Doctrine\Bundle\DoctrineBundle\DoctrineBundle::build())

composer.json dump

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.4",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-pdo": "*",
        "jms/serializer-bundle": "^3.5",
        "secit-pl/signal-notifier-bundle": "^1.0",
        "secit-pl/validation-bundle": "^1.6",
        "sensio/framework-extra-bundle": "^5.1",
        "symfony-bundles/json-request-bundle": "^3.0",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "5.2.*",
        "symfony/console": "5.2.*",
        "symfony/dotenv": "5.2.*",
        "symfony/expression-language": "5.2.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "5.2.*",
        "symfony/framework-bundle": "5.2.*",
        "symfony/http-client": "5.2.*",
        "symfony/intl": "5.2.*",
        "symfony/mailer": "5.2.*",
        "symfony/messenger": "5.2.*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/notifier": "5.2.*",
        "symfony/orm-pack": "*",
        "symfony/process": "5.2.*",
        "symfony/security-bundle": "5.2.*",
        "symfony/serializer-pack": "*",
        "symfony/string": "5.2.*",
        "symfony/translation": "5.2.*",
        "symfony/twig-pack": "*",
        "symfony/uid": "5.2.*",
        "symfony/validator": "5.2.*",
        "symfony/web-link": "5.2.*",
        "symfony/yaml": "5.2.*"
    },
    "require-dev": {
        "symfony/debug-pack": "*",
        "symfony/maker-bundle": "^1.0",
        "symfony/profiler-pack": "*",
        "symfony/test-pack": "*"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.2.*"
        }
    },
    "minimum-stability": "beta"
}

Edit 1:
Switching to symfony/orm-pack (dev-master 46aa731) don't solve the problem.

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