Deprecation: Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated

后端 未结 2 1439
抹茶落季
抹茶落季 2021-02-01 12:02

I\'m using Symfony 4.3.8 and I can\'t find any information about thoses deprecations :

User Deprecated: Creating Doctrine\\ORM\\Mapping\\UnderscoreNamingS

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 12:27

    In most cases I would just answer this sort of question with a comment but I suspect other developers might run into this issue. I poked around a bit and could not find any explicit documentation on this issue. Perhaps because the DoctrineBundle is under the control of the Doctrine folks and not the Symfony developers. Or maybe I am just a bad searcher.

    In any event, between 4.3 and 4.4 the service name for the underscore naming strategy was changed.

    # doctrine.yaml
    orm:
      # 4.3
      naming_strategy: doctrine.orm.naming_strategy.underscore
      # 4.4
      naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
    

    And a depreciation message was added to warn developers to change the name. Would have been nice if the message was just a tiny bit more explicit but oh well. So if you are upgrading an existing app to 4.4 and beyond then you will probably need to manually edit your doctrine.yaml file to make the depreciation message go away.

    Some more info (thanks @janh) on why the change was made: https://github.com/doctrine/orm/blob/2.8.x/UPGRADE.md#deprecated-number-unaware-doctrineormmappingunderscorenamingstrategy https://github.com/doctrine/orm/issues/7855

    Still not really clear on why "they" chose to do things this way but oh well. You probably want to run "bin/console doctrine:schema:update --dump-sql" just to see if this impacts your database column names and adjust accordingly. The changes has been out for several weeks now and there does not seem to be many howls of outrage over the change so I guess most column names don't have embedded numbers. So far at least.

提交回复
热议问题