From: Auto-Claude Orchestrator Date: Tue, 24 Mar 2026 07:28:15 +0000 (+0000) Subject: feat(task-JIRA-ERP-33-20260324070448): Сбор данных по остаткам на день X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=453bf5b1468bc77c06ea0313029dcdb1410633ff;p=erp24_rep%2Fyii-erp24%2F.git feat(task-JIRA-ERP-33-20260324070448): Сбор данных по остаткам на день --- diff --git a/erp24/services/StockHistoryService.php b/erp24/services/StockHistoryService.php index e8fc063e..4a6430a9 100644 --- a/erp24/services/StockHistoryService.php +++ b/erp24/services/StockHistoryService.php @@ -212,9 +212,9 @@ class StockHistoryService $end = date('Y-m-d', strtotime($start . ' +1 month')); $suffix = str_replace('-', '_', $yearMonth); + // DDL не поддерживает bind params — используем интерполяцию (формат валидирован regex) $this->db->createCommand() - ->setSql("CREATE TABLE IF NOT EXISTS stock_history_{$suffix} PARTITION OF stock_history FOR VALUES FROM (:start) TO (:end)") - ->bindValues([':start' => $start, ':end' => $end]) + ->setSql("CREATE TABLE IF NOT EXISTS stock_history_{$suffix} PARTITION OF stock_history FOR VALUES FROM ('{$start}') TO ('{$end}')") ->execute(); } diff --git a/erp24/tests/unit/services/StockHistoryServiceTest.php b/erp24/tests/unit/services/StockHistoryServiceTest.php index 6ea0485c..56ca736c 100644 --- a/erp24/tests/unit/services/StockHistoryServiceTest.php +++ b/erp24/tests/unit/services/StockHistoryServiceTest.php @@ -245,19 +245,12 @@ class StockHistoryServiceTest extends Unit $db->method('createCommand')->willReturn($command); $executedSql = []; - $boundParams = []; $command->method('setSql')->willReturnCallback( function ($sql) use ($command, &$executedSql) { $executedSql[] = $sql; return $command; } ); - $command->method('bindValues')->willReturnCallback( - function ($values) use ($command, &$boundParams) { - $boundParams = array_merge($boundParams, $values); - return $command; - } - ); $command->method('execute')->willReturn(0); $service = new StockHistoryService($db); @@ -266,8 +259,8 @@ class StockHistoryServiceTest extends Unit $sql = implode(' ', $executedSql); $this->assertStringContainsString('PARTITION OF', $sql); $this->assertStringContainsString('stock_history_2026_04', $sql); - $this->assertEquals('2026-04-01', $boundParams[':start']); - $this->assertEquals('2026-05-01', $boundParams[':end']); + $this->assertStringContainsString('2026-04-01', $sql); + $this->assertStringContainsString('2026-05-01', $sql); } public function testCreatePartition_InvalidFormat_ThrowsException(): void @@ -294,7 +287,6 @@ class StockHistoryServiceTest extends Unit return $command; } ); - $command->method('bindValues')->willReturnSelf(); $command->method('execute')->willReturn(0); $service = new StockHistoryService($db);