Closed FylmTM closed 9 years ago
Update.
// driver/src/main/java/org/neo4j/driver/internal/connector/socket/SocketClient.java:111
while ( handler.receivedresponses() < pendingmessages.size() )
{
reader.read( handler );
}
pendingMessages
variables has two messages for select query:
[
[RUN "MATCH (n) RETURN n as n" {}],
[PULL_ALL]
]
First one - just puts field names into collector (correctly)
Second one - puts records into collector body, and then overrides fieldNames in collector, in org.neo4j.driver.internal.connector.socket.SocketResponseHandler#handleSuccessMessage
method with empty array.
Hey mate!
This is actually by design - we only return the field names once, in the SUCCESS
message sent for the RUN
command. This is to avoid redundancy on the wire - and to highlight that the field names is metadata associated with the RUN
command. The SUCCESS
message sent in response to a RUN
constitutes query metadata.
If you want to know the field names, simply store the result of the SUCCESS
message returned from the RUN
.
Also note; these APIs are internal, not part of the API of the driver.
Eg: This is by design, closing this as a wontfix
/j
We create 3 nodes in database:
Then we try to execute select query:
Expected: 3 nodes returned, under
n
key What we have: result contains 3 nodes, butfieldsNames
property is empty.Debug result:
Sync phase (1)
ResultBuilder - stateful container. Field names are populated in
fieldNames
method. This method is called whensuccess
message received:When we execute query we have this handling order:
So, on first
success
we correctly receive fieldNames:But, when second
success
is received we callfieldNames()
onResultBuilder
with no names. So, secondsuccess
message doesn't containt any names. And this message overridesfieldNames
from firstsuccess
message.Build phase (2)
Now in builder state we have valid
body
with 3 records. ButfieldNames
is empty.I am not sure where I should look to fix this problem. If you can point me to correct place in the code, I can try to fix this problem and open pull request.