From 36654b184e824ff89c8df08914fd78bd7afd452f Mon Sep 17 00:00:00 2001 From: matcracker Date: Tue, 30 Mar 2021 19:56:33 +0200 Subject: [PATCH 1/2] Fixed missing import of Generator class --- libasynql/src/poggit/libasynql/base/DataConnectorImpl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libasynql/src/poggit/libasynql/base/DataConnectorImpl.php b/libasynql/src/poggit/libasynql/base/DataConnectorImpl.php index 86cb5f75..c3ce7a27 100644 --- a/libasynql/src/poggit/libasynql/base/DataConnectorImpl.php +++ b/libasynql/src/poggit/libasynql/base/DataConnectorImpl.php @@ -24,6 +24,7 @@ use Error; use Exception; +use Generator; use InvalidArgumentException; use pocketmine\plugin\Plugin; use pocketmine\utils\Terminal; From c002d665ede629f8430294d0f644a5c19225c638 Mon Sep 17 00:00:00 2001 From: matcracker Date: Tue, 30 Mar 2021 19:56:39 +0200 Subject: [PATCH 2/2] Direct return the yield value instead of assignment --- .../libasynql/base/DataConnectorImpl.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libasynql/src/poggit/libasynql/base/DataConnectorImpl.php b/libasynql/src/poggit/libasynql/base/DataConnectorImpl.php index c3ce7a27..636d4e76 100644 --- a/libasynql/src/poggit/libasynql/base/DataConnectorImpl.php +++ b/libasynql/src/poggit/libasynql/base/DataConnectorImpl.php @@ -152,8 +152,8 @@ public function asyncChange(string $queryName, array $args = []) : Generator{ $onSuccess = yield Await::RESOLVE; $onError = yield Await::REJECT; $this->executeChange($queryName, $args, $onSuccess, $onError); - $affectedRows = yield Await::ONCE; - return $affectedRows; + //Return $affectedRows + return yield Await::ONCE; } public function executeInsert(string $queryName, array $args = [], ?callable $onInserted = null, ?callable $onError = null) : void{ @@ -178,8 +178,8 @@ public function asyncInsert(string $queryName, array $args = []) : Generator{ $this->executeInsert($queryName, $args, static function(int $insertId, int $affectedRows) use($onSuccess) : void{ $onSuccess([$insertId, $affectedRows]); }, $onError); - $affectedRows = yield Await::ONCE; - return $affectedRows; + //Return $affectedRows + return yield Await::ONCE; } public function executeSelect(string $queryName, array $args = [], ?callable $onSelect = null, ?callable $onError = null) : void{ @@ -201,11 +201,11 @@ public function executeSelectRaw(string $query, array $args = [], ?callable $onS public function asyncSelect(string $queryName, array $args = []) : Generator{ $onSuccess = yield Await::RESOLVE; $onError = yield Await::REJECT; - $this->executeSelect($queryName, $args, static function(array $rows, SqlColumnInfo $columns) use($onSuccess) : void{ + $this->executeSelect($queryName, $args, static function(array $rows) use($onSuccess) : void{ $onSuccess($rows); }, $onError); - $rows = yield Await::ONCE; - return $rows; + //Return $rows + return yield Await::ONCE; } public function asyncSelectWithInfo(string $queryName, array $args = []) : Generator{ @@ -214,8 +214,8 @@ public function asyncSelectWithInfo(string $queryName, array $args = []) : Gener $this->executeInsert($queryName, $args, static function(array $rows, SqlColumnInfo $columns) use($onSuccess) : void{ $onSuccess([$rows, $columns]); }, $onError); - $rows = yield Await::ONCE; - return $rows; + //Return $rows + return yield Await::ONCE; } private function executeImpl(string $queryName, array $args, int $mode, callable $handler, ?callable $onError) : void{