-Empty dataset can not be saved
This commit is contained in:
parent
11e436236c
commit
36162c6486
@ -10,7 +10,7 @@ class Values extends Fragment {
|
||||
|
||||
public ? int $fieldCount = null;
|
||||
|
||||
public array $rows;
|
||||
public array $rows = [];
|
||||
|
||||
public QueryBuilderInterface $queryBuilder;
|
||||
|
||||
@ -21,6 +21,10 @@ class Values extends Fragment {
|
||||
|
||||
public function add(array $row) : self
|
||||
{
|
||||
if ($row === []) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if ($this->fieldCount === null) {
|
||||
$this->fieldCount = count($row);
|
||||
}
|
||||
|
||||
@ -199,6 +199,10 @@ class Repository implements RepositoryInterface
|
||||
if ( $replace || ! $entity->isLoaded() ) {
|
||||
# $dataset = array_filter($dataset, fn($item, $field) => ! ($this->entityResolver->searchFieldAnnotation($field, new Field, false)->readonly ?? false), \ARRAY_FILTER_USE_BOTH);
|
||||
|
||||
if (empty($dataset)) {
|
||||
throw new \InvalidArgumentException("Unable to add a new row from an empty dataset.");
|
||||
}
|
||||
|
||||
$pdoObject = $this->insertSqlQuery($fieldsAndValue ?? $dataset, $replace)->runInsertQuery();
|
||||
|
||||
if ( null !== $primaryKeyDefinition ) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user