Skip to content

Commit 9f988c4

Browse files
Fixed passing of references and registered variables to the document function
1 parent bc82109 commit 9f988c4

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/QueryBuilder.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ public function registerVariable(
164164
if (is_string($variableName)) {
165165
$variableName = [$variableName => $variableName];
166166
}
167-
168167
if (is_array($variableName)) {
169168
$this->variables = array_unique(array_merge($this->variables, $variableName));
170169
}

src/Traits/NormalizesMiscellaneousFunctions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function normalizeDocument(QueryBuilder $queryBuilder): void
4444
}
4545
$this->parameters['id'] = $queryBuilder->normalizeArgument(
4646
$this->parameters['id'],
47-
['Id', 'Key', 'Query', 'List', 'Bind']
47+
['RegisteredVariable', 'Reference', 'Id', 'Key', 'Query', 'List', 'Bind']
4848
);
4949
}
5050

tests/Unit/AQL/MiscellaneousFunctionsTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ public function testDocumentFunction()
6565
$qb = new QueryBuilder();
6666
$qb->return($qb->document(['users/john', 'users/amy']));
6767
self::assertEquals('RETURN DOCUMENT(["users/john","users/amy"])', $qb->get()->query);
68+
69+
70+
$qb = new QueryBuilder();
71+
$qb->let('variable', 'collection/a')
72+
->return($qb->document("pages", 'variable'));
73+
74+
self::assertEquals(
75+
'LET variable = @' . $qb->getQueryId() . '_1 RETURN DOCUMENT(pages, variable)',
76+
$qb->get()->query
77+
);
6878
}
6979

7080
public function testCurrentDatabase()

0 commit comments

Comments
 (0)