@@ -214,12 +214,15 @@ Optional parameters:
214214 - ``check ``: Adds a check constraint type to the column (might not
215215 be supported by all vendors).
216216
217- - **columnDefinition **: DDL SQL snippet that starts after the column
217+ - **columnDefinition **: Specify the DDL SQL snippet that starts after the column
218218 name and specifies the complete (non-portable!) column definition.
219219 This attribute allows to make use of advanced RMDBS features.
220- However you should make careful use of this feature and the
221- consequences. ``SchemaTool `` will not detect changes on the column correctly
222- anymore if you use ``columnDefinition ``.
220+ However, as this needs to be specified in the DDL native to the database,
221+ the resulting schema changes are no longer portable. If you specify a
222+ ``columnDefinition ``, the ``SchemaTool `` ignores all other attributes
223+ that are normally used to build the definition DDL. Changes to the
224+ ``columnDefinition `` are not detected, you will need to manually create a
225+ migration to apply changes.
223226
224227 Additionally you should remember that the ``type ``
225228 attribute still handles the conversion between PHP and Database
@@ -262,10 +265,11 @@ Examples:
262265 )]
263266 protected $loginCount;
264267
265- // MySQL example: full_name char(41) GENERATED ALWAYS AS (concat(firstname,' ',lastname)),
268+ // columnDefinition is raw SQL, not DQL. This example works for MySQL:
266269 #[Column(
267270 type: "string",
268271 name: "user_fullname",
272+ columnDefinition: "VARCHAR(255) GENERATED ALWAYS AS (concat(firstname,' ',lastname))",
269273 insertable: false,
270274 updatable: false
271275 )]
@@ -366,7 +370,7 @@ Optional parameters:
366370
367371- **type **: By default this is string.
368372- **length **: By default this is 255.
369- - **columnDefinition **: By default this is null the definition according to the type will be used. This option allows to override it.
373+ - **columnDefinition **: Allows to override how the column is generated. See the "columnDefinition" attribute on :ref: ` #[Column] < attrref_column >`
370374- **enumType **: By default this is `null `. Allows to map discriminatorColumn value to PHP enum
371375- **options **: See "options" attribute on :ref: `#[Column] <attrref_column >`.
372376
@@ -678,8 +682,10 @@ Optional parameters:
678682- **onDelete **: Cascade Action (Database-level)
679683- **columnDefinition **: DDL SQL snippet that starts after the column
680684 name and specifies the complete (non-portable!) column definition.
681- This attribute enables the use of advanced RMDBS features. Using
682- this attribute on ``#[JoinColumn] `` is necessary if you need slightly
685+ This attribute enables the use of advanced RMDBS features. Note that you
686+ need to reference columns by their database name (either explicitly set in
687+ the mapping or per the current :doc: `naming strategy <namingstrategy >`).
688+ Using this attribute on ``#[JoinColumn] `` is necessary if you need
683689 different column definitions for joining columns, for example
684690 regarding NULL/NOT NULL defaults. However by default a
685691 "columnDefinition" attribute on :ref: `#[Column] <attrref_column >` also sets
@@ -1134,7 +1140,7 @@ Marker attribute that defines a specified column as version attribute used in
11341140an :ref: `optimistic locking <transactions-and-concurrency_optimistic-locking >`
11351141scenario. It only works on :ref: `#[Column] <attrref_column >` attributes that have
11361142the type ``integer `` or ``datetime ``. Setting ``#[Version] `` on a property with
1137- :ref: `#[Id <attrref_id >` is not supported.
1143+ :ref: `#[Id] <attrref_id >` is not supported.
11381144
11391145Example:
11401146
0 commit comments