doctrine/annotations v1.3.1 Docblock Annotations Parser
doctrine/cache v1.6.1 Caching library offering an object-oriented API for many cache backends
doctrine/collections v1.4.0 Collections Abstraction library
doctrine/common v2.7.2 Common Library for Doctrine projects
doctrine/data-fixtures v1.2.2 Data Fixtures for all Doctrine Object Managers
doctrine/dbal v2.5.12 Database Abstraction Layer
doctrine/doctrine-bundle 1.6.7 Symfony DoctrineBundle
doctrine/doctrine-cache-bundle 1.3.0 Symfony Bundle for Doctrine Cache
doctrine/doctrine-fixtures-bundle v2.4.0 Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle v1.2.1 Symfony DoctrineMigrationsBundle
doctrine/inflector v1.1.0 Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations v1.5.0 Database Schema migrations using Doctrine DBAL
doctrine/orm v2.5.6 Object-Relational-Mapper for PHP
oro/doctrine-extensions 1.2.0 Doctrine Extensions for MySQL and PostgreSQL.
Summary
Doctrine always sets parent to null in database even when parent is set to a valid entity.
The $repo->find(11) returns a Category entity that has a parent (I set it manually in the database) but the parent field is NULL. (I have also tried with an entity that has no parent, same result)
Here is the var_dump:
Bug Report
Summary
Doctrine always sets parent to null in database even when parent is set to a valid entity.
I have the following entity orm:
Here is the entity class:
You can see that I have the parent (parent_id) set as a foreign_key that refers to id. This is similar to what is here in the docs: https://www.doctrine-project.org/projects/doctrine-orm/en/2.5/reference/association-mapping.html#one-to-one-self-referencing There is no yaml but I got this yaml from doctrine (using the generation commands).
The issue is that no matter what I do I can never save what is set in the parent. Example code:
The
$repo->find(11)
returns a Category entity that has a parent (I set it manually in the database) but the parent field is NULL. (I have also tried with an entity that has no parent, same result) Here is the var_dump:This code create a new category in the database but the parent field is set to NULL.
What am I doing wrong?
Current behavior
Parent is not set in the DB but is being set in the entity (explanations above)
How to reproduce
Example code provided above
Expected behavior
Parent being set and saved to DB