From c324715d8c8f650ce509f0cbc10a8d9505ee9094 Mon Sep 17 00:00:00 2001 From: dmitry krokhin Date: Mon, 6 Sep 2021 20:43:07 +0300 Subject: [PATCH] existence check using box func api --- src/Plugin/Procedure.php | 4 ++-- tests/UuidTest.php | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Plugin/Procedure.php b/src/Plugin/Procedure.php index 2e9331b..42c70cd 100644 --- a/src/Plugin/Procedure.php +++ b/src/Plugin/Procedure.php @@ -47,7 +47,7 @@ public function register($class) private function validatePresence(BaseProcedure $procedure) { $name = $procedure->getName(); - [$exists] = $this->mapper->getClient()->evaluate("return _G.$name ~= nil"); + [$exists] = $this->mapper->getClient()->call("box.schema.func.exists", $name); $instance = $this->mapper->findOrCreate('_procedure', [ 'name' => get_class($procedure) @@ -59,7 +59,7 @@ private function validatePresence(BaseProcedure $procedure) $script = " $name = function($params) $body end - box.schema.func.create('$name', {if_not_exists=true}) + box.schema.func.create('$name', { if_not_exists=true }) "; $this->mapper->getClient()->evaluate($script); $instance->hash = md5($body); diff --git a/tests/UuidTest.php b/tests/UuidTest.php index 38bca0b..f174479 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -21,7 +21,6 @@ public function testPrimaryKey() $this->clean($mapper); $mapper->getSchema()->createSpace('test_space', [ - 'is_sync' => true, 'engine' => 'memtx', 'properties' => [ 'id' => 'uuid', @@ -45,7 +44,6 @@ public function testBasics() $this->clean($mapper); $mapper->getSchema()->createSpace('test_space', [ - 'is_sync' => true, 'engine' => 'memtx', 'properties' => [ 'id' => 'unsigned',