age icon indicating copy to clipboard operation
age copied to clipboard

multidimensional arrays are not processed correctly by nodejs driver

Open elouizbadr opened this issue 2 years ago • 1 comments

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?

...
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?

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)

{
  "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

...
"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:

# 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)

elouizbadr avatar Dec 12 '23 19:12 elouizbadr

This issue is stale because it has been open 45 days with no activity. Remove "Abondoned" label or comment or this will be closed in 7 days.

github-actions[bot] avatar May 11 '24 00:05 github-actions[bot]