]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
feat(task-JIRA-ERP-33-20260324070448): Сбор данных по остаткам на день
authorAuto-Claude Orchestrator <orchestrator@auto-claude.local>
Tue, 24 Mar 2026 07:28:15 +0000 (07:28 +0000)
committerAuto-Claude Orchestrator <orchestrator@auto-claude.local>
Tue, 24 Mar 2026 07:28:15 +0000 (07:28 +0000)
erp24/services/StockHistoryService.php
erp24/tests/unit/services/StockHistoryServiceTest.php

index e8fc063e4281b3080e23bbed8c789abd1edfff2e..4a6430a950db2a5f28de4056efad9e4e135bdea5 100644 (file)
@@ -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();
     }
 
index 6ea0485c78eab8b6377d5e8febafa3b101d612bd..56ca736ca79f1070efab907ba02a9100a0d7b4f1 100644 (file)
@@ -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);