So I have this Neo4j database and I made a query like this:
WITH something, collect(field1:aaaa,field2:bbbb) AS d
RETURN something, d
I wanted to get the results and show them with python-tabulate
by creating a subtable of the ‘d’ fields and then inserting it into a main table. However, when making the subtable I realized something.
In theory, each record should’ve looked something like this
{
something: "abcd"
d: [{
'field1':"abcd"
'field2':abcd
},
{
'field1':"abcd"
'field2':abcd
} ...etc
]
{
However, when I checked at the response in Python, it turns out that field1 and field2 are in the wrong order, like:
{
something: abcd
d: [{
'field2':"abcd"
'field1':abcd
},
{
'field2':"abcd"
'field1':abcd
} ...etc
]
{
This kinda matters because I wanted to use python-tabulate
to format the output, which should still be possible but I’d have to change the positions of field2 and field 1.
I used print() to look at the records to verify it’s not a thing of the tabulate library, which it’s not. The fields are already swapped from the response.
So my question is: Why is this happening? Does Cypher prioritize numbers over strings or something like that (I guess it’s worth mentioning, field 1 is a string and field 2 an int)? And if so, how do I prevent it?
Juan Pablo Aguilar Lobatón is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.