Skip to content

Commit

Permalink
correct parse nested arrays in the ndoejs driver
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgraul committed Aug 20, 2024
1 parent 05487a0 commit aaf33e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/nodejs/src/antlr4/CustomAgTypeListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class CustomAgTypeListener implements AgtypeListener, ParseTreeListener {
this.mergeArray()
}

exitArrayValue(): void {
this.mergeArray();
}

exitPair (ctx: PairContext): void {
const name = this.stripQuotes(ctx.STRING().text)

Expand Down
12 changes: 12 additions & 0 deletions drivers/nodejs/test/Agtype.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,16 @@ describe('Parsing', () => {
}))
})))
})

it("Nested Array Parsing", () => {
expect(
AGTypeParse(
'{"id": 1125899906842627, "label": "car", "properties": {"wheels": [ "a", ["d"] ]}}::vertex',
),
).toStrictEqual(new Map<string, any>(Object.entries({
id: 1125899906842627,
label: "car",
properties: new Map<string, any>(Object.entries({ wheels: ["a", ["d"]] })),
})));
});
})

0 comments on commit aaf33e3

Please sign in to comment.