Search code examples
phpsymfonydoctrine-ormupgrade

Problems Upgrading Doctrine ORM from 2.2 to 3.0 with DefaultQuoteStrategy::getColumnName()


I have a problem in my Symfony 6.4 when I upgrade Doctrine/orm from 2.2 to 3.0. The error says:

Doctrine\ORM\Mapping\DefaultQuoteStrategy::getColumnName(): Return value must be of type string, null returned

I know that is something about "object API of FieldMapping", because my fieldMapping is an array as the 2.2 version, but no an object as supuse to be in 3.0 version.

And here the commit where someone called greg0ire change my life: https://github.com/doctrine/orm/commit/2acb298e7445b8bd70aef4bbff78652b28c4aad4

My doctrine config is:

doctrine:
dbal:
    url: '%env(resolve:DATABASE_URL)%'
    server_version: '8.0.36'

    profiling_collect_backtrace: '%kernel.debug%'
    use_savepoints: true
    types:
        map_config: 'GameMap\Infrastructure\Persistence\Doctrine\DBAL\Types\MapConfigJsonType'
        group_config: 'GameMap\Infrastructure\Persistence\Doctrine\DBAL\Types\GroupConfigJsonType'
        poi_media_type: 'GameMap\Infrastructure\Persistence\Doctrine\DBAL\Types\PoiMediaTypeStringType'
        datetime_immutable_utc: 'GameMap\Infrastructure\Persistence\Doctrine\DBAL\Types\UtcDateTimeType'

orm:
    auto_generate_proxy_classes: true
    enable_lazy_ghost_objects: true
    report_fields_where_declared: true
    validate_xml_mapping: true
    naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
    auto_mapping: true
    mappings:
        GameMap:
            type: attribute
            is_bundle: false
            dir: '%kernel.project_dir%/src/Domain/Entity'
            prefix: 'GameMap\Domain\Entity'
            alias: GameMap
    controller_resolver:
      auto_mapping: true
    filters:
        deleted:
            class: 'GameMap\Infrastructure\Persistence\Doctrine\Filter\DeletedFilter'
            enabled: true

Thanks a lot!!


Solution

  • Finally I found the trick!! well tricks.

    As I said, all the problem is in the FieldMapping, because it is an array... why, because we require "doctrine/annotations".

    As an old project, some dependencies are there but not used anymore. Since the beggining we used attributes, and the config was "type: Attributes", but this package looks like make some interferences.

    This are the steps that we follow:

    1. Remove all doctrine dependencies with: composer remove doctrine/*
    2. Add doctrine as Symfony sugests with: composer require symfony/orm-pack
    3. Remove all the caches "hardly": rm -rf var/cache/dev/*
    4. Reload all the clases: composer dump-autoload

    I think that the tick was the doctrine/annotations and the cache.

    I hope be the only one with this problem, but if not, at least, I can be a help for someone else.