Doctrine Mapping Issue: "default" Value Overwrites "name" Attribute Value in Certain Cases. #7128

Closed
opened 2026-01-22 15:45:16 +01:00 by admin · 1 comment
Owner

Originally created by @oto-emo on GitHub (Mar 31, 2023).

Hi everyone!

I've been coding on Symfony (and Doctrine) since 2016 and I've come across an issue that doesn't seem to be caused by my code, maybe it's related to Doctrine.

I've noticed a problem that's a bit difficult to understand (especially to explain), and it took me a while to identify its source. I feel like the use of certain terms (column names and/or class properties) is causing the problem.


Here's the problem: I have three entities with the following relationships:

Fund -> OneToMany -> FundBenchmark
Benchmark -> OneToMany -> FundBenchmark

FundBenchmark is the relational table, carrying additional attributes for Fund and Benchmark.

In FundBenchmark, I have:

  • id
  • fund_id
  • benchmark_id
  • rank

And in Benchmark:

  • id
  • name

Now, this is where things get tricky to explain. I have two benchmarks with different names, but they are linked to the same Fund and have different ranks.

Benchmark:

  • id: 1
  • name: benchmark 1
  • id: 2
  • name: benchmark 2

They are linked to the same Fund but have different ranks.

FundBenchmark:

  • id: 1
  • fund: #Same Fund
  • benchmark: #benchmark 1
  • rank: default
  • id: 2
  • fund: #Same Fund
  • benchmark: #benchmark 2
  • rank: bench2

What I've noticed is that in this state, I retrieve both rows correctly, but the name field of the benchmark with rank bench2 is overwritten by the name of the benchmark with rank default. All other values are correct. If I modify the value of the default rank in the database to something else, the name field has the correct value present in the database.

I suspect that the value "default" and the property name "name" together are disrupting the proper retrieval of the expected "name" value.

Specifications :

  • doctrine/doctrine-bundle : 2.9.0
  • doctrine/orm : 2.14.1
  • doctrine/dbal: 3.6.1
  • symfony/symfony : 5.4.22
  • DBMS : SQL Server 15.0
Originally created by @oto-emo on GitHub (Mar 31, 2023). Hi everyone! I've been coding on Symfony (and Doctrine) since 2016 and I've come across an issue that doesn't seem to be caused by my code, maybe it's related to Doctrine. I've noticed a problem that's a bit difficult to understand (especially to explain), and it took me a while to identify its source. I feel like the use of certain terms (column names and/or class properties) is causing the problem. --- Here's the problem: I have three entities with the following relationships: Fund -> OneToMany -> FundBenchmark Benchmark -> OneToMany -> FundBenchmark FundBenchmark is the relational table, carrying additional attributes for Fund and Benchmark. In FundBenchmark, I have: - id - fund_id - benchmark_id - rank And in Benchmark: - id - name Now, this is where things get tricky to explain. I have two benchmarks with different names, but they are linked to the same Fund and have different ranks. Benchmark: - id: 1 - name: benchmark 1 -- - id: 2 - name: benchmark 2 They are linked to the same Fund but have different ranks. FundBenchmark: - id: 1 - fund: #Same Fund - benchmark: #benchmark 1 - rank: default -- - id: 2 - fund: #Same Fund - benchmark: #benchmark 2 - rank: bench2 --- What I've noticed is that in this state, I retrieve both rows correctly, but the name field of the benchmark with rank bench2 is overwritten by the name of the benchmark with rank default. All other values are correct. If I modify the value of the default rank in the database to something else, the name field has the correct value present in the database. I suspect that the value "default" and the property name "name" together are disrupting the proper retrieval of the expected "name" value. **Specifications :** - doctrine/doctrine-bundle : 2.9.0 - doctrine/orm : 2.14.1 - doctrine/dbal: 3.6.1 - symfony/symfony : 5.4.22 - DBMS : SQL Server 15.0
admin closed this issue 2026-01-22 15:45:16 +01:00
Author
Owner

@oto-emo commented on GitHub (Apr 3, 2023):

A "simple" memory problem that was overwriting my previously loaded attributes.

@oto-emo commented on GitHub (Apr 3, 2023): A "simple" memory problem that was overwriting my previously loaded attributes.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7128