This commit is contained in:
Yuri Kuznetsov
2024-12-03 11:38:22 +02:00
parent d088450745
commit 4c5791110c
6 changed files with 16 additions and 5 deletions

View File

@@ -33,6 +33,7 @@ use Espo\Core\Name\Field;
use Espo\Core\ORM\Repository\Option\SaveOption;
use Espo\Core\Utils\SystemUser;
use Espo\ORM\BaseEntity;
use Espo\ORM\Defs\Params\AttributeParam;
use Espo\ORM\Defs\Params\RelationParam;
use Espo\ORM\Entity;
use Espo\ORM\Relation\RelationsMap;
@@ -129,7 +130,7 @@ class Database extends RDBRepository
if (
$entity->isNew() &&
!$entity->has(self::ATTR_ID) &&
!$this->getAttributeParam($entity, self::ATTR_ID, 'autoincrement')
!$this->getAttributeParam($entity, self::ATTR_ID, AttributeParam::AUTOINCREMENT)
) {
$entity->set(self::ATTR_ID, $this->recordIdGenerator->generate());
}

View File

@@ -82,7 +82,7 @@ class Converter
'len' => AttributeParam::LEN, // @todo Revise.
FieldParam::NOT_NULL => AttributeParam::NOT_NULL,
'exportDisabled' => CoreAttributeParam::NOT_EXPORTABLE,
'autoincrement' => 'autoincrement',
FieldParam::AUTOINCREMENT => AttributeParam::AUTOINCREMENT,
'entity' => 'entity',
FieldParam::NOT_STORABLE => AttributeParam::NOT_STORABLE,
'link' => AttributeParam::RELATION,

View File

@@ -92,7 +92,7 @@ class AttributeDefs
*/
public function isAutoincrement(): bool
{
return $this->data['autoincrement'] ?? false;
return $this->data[AttributeParam::AUTOINCREMENT] ?? false;
}
/**

View File

@@ -59,6 +59,11 @@ class AttributeParam
*/
public const NOT_NULL = 'notNull';
/**
* Autoincrement.
*/
public const AUTOINCREMENT = 'autoincrement';
/**
* A default value.
*/

View File

@@ -49,6 +49,11 @@ class FieldParam
*/
public const DB_TYPE = 'dbType';
/**
* Autoincrement.
*/
public const AUTOINCREMENT = 'autoincrement';
/**
* A max length.
*/

View File

@@ -1308,7 +1308,7 @@ class BaseMapper implements RDBMapper
$this->queryExecutor->execute($query);
if ($this->getAttributeParam($entity, Attribute::ID, 'autoincrement')) {
if ($this->getAttributeParam($entity, Attribute::ID, AttributeParam::AUTOINCREMENT)) {
$this->setLastInsertIdWithinConnection($entity);
}
}
@@ -1564,7 +1564,7 @@ class BaseMapper implements RDBMapper
$onlyStorable &&
(
$this->getAttributeParam($entity, $attribute, AttributeParam::NOT_STORABLE) ||
$this->getAttributeParam($entity, $attribute, 'autoincrement') ||
$this->getAttributeParam($entity, $attribute, AttributeParam::AUTOINCREMENT) ||
(
$this->getAttributeParam($entity, $attribute, 'source') &&
$this->getAttributeParam($entity, $attribute, 'source') !== 'db'