当我将 Doctrine/orm 从 2.2 升级到 3.0 时,我的 Symfony 6.4 出现问题。错误说:
Doctrine\ORM\Mapping\DefaultQuoteStrategy::getColumnName():返回值必须是string类型,返回null
我知道这是关于“FieldMapping 的对象 API”的内容,因为我的 fieldMapping 是一个数组,与 2.2 版本一样,但在 3.0 版本中没有假设的对象。
这里有人称为 greg0ire 的提交改变了我的生活:https://github.com/doctrine/orm/commit/2acb298e7445b8bd70aef4bbff78652b28c4aad4
我的学说配置是:
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
非常感谢!!
我终于找到窍门了!!好技巧。
正如我所说,所有问题都在 FieldMapping 中,因为它是一个数组...为什么,因为我们需要“学说/注释”。
作为一个老项目,有些依赖项存在但不再使用。因为一开始我们使用了属性,配置是“type: Attributes”,但是这个包看起来像是做了一些干扰。
这是我们遵循的步骤:
composer remove doctrine/*
composer require symfony/orm-pack
rm -rf var/cache/dev/*
composer dump-autoload
我认为勾选的是学说/注释和缓存。
我希望是唯一一个遇到这个问题的人,但如果没有,至少我可以帮助别人。