age icon indicating copy to clipboard operation
age copied to clipboard

Output serialization for strings seems to be incorrect at times

Open selendym opened this issue 2 years ago • 1 comments

Describe the bug

Output serialization for strings seems to be incorrect at times.

How are you accessing AGE (Command line, driver, etc.)?

With psql from the docker image. One container for the server and another one for the client.

What data setup do we need to do?

select * from ag_catalog.create_graph('g');

What is the necessary configuration info needed?

Just the docker image built from master branch.

What is the command that caused the error?

postgres=# SELECT * FROM ag_catalog.cypher('g', $$ with { id: 42, label: "label_name", properties: {} }::vertex as v return { a: "ASDF", v: v } $$) AS (c ag_catalog.agtype);
                                        c
---------------------------------------------------------------------------------
 {"a": "ASDF", "v": {"id": 42, "label": "label_name", "properties": {}}::vertex}
(1 row)

postgres=# SELECT * FROM ag_catalog.cypher('g', $$ with { id: 42, label: "label_name", properties: {} }::vertex as v return { z: "asdf", v: v } $$) AS (c ag_catalog.agtype);
                                      c
-----------------------------------------------------------------------------
 {"v": {"id": 42, "label": "label_name", "properties": {}}::vertex, "z": ""}
(1 row)

postgres=# SELECT * FROM ag_catalog.cypher('g', $$ with { id: 42, label: "label_name", properties: {} }::vertex as v return { a: "ASDF", z: "asdf", v: v } $$) AS (c ag_catalog.agtype);
                                              c
----------------------------------------------------------------------------------------------
 {"a": "ASDF", "v": {"id": 42, "label": "label_name", "properties": {}}::vertex, "z": " asd"}
(1 row)

The first query in the above listing is correct while the last two serialize "z" incorrectly. Note that "a" seems to be serialized correctly, so the order wrt the vertex "v" seems to be relevant here.

Similarly for edges:

postgres=# SELECT * FROM ag_catalog.cypher('g', $$ with { id: 42, start_id: 42, end_id: 42, label: "label_name", properties: {} }::edge as e return { a: "ASDF", e: e } $$) AS (c ag_catalog.agtype);
                                                      c
-------------------------------------------------------------------------------------------------------------
 {"a": "ASDF", "e": {"id": 42, "label": "label_name", "end_id": 42, "start_id": 42, "properties": {}}::edge}
(1 row)

postgres=# SELECT * FROM ag_catalog.cypher('g', $$ with { id: 42, start_id: 42, end_id: 42, label: "label_name", properties: {} }::edge as e return { z: "asdf", e: e } $$) AS (c ag_catalog.agtype);
                                                    c
---------------------------------------------------------------------------------------------------------
 {"e": {"id": 42, "label": "label_name", "end_id": 42, "start_id": 42, "properties": {}}::edge, "z": ""}
(1 row)

postgres=# SELECT * FROM ag_catalog.cypher('g', $$ with { id: 42, start_id: 42, end_id: 42, label: "label_name", properties: {} }::edge as e return { a: "ASDF", z: "asdf", e: e } $$) AS (c ag_catalog.agtype);
                                                            c
--------------------------------------------------------------------------------------------------------------------------
 {"a": "ASDF", "e": {"id": 42, "label": "label_name", "end_id": 42, "start_id": 42, "properties": {}}::edge, "z": " asd"}
(1 row)

Expected behavior

All of the strings should be serialized correctly.

Environment (please complete the following information):

  • env: docker
  • branch: master
  • commit: 5ded59f

selendym avatar Jul 26 '22 13:07 selendym

Interesting. There appears to be a positional component to this bug -

psql-11.5-5432-pgsql=# SELECT * FROM ag_catalog.cypher('g', $$ with { id: 42, label: "label_name", properties: {} }::vertex as v return { z: "asdf", v: v } $$) AS (c ag_catalog.agtype);
                                      c
-----------------------------------------------------------------------------
 {"v": {"id": 42, "label": "label_name", "properties": {}}::vertex, "z": ""}
(1 row)

psql-11.5-5432-pgsql=# SELECT * FROM ag_catalog.cypher('g', $$ with { id: 42, label: "label_name", properties: {} }::vertex as z return { v: "asdf", z: z } $$) AS (c ag_catalog.agtype);
                                        c
---------------------------------------------------------------------------------
 {"v": "asdf", "z": {"id": 42, "label": "label_name", "properties": {}}::vertex}
(1 row)
psql-11.5-5432-pgsql=# SELECT * FROM ag_catalog.cypher('g', $$ with { id: 42, label: "label_name", properties: {} }::vertex as v return { a: "ASDF", z: "asdf", v: v } $$) AS (c ag_catalog.agtype);
                                              c
----------------------------------------------------------------------------------------------
 {"a": "ASDF", "v": {"id": 42, "label": "label_name", "properties": {}}::vertex, "z": " asd"}
(1 row)

psql-11.5-5432-pgsql=# SELECT * FROM ag_catalog.cypher('g', $$ with { id: 42, label: "label_name", properties: {} }::vertex as z return { a: "ASDF", v: "asdf", z: z } $$) AS (c ag_catalog.agtype);
                                              c
----------------------------------------------------------------------------------------------
 {"a": "ASDF", "v": "asdf", "z": {"id": 42, "label": "label_name", "properties": {}}::vertex}
(1 row)

jrgemignani avatar Aug 01 '22 04:08 jrgemignani