Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

The property order of the returned results has changed #1345

Closed
cooper-lzy opened this issue Aug 25, 2021 · 2 comments
Closed

The property order of the returned results has changed #1345

cooper-lzy opened this issue Aug 25, 2021 · 2 comments
Assignees

Comments

@cooper-lzy
Copy link

cooper-lzy commented Aug 25, 2021

In the schema, name comes first and age comes second, but the order in the returned result is wrong.

image

@whitewum
Copy link
Contributor

whitewum commented Aug 25, 2021

I checked opencypher specification and tck tests. And I also googled. Very few about this behavior.

# a tck case about add property
  Scenario: Overwrite values when using +=
    Given an empty graph
    And having executed:
      """
      CREATE (:X {name: 'A', name2: 'B'})
      """
    When executing query:
      """
      MATCH (n:X {name: 'A'})
      SET n += {name2: 'C'}
      RETURN n
      """
    Then the result should be, in any order:
      | n                             |
      | (:X {name: 'A', name2: 'C'}) |
    And the side effects should be:
      | +properties | 1 |
      | -properties | 1 |
  Scenario: `properties()` on a node
    Given an empty graph
    And having executed:
      """
      CREATE (n:Person {name: 'Popeye', level: 9001})
      """
    When executing query:
      """
      MATCH (p:Person)
      RETURN properties(p) AS m
      """
    Then the result should be, in any order:
      | m                             |
      | {name: 'Popeye', level: 9001} |
    And no side effects

name/level are not ordered in the alphabet, and {} is a map.

My suggestion is to clarify that: Properties have no guaranteed order in the doc.

@Sophie-Xie Sophie-Xie assigned CPWstatic and unassigned Sophie-Xie Aug 25, 2021
@CPWstatic
Copy link
Contributor

Thanks for taking care of this. The opencypher do not specify such a behavior, and i think there would not be one of such a specification. As said by @whitewum , we implement the map by an unordered map, the order would not be guaranteed. As far as i know, this is not a big problem for using. So i'll close this issue first unless we really meet any using problems in real world.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants