Why Doctrine2 doesn't automatically quote all SQL identifiers? -
doctrine manual says:
doctrine not quote identifiers automatically because leads more problems, solve.
what problems there quoting everything?
this quote comes older version of documentation, under basic mapping section. latest documentation doesn't include text anymore, but still true.
the limitations , known issues section of latest documentation sheds light on this:
for compatibility reasons between supported vendors , edge case problems doctrine 2 not automatic identifier quoting.
because of different quoting strategies used in different sql vendors, , way sql generated orm, quite hard come solution works cases. , it's harder maintain. might not impossible, doctrine team decided isn't worth time, , (perhaps more importantly) code complexity, try.
for hint on how complex sql generation is, browse through code in git repository.
it's common best practice use alphanumeric characters (and underscores) identifiers, , not use reserved keywords. if follow those, won't need identifier quoting.
if need to, because dealing legacy database, doctrine offers 2 solutions:
- manual quoting of identifiers, see basic mapping section.
- create database views follow best practices mentioned earlier.
ps: don't know: "identifier" not refer primary keys, names of tables, columns, indexes, etc.
Comments
Post a Comment