Open cavasinf opened 11 months ago
I can't reproduce this issue. Can you share a reproducer as a repository?
Sorry, I was on vacation. I'll try to do a Symfony project this week that represents this case.
Here you go: https://github.com/cavasinf/doctrine-orm-10821
From your tests:
findBy
(sorry) but a QueryBuilder
Maybe you’re using different naming strategies for the different connections?
Can't you see the reproducer? Have you tried it?
No I haven’t tried it. I just saw your issue, noticed that it sounds like a naming strategy configuration issue.
Also you’re using two entity managers on the same set of entities. Not sure that is a supported configuration.
Bug Report
Summary
Switching from one database to multiple databases for one Symfony application, and following the doc How to Work with Multiple Entity Managers and Connections.
When using extend of
EntityRepository
on custom Repository, every camelCase SELECT generated are wrongs.Current behavior
When the entity property name is camelCase:
The repository tries to select the exact same column name in SQL version
t0.fullName
or in the database the true column name isfull_name
.An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.fullName' in 'field list'
Looking through the code, the problem comes from the ClassMetadaInfo -> AttributeDriver -> AttributeReader ->
convertToAttributeInstances()
.This code only looks at attribute names/values. When describing the property, if I add the
name
of the property as in the database (in kebab_case) it works as untended.Mapping result:
How to reproduce
[ORM\Entity(repositoryClass: UserRepository::class)]
class User {
[ORM\Column]
}
Do a
findBy
QueryBuilder
from that repository.Expected behavior
As when using the
ServiceEntityRepository
camelCase properties should be converted to kebab_case when defining the SELECT elements for the query.