Symfony Sonata管理包更新文档导致删除嵌入文档

Symfony Sonata管理包更新文档导致删除嵌入文档,symfony,sonata-admin,sonata,doctrine-odm,odm,Symfony,Sonata Admin,Sonata,Doctrine Odm,Odm,我有一个使用SonataAdmin和ODM(Mongo)创建的应用程序。 我有两个类(部分和级别),其中第一个(部分)可以从级别嵌入许多类。 当我创建一个文档(节)并在其中嵌入一些级别时,它可以正常工作,但是更新该文档将导致删除所有嵌入的文档(级别) 两类: use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB; /** * @MongoDB\Document */ clas

我有一个使用SonataAdmin和ODM(Mongo)创建的应用程序。 我有两个类(部分和级别),其中第一个(部分)可以从级别嵌入许多类。 当我创建一个文档(节)并在其中嵌入一些级别时,它可以正常工作,但是更新该文档将导致删除所有嵌入的文档(级别)

两类:

    use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
    
    /**
     * @MongoDB\Document
     */
    
    class Level
    {
        /**
         * @MongoDB\Id
         */
        protected $id;
    
        /**
         * @MongoDB\Field(type="string")
         */
        protected $label;
    ...
    }

sectionAdmine文件

final class SectionAdmin extends AbstractAdmin
{
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('id')
            ->add('label')
            ->add('levels')
            // add custom action links
            ->add('_action', 'actions', [
                'actions' => [
                    'view' => [],
                    'edit' => [],
                ]
            ]);
    }
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper->add('label')->add('levels');
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper->add('label')->add('levels');
    }
}
单击更新后记录:

php_1    | NOTICE: PHP message: [debug] MongoDB command: {"update":"Section","ordered":true,"$db":"symfony","updates":[{"q":{"_id":{"$oid":"6067980a450b7345b76bc8f4"}},"u":{"$unset":{"levels.0":true,"levels.1":true}},"upsert":false,"multi":false}]}
php_1    | NOTICE: PHP message: [debug] MongoDB command: {"update":"Section","ordered":true,"$db":"symfony","updates":[{"q":{"_id":{"$oid":"6067980a450b7345b76bc8f4"}},"u":{"$pull":{"levels":null}},"upsert":false,"multi":false}]}
php_1    | NOTICE: PHP message: [debug] MongoDB command: {"update":"Section","ordered":true,"$db":"symfony","updates":[{"q":{"_id":{"$oid":"6067980a450b7345b76bc8f4"}},"u":{"$push":{"levels":{"$each":[{"_id":{"$oid":"606666688041ee13136a5f52"},"label":"5eme"},{"_id":{"$oid":"6066666d8041ee13136a5f53"},"label":"6eme"},{"_id":{"$oid":"6067962f493d2118fc74f5c2"},"label":"1 ere"}]}}},"upsert":false,"multi":false}]}
php_1    | NOTICE: PHP message: [debug] MongoDB command: {"delete":"Level","ordered":true,"$db":"symfony","deletes":[{"q":{"_id":{"$oid":"606666688041ee13136a5f52"}},"limit":1}]}
php_1    | NOTICE: PHP message: [debug] MongoDB command: {"delete":"Level","ordered":true,"$db":"symfony","deletes":[{"q":{"_id":{"$oid":"6066666d8041ee13136a5f53"}},"limit":1}]}
php_1    | NOTICE: PHP message: [debug] MongoDB command: {"update":"Section","ordered":true,"$db":"symfony","updates":[{"q":{"_id":{"$oid":"6067980a450b7345b76bc8f4"}},"u":{"$unset":{"levels.0":true,"levels.1":true}},"upsert":false,"multi":false}]}
php_1    | NOTICE: PHP message: [debug] MongoDB command: {"update":"Section","ordered":true,"$db":"symfony","updates":[{"q":{"_id":{"$oid":"6067980a450b7345b76bc8f4"}},"u":{"$pull":{"levels":null}},"upsert":false,"multi":false}]}
php_1    | NOTICE: PHP message: [debug] MongoDB command: {"update":"Section","ordered":true,"$db":"symfony","updates":[{"q":{"_id":{"$oid":"6067980a450b7345b76bc8f4"}},"u":{"$push":{"levels":{"$each":[{"_id":{"$oid":"606666688041ee13136a5f52"},"label":"5eme"},{"_id":{"$oid":"6066666d8041ee13136a5f53"},"label":"6eme"},{"_id":{"$oid":"6067962f493d2118fc74f5c2"},"label":"1 ere"}]}}},"upsert":false,"multi":false}]}
php_1    | NOTICE: PHP message: [debug] MongoDB command: {"delete":"Level","ordered":true,"$db":"symfony","deletes":[{"q":{"_id":{"$oid":"606666688041ee13136a5f52"}},"limit":1}]}
php_1    | NOTICE: PHP message: [debug] MongoDB command: {"delete":"Level","ordered":true,"$db":"symfony","deletes":[{"q":{"_id":{"$oid":"6066666d8041ee13136a5f53"}},"limit":1}]}