Doctrine manual says:
Doctrine does not quote identifiers automatically because this leads to more problems, than it would solve.
What exactly problems are there with quoting everything?
This quote comes from an older version of the documentation, under the Basic Mapping section. The latest documentation doesn't include this text anymore, but it is still true.
The Limitations and Known Issues section of the latest documentation sheds some light on this:
For compatibility reasons between all the supported vendors and edge case problems Doctrine 2 does NOT do automatic identifier quoting.
Because of the different quoting strategies used in different SQL vendors, and the way SQL is generated by the ORM, it is quite hard to come up with a solution that works for all cases. And it's even harder to maintain. It might not be impossible, but the Doctrine team decided it isn't worth the time, and (perhaps more importantly) code complexity, to try.
For a hint on how complex SQL generation is, browse through the code in the git repository.
It's a common best practice to only use alphanumeric characters (and underscores) for identifiers, and to not use reserved keywords. If you follow those, you won't need identifier quoting.
If you do need to, because your dealing with a legacy database, Doctrine offers 2 solutions:
PS: For those who don't know: "identifier" does not refer to primary keys, but to the names of tables, columns, indexes, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With