diff --git a/nur_src/b/io/SharedFile.php b/nur_src/b/io/SharedFile.php index 14fcbbc..3a22468 100644 --- a/nur_src/b/io/SharedFile.php +++ b/nur_src/b/io/SharedFile.php @@ -3,7 +3,6 @@ namespace nur\b\io; use nur\b\ICloseable; use nur\os; -use nur\path; /** * Class SharedFile: un fichier accédé par plusieurs processus en même temps. diff --git a/nur_src/b/params/Tparametrable1.php b/nur_src/b/params/Tparametrable1.php index d3b0bed..e51b4b5 100644 --- a/nur_src/b/params/Tparametrable1.php +++ b/nur_src/b/params/Tparametrable1.php @@ -1,8 +1,6 @@ two = new Two(); diff --git a/nur_tests/data/types/RawStringTypeTest.php b/nur_tests/data/types/RawStringTypeTest.php index 16aa591..96354f4 100644 --- a/nur_tests/data/types/RawStringTypeTest.php +++ b/nur_tests/data/types/RawStringTypeTest.php @@ -2,7 +2,6 @@ namespace nur\data\types; use nur\b\ValueException; -use nur\md; use nur\t\TestCase; class RawStringTypeTest extends TestCase { diff --git a/src/db/CapacitorStorage.php b/src/db/CapacitorStorage.php index 276a1b5..5be8f83 100644 --- a/src/db/CapacitorStorage.php +++ b/src/db/CapacitorStorage.php @@ -1,9 +1,7 @@ getSum("item", $item), - $this->unserialize($channel, $channel->getItemValues($item))); + $this->serialize($channel, $channel->getItemValues($item))); $prow = null; $rowIds = $this->getRowIds($channel, $row, $primaryKeys); if ($rowIds !== null) { diff --git a/src/db/sqlite/SqliteStorage.php b/src/db/sqlite/SqliteStorage.php index 6c69c4a..c54e749 100644 --- a/src/db/sqlite/SqliteStorage.php +++ b/src/db/sqlite/SqliteStorage.php @@ -66,7 +66,7 @@ class SqliteStorage extends CapacitorStorage { $now = date("Y-m-d H:i:s"); $row = cl::merge( $channel->getSum("item", $item), - $this->unserialize($channel, $channel->getItemValues($item))); + $this->serialize($channel, $channel->getItemValues($item))); $prow = null; $rowIds = $this->getRowIds($channel, $row, $primaryKeys); if ($rowIds !== null) { diff --git a/tests/db/sqlite/SqliteStorageTest.php b/tests/db/sqlite/SqliteStorageTest.php index 33fdac1..719528e 100644 --- a/tests/db/sqlite/SqliteStorageTest.php +++ b/tests/db/sqlite/SqliteStorageTest.php @@ -77,8 +77,8 @@ class SqliteStorageTest extends TestCase { }; $capacitor->each(["age" => [">", 10]], $setDone, ["++"]); $capacitor->each(["done" => 0], $setDone, null); - Txx(cl::all($capacitor->discharge(false))); + Txx(cl::all($capacitor->discharge(false))); $capacitor->close(); self::assertTrue(true); } @@ -110,4 +110,42 @@ class SqliteStorageTest extends TestCase { $capacitor->close(); self::assertTrue(true); } + + function testSum() { + $storage = new SqliteStorage(__DIR__.'/capacitor.db'); + $capacitor = new Capacitor($storage, new class extends CapacitorChannel { + const NAME = "sum"; + const COLUMN_DEFINITIONS = [ + "a__" => "varchar", + "b__" => "varchar", + "b__sum_" => self::SUM_DEFINITION, + ]; + + function getItemValues($item): ?array { + return [ + "a" => $item["a"], + "b" => $item["b"], + ]; + } + }); + + $capacitor->reset(); + $capacitor->charge(["a" => null, "b" => null]); + $capacitor->charge(["a" => "first", "b" => "second"]); + + Txx("=== all"); + /** @var Sqlite $sqlite */ + $sqlite = $capacitor->getStorage()->db(); + Txx(cl::all($sqlite->all([ + "select", + "from" => $capacitor->getChannel()->getTableName(), + ]))); + Txx("=== each"); + $capacitor->each(null, function ($item, $values) { + Txx($values); + }); + + $capacitor->close(); + self::assertTrue(true); + } } diff --git a/tests/php/content/contentTest.php b/tests/php/content/contentTest.php index e77816b..bf824ba 100644 --- a/tests/php/content/contentTest.php +++ b/tests/php/content/contentTest.php @@ -1,7 +1,6 @@