Skip to content

Commit 5e70771

Browse files
committed
Move Exception for no data to batchExecute
This reduces the amount of code.
1 parent 8abf42b commit 5e70771

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

system/Database/BaseBuilder.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ protected function batchExecute(string $renderMethod, int $batchSize = 100)
17461746
{
17471747
if (empty($this->QBSet)) {
17481748
if ($this->db->DBDebug) {
1749-
throw new DatabaseException('No data availble to process.');
1749+
throw new DatabaseException(trim($renderMethod, '_') . '() has no data.');
17501750
}
17511751

17521752
return false; // @codeCoverageIgnore
@@ -1942,19 +1942,11 @@ protected function getValues(array $values): array
19421942
* @param array|string|null $set a dataset or select query
19431943
*
19441944
* @return false|int|string[] Number of rows inserted or FALSE on failure, SQL array when testMode
1945-
*
1946-
* @throws DatabaseException
19471945
*/
19481946
public function insertBatch($set = null, ?bool $escape = null, int $batchSize = 100)
19491947
{
19501948
if ($set !== null && $set !== []) {
19511949
$this->setData($set, $escape);
1952-
} elseif (empty($this->QBSet)) {
1953-
if ($this->db->DBDebug) {
1954-
throw new DatabaseException('insertBatch() has no data.');
1955-
}
1956-
1957-
return false; // @codeCoverageIgnore
19581950
}
19591951

19601952
return $this->batchExecute('_insertBatch', $batchSize);
@@ -2286,21 +2278,13 @@ protected function validateUpdate(): bool
22862278
* @param array|RawSql|string|null $constraints
22872279
*
22882280
* @return false|int|string[] Number of rows affected or FALSE on failure, SQL array when testMode
2289-
*
2290-
* @throws DatabaseException
22912281
*/
22922282
public function updateBatch($set = null, $constraints = null, int $batchSize = 100)
22932283
{
22942284
$this->onConstraint($constraints);
22952285

22962286
if ($set !== null && $set !== []) {
22972287
$this->setData($set, true);
2298-
} elseif (empty($this->QBSet)) {
2299-
if ($this->db->DBDebug) {
2300-
throw new DatabaseException('updateBatch() has no data.');
2301-
}
2302-
2303-
return false; // @codeCoverageIgnore
23042288
}
23052289

23062290
return $this->batchExecute('_updateBatch', $batchSize);

0 commit comments

Comments
 (0)