Skip to content

Commit

Permalink
Fixed passing of references and registered variables to the document …
Browse files Browse the repository at this point in the history
…function
  • Loading branch information
LaravelFreelancerNL committed May 16, 2022
1 parent bc82109 commit 9f988c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/QueryBuilder.php
Expand Up @@ -164,7 +164,6 @@ public function registerVariable(
if (is_string($variableName)) {
$variableName = [$variableName => $variableName];
}

if (is_array($variableName)) {
$this->variables = array_unique(array_merge($this->variables, $variableName));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/NormalizesMiscellaneousFunctions.php
Expand Up @@ -44,7 +44,7 @@ protected function normalizeDocument(QueryBuilder $queryBuilder): void
}
$this->parameters['id'] = $queryBuilder->normalizeArgument(
$this->parameters['id'],
['Id', 'Key', 'Query', 'List', 'Bind']
['RegisteredVariable', 'Reference', 'Id', 'Key', 'Query', 'List', 'Bind']
);
}

Expand Down
10 changes: 10 additions & 0 deletions tests/Unit/AQL/MiscellaneousFunctionsTest.php
Expand Up @@ -65,6 +65,16 @@ public function testDocumentFunction()
$qb = new QueryBuilder();
$qb->return($qb->document(['users/john', 'users/amy']));
self::assertEquals('RETURN DOCUMENT(["users/john","users/amy"])', $qb->get()->query);


$qb = new QueryBuilder();
$qb->let('variable', 'collection/a')
->return($qb->document("pages", 'variable'));

self::assertEquals(
'LET variable = @' . $qb->getQueryId() . '_1 RETURN DOCUMENT(pages, variable)',
$qb->get()->query
);
}

public function testCurrentDatabase()
Expand Down

0 comments on commit 9f988c4

Please sign in to comment.