apache / apache/age

multidimensional arrays are not processed correctly by nodejs driver

Open
#1,447 1 comment 0 reactions 0 assignees View on GitHub
bug driver nodejs override-stale
Dominant language
C
Stars
4.8k
Forks
523
Avg merge
1d 2h
Merged PRs (30d)
9

Description

**Describe the bug**
It seems that Nodejs driver is not able to support multidimensional arrays. Data stored inside PG database are correct but they get messed up once returned as a resultSet by `client.query()` statement in the javascript code.

**How are you accessing AGE (Command line, driver, etc.)?**
- [NodeJS driver] : `const resultSet = await client.query(query);`

**What data setup do we need to do?**
```pgsql
...
SELECT * from cypher('my_graph_name', $$
CREATE (a:Part {hello: 'world', my2dArr: [['a', 'b']]}),
$$) as (a agtype);
...
```

**What is the command that caused the error?**
```pgsql
SELECT * FROM cypher('my_graph_name', $$
MATCH (a:Part)
RETURN a
$$) as (a agtype);
```

Here is the `resultSet` object returned by `await client.query(query)`

```json
{
"command": "SELECT",
"rowCount": 1,
"oid": null,
"rows": [
{
"v": {
"id": 844424930131969,
"label": "Part",
"properties": {
"hello": [
[
"a",
"b"
],
"world"
]
}
}
}
],
"fields": [
{
"name": "v",
"tableID": 0,
"columnID": 0,
"dataTypeID": 17258,
"dataTypeSize": -1,
"dataTypeModifier": -1,
"format": "text"
}
],
"_parsers": [
null
],
"_types": {
"_types": {
"arrayParser": {},
"builtins": {
"BOOL": 16,
"BYTEA": 17,
"CHAR": 18,
"INT8": 20,
"INT2": 21,
"INT4": 23,
"REGPROC": 24,
"TEXT": 25,
"OID": 26,
"TID": 27,
"XID": 28,
"CID": 29,
"JSON": 114,
"XML": 142,
"PG_NODE_TREE": 194,
"SMGR": 210,
"PATH": 602,
"POLYGON": 604,
"CIDR": 650,
"FLOAT4": 700,
"FLOAT8": 701,
"ABSTIME": 702,
"RELTIME": 703,
"TINTERVAL": 704,
"CIRCLE": 718,
"MACADDR8": 774,
"MONEY": 790,
"MACADDR": 829,
"INET": 869,
"ACLITEM": 1033,
"BPCHAR": 1042,
"VARCHAR": 1043,
"DATE": 1082,
"TIME": 1083,
"TIMESTAMP": 1114,
"TIMESTAMPTZ": 1184,
"INTERVAL": 1186,
"TIMETZ": 1266,
"BIT": 1560,
"VARBIT": 1562,
"NUMERIC": 1700,
"REFCURSOR": 1790,
"REGPROCEDURE": 2202,
"REGOPER": 2203,
"REGOPERATOR": 2204,
"REGCLASS": 2205,
"REGTYPE": 2206,
"UUID": 2950,
"TXID_SNAPSHOT": 2970,
"PG_LSN": 3220,
"PG_NDISTINCT": 3361,
"PG_DEPENDENCIES": 3402,
"TSVECTOR": 3614,
"TSQUERY": 3615,
"GTSVECTOR": 3642,
"REGCONFIG": 3734,
"REGDICTIONARY": 3769,
"JSONB": 3802,
"REGNAMESPACE": 4089,
"REGROLE": 4096
}
},
"text": {},
"binary": {}
},
"RowCtor": null,
"rowAsArray": false,
"_prebuiltEmptyResultObject": {
"v": null
}
}
```

**Expected behavior**

The `rows` section of the MATCH resultSet above should've returned the node properties as given in the CREATE query

```json
...
"rows": [
{
"v": {
"id": 844424930131969,
"label": "Part",
"properties": {
"hello": "world",
"my2dArr": [[
"a",
"b"
]]
}
}
}
],
```

**Environment (please complete the following information):**
- Version: [apache/age:PG14_latest]

**Additional context**

Data stored correctly by AGE as shown by this query from psql:

```psql
# SELECT * FROM cypher('my_graph_name', $$ MATCH (v:Part) RETURN v $$) as (v agtype);
v
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------
{"id": 844424930131969, "label": "Part", "properties": {"hello": "world", "my2dArr": [["a", "b"]]}}::vertex
(1 row)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.