Orm: DDC-3226: Unable to escape field names in YAML notation

Created on 24 Jul 2014  路  4Comments  路  Source: doctrine/orm

Jira issue originally created by user kix:

As in DDC-1759, I wanted to use some reserved words as my field names (same case: MySQL-backed key-value storage).
DDC-1759 was resolved by escaping the column names in field annotations. However, I'm using YAML files to store my mappings, and I couldn't find a way to set up an escaped field name there.

Bug

Most helpful comment

I got this error, and the first result I found on google was this thread. A working example under YAML to make a reserved word as column name:

Model\Entity:
    type: entity
    table: core_entity
    fields:
        order:
            type: smallint
            column: `order`

The last line did the trick (order being a reserved word in MySQL)

All 4 comments

Comment created by @ocramius:

Escaping fields is done via the backtick symbol ``` in column mappings. This is not driver-specific, but applies to all mappings.

Issue was closed with resolution "Invalid"

I got this error, and the first result I found on google was this thread. A working example under YAML to make a reserved word as column name:

Model\Entity:
    type: entity
    table: core_entity
    fields:
        order:
            type: smallint
            column: `order`

The last line did the trick (order being a reserved word in MySQL)

This is not documented anywhere (as far as I can tell) and in PHP annotations, the override is @Column( **name** ="order") instead of **column**: `order` in yaml, making this even harder to figure out.

Was this page helpful?
0 / 5 - 0 ratings