Use temporary negative IDs for rows created in a draft Changeset

This commit is contained in:
2018-08-11 16:19:32 +02:00
parent 7938519a64
commit 8efc31d820
12 changed files with 193 additions and 72 deletions
+10 -10
View File
@@ -125,27 +125,27 @@ class Column implements JsonSerializable, Arrayable
*
* @param object|array $obj
*/
public function __construct($obj, $allowEmptyName=false)
public function __construct($obj)
{
$b = objBag($obj);
if (!$allowEmptyName && (!$b->has('name') || $b->name == '')) {
throw new NotApplicableException('Missing name in column');
if (!$b->has('name') || $b->name == '') {
throw new SimpleValidationException('name', "Missing column name.");
}
if (!$b->has('type')) {
throw new NotApplicableException('Missing type in column');
if (!$b->has('type') || !in_array($b->type, self::colTypes)) {
throw new SimpleValidationException('type', "Missing or invalid column type.");
}
if ($b->name[0] == '_') { // would cause problems with selects (see: _id / GRID)
throw new NotApplicableException("Column name can't start with underscore.");
if ($b->name[0] == '_' || !preg_match(IDENTIFIER_PATTERN, $b->name)) {
throw new SimpleValidationException('name', "Column name can contain only letters, digits, and underscore, and must start with a letter.");
}
if (!in_array($b->type, self::colTypes)) {
throw new NotApplicableException("\"$b->type\" is not a valid column type.");
if (!$b->has('id') || $b->id[0] == '_') {
throw new SimpleValidationException('id', "Invalid or missing column ID");
}
$this->id = $b->get('id', null);
$this->id = $b->id;
$this->name = $b->name;
$this->type = $b->type;
$this->title = $b->title ?: $b->name;