Skip to content

Commit f7e1593

Browse files
committed
fix: fix error in the InMemoryAdapter when using _empty operator on a field with value null
1 parent d97bc54 commit f7e1593

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/database/inmemory/js-generator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ register(TransformListQueryNode, (node, context) => {
430430
});
431431

432432
register(CountQueryNode, (node, context) => {
433-
return js`${processNode(node.listNode, context)}.length`;
433+
// in arangodb LENGTH(null) is 0, which can be useful sometimes, so let's just mimick the behavior
434+
return js`(${processNode(node.listNode, context)}?.length ?? 0)`;
434435
});
435436

436437
register(AggregationQueryNode, (node, context) => {

src/query-tree/lists.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ export class ConcatListsQueryNode extends QueryNode {
135135

136136
/**
137137
* A node that evaluates to the number of items in a list
138+
*
139+
* If the listNode evaluates to null, this node evaluates to zero
138140
*/
139141
export class CountQueryNode extends QueryNode {
140142
constructor(public readonly listNode: QueryNode) {

0 commit comments

Comments
 (0)