else { $value =
$entity->
$field_name->
$column_name ?? NULL;
} if (!
empty($definition->
getSchema()['columns'
][$column_name]['serialize'
])) { $value =
serialize($value);
} // Do not set serial fields if we do not have a value. This supports all
// SQL database drivers.
// @see https://www.drupal.org/node/2279395
$value = SqlContentEntityStorageSchema::
castValue($definition->
getSchema()['columns'
][$column_name],
$value);
$empty_serial =
empty($value) &&
$this->
isColumnSerial($table_name,
$schema_name);
// The user entity is a very special case where the ID field is a serial
// but we need to insert a row with an ID of 0 to represent the
// anonymous user.
// @todo https://drupal.org/i/3222123 implement a generic fix for all
// entity types.
$user_zero =
$this->entityTypeId === 'user' &&
$value === 0;
if (!
$empty_serial ||
$user_zero) { $record->
$schema_name =
$value;
} } }