DBAL-954: Custom QuoteStrategy doesn't work when creating new schema #2199

doctrinebot opened this Issue Jul 30, 2014 · 1 comment

3 participants


Jira issue originally created by user lyzkov:

Implementing custom quote strategy:

class SingleQuoteStrategy extends DefaultQuoteStrategy implements QuoteStrategy
    public function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform $platform)
        return isset($class->fieldMappings[$fieldName]['quoted'])
            ? $platform->quoteSingleIdentifier($class->fieldMappings[$fieldName]['columnName'])
            : $class->fieldMappings[$fieldName]['columnName'];

doesn't work when a new schema is created.

The problem is that in class file mapping I have column that has dot in its name escaped with back single quotes:

<field name="anuncianteId*delete" type="integer" column="`anunciante*id.delete`" nullable="true"/>

My custom quote strategy is necessary to force Doctrine to respect that. Otherwise Doctrine treats it as: namespace.name.

If I already have table with that column in my database update schema tool doesn't complains, the problem occurs only when I try to create new schema.

The error in resulting SQL Statement:
(SQLSTATE[HY000]: General error: 1 near ".": syntax error' while executing DDL: CREATE TABLE account ( (...) "anunciante_id"."delete" INTEGER DEFAULT NULL, (...) )

@doctrinebot doctrinebot added the Bug label Dec 7, 2015
@beberlei beberlei was assigned by doctrinebot Dec 7, 2015
@beberlei beberlei was unassigned by deeky666 Jan 6, 2016
Doctrine member

Yeah I suppose this is due to Doctrine\DBAL\Schema\AbstractAsset not supporting such scenarios at the moment. It looks for a . to identify a namespaced identifier, ignoring the presence of quote characters. This is due to the simplicity of that class, not doing a robust and exact parsing of the given identifier. This could be improved indeed but might eventually affect performance...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment