Skip to content

An empty string should be NULL #9678

@steefaan

Description

@steefaan

I faced this issue multiple times already. You can work around this issue but I think it should be a part of the ORM.

Table:

CREATE TABLE categories
(
    id INTEGER PRIMARY KEY NOT NULL,
    name VARCHAR(128) NOT NULL,
    meta_title VARCHAR(255)
);

ORM usage:

$entity = $this->Categories->newEntity($this->request->data);
$this->Categories->save($entity);

Current result:

id name meta_title
1 Test

Should be:

id name meta_title
1 Test NULL

As I mentioned above you can work around this behavior with Behaviors/Callbacks but I think this should be something which is handled directly inside the ORM. Saving an empty string inside a NULLable field isn't the proper usage of NULL.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions