mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 15:06:06 +00:00
Force empty array DB default for array fields
This commit is contained in:
@@ -49,6 +49,7 @@ class MysqlColumnPreparator implements ColumnPreparator
|
||||
private const PARAM_PRECISION = 'precision';
|
||||
private const PARAM_SCALE = 'scale';
|
||||
private const PARAM_BINARY = 'binary';
|
||||
private const string PARAM_STORE_ARRAY_VALUES = 'storeArrayValues';
|
||||
|
||||
public const TYPE_MYSQL = 'MySQL';
|
||||
public const TYPE_MARIADB = 'MariaDB';
|
||||
@@ -142,6 +143,10 @@ class MysqlColumnPreparator implements ColumnPreparator
|
||||
case Entity::JSON_ARRAY:
|
||||
$default = is_array($default) ? json_encode($default) : null;
|
||||
|
||||
if ($defs->getParam(self::PARAM_STORE_ARRAY_VALUES)) {
|
||||
$default = json_encode([]);
|
||||
}
|
||||
|
||||
$column = $column->withDefault($default);
|
||||
|
||||
break;
|
||||
|
||||
@@ -45,6 +45,7 @@ class PostgresqlColumnPreparator implements ColumnPreparator
|
||||
private const PARAM_AUTOINCREMENT = 'autoincrement';
|
||||
private const PARAM_PRECISION = 'precision';
|
||||
private const PARAM_SCALE = 'scale';
|
||||
private const string PARAM_STORE_ARRAY_VALUES = 'storeArrayValues';
|
||||
|
||||
/** @var string[] */
|
||||
private array $textTypeList = [
|
||||
@@ -120,6 +121,10 @@ class PostgresqlColumnPreparator implements ColumnPreparator
|
||||
case Entity::JSON_ARRAY:
|
||||
$default = is_array($default) ? json_encode($default) : null;
|
||||
|
||||
if ($defs->getParam(self::PARAM_STORE_ARRAY_VALUES)) {
|
||||
$default = json_encode([]);
|
||||
}
|
||||
|
||||
$column = $column->withDefault($default);
|
||||
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user