Skip to content

Allow to define expression default values MySQL 8.0.13 #5803

Open
@oleg-andreyev

Description

@oleg-andreyev

Feature Request

Q A
New Feature yes
RFC no

Summary

As of 8.0.13 it's possible to define DEFAULT as an expression:
https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html#data-type-defaults-explicit

Would be nice to allow such behavior.

Context (probably bug):

When we have JSON-type column and field in Entity is nullable=false, MySQL will put default value as literal null and when decoding JsonType will return NULL so my property must be nullable while it's undesirable behavior.

IMO best option how to handle this:

  • add new key expression to options
  • if expression===true do not enquote default value, but instead add parentheses

AR:

CREATE TABLE t1 (
  j JSON        DEFAULT 'JSON_ARRAY()'
);

ER:

CREATE TABLE t1 (
  j JSON        DEFAULT (JSON_ARRAY())
);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions