ikleiman
ikleiman

Reputation: 545

Doctrine ORM Custom Column Collation

I'm trying to set custom column collation as in Doctrine documentation:

using

@ORM\Column(name="body", type="string", length=140, options={"customSchemaOptions"={"collate"="utf8mb4_unicode_ci"}})

but when I update the schema it always goes back to utf8_unicode_ci (when I set it manually for example). Any ideas?

Upvotes: 17

Views: 12828

Answers (1)

Niels Keurentjes
Niels Keurentjes

Reputation: 41958

This has been added by now if you (or someone else) still need, see column annotation docs

Example: In annotations:

/**
 * @var string
 *
 * @ORM\Column(type="string", length=64, nullable=false, options={"collation":"utf8_bin"})
 */
private $code;

In Yaml:

Your\Nice\Entity:
    fields:
        code:
            type: string
            length: 64
            options:
                collation: utf8_bin   # Although the recommendation is the utf8mb4* set now.

This is supported by all common database drivers now.

Upvotes: 32

Related Questions