Skip to content Skip to sidebar Skip to footer

Doctrine - Postgresql - Uppercase And Spaces In Table / Field Names

Having issues with Doctrine 2.3 and PostgreSQL with Spaces and Upper case Field / Table names Example: ( Yes we are working on migrating away from this ) SELECT 'Field Name' FROM '

Solution 1:

You may need to use backticks to let Doctrine know that it should be quoted: Quoting reserved words. E.g:

<?php/** @Column(name="`number`", type="integer") */private$number;

Solution 2:

Unfortunately the accepted answer won't work in the presented situation. The backticks will not work as every column in a doctrine query gets an alias by using the lower cased name with an appended identifier. This alias would have spaces in it and would therefore generate a sql error when passed to postgres.

The only way this could be corrected is in Doctrine itself when the query is generated.

update it seems this may have been corrected in the latest version of doctrine2. It now replaces non acceptable characters.

Post a Comment for "Doctrine - Postgresql - Uppercase And Spaces In Table / Field Names"