-Empty dataset can not be saved

This commit is contained in:
Dave M. 2026-01-05 12:37:55 +00:00
parent 11e436236c
commit 36162c6486
2 changed files with 9 additions and 1 deletions

View File

@ -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);
}

View File

@ -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 ) {