Skip to content

Commit

Permalink
existence check using box func api
Browse files Browse the repository at this point in the history
  • Loading branch information
nekufa committed Sep 6, 2021
1 parent d4e8edb commit c324715
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Plugin/Procedure.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions tests/UuidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public function testPrimaryKey()
$this->clean($mapper);

$mapper->getSchema()->createSpace('test_space', [
'is_sync' => true,
'engine' => 'memtx',
'properties' => [
'id' => 'uuid',
Expand All @@ -45,7 +44,6 @@ public function testBasics()
$this->clean($mapper);

$mapper->getSchema()->createSpace('test_space', [
'is_sync' => true,
'engine' => 'memtx',
'properties' => [
'id' => 'unsigned',
Expand Down

0 comments on commit c324715

Please sign in to comment.