Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird behaviour with parent operator and array constructors #645

Open
mikhail-barg opened this issue Sep 7, 2023 · 0 comments
Open

Weird behaviour with parent operator and array constructors #645

mikhail-barg opened this issue Sep 7, 2023 · 0 comments

Comments

@mikhail-barg
Copy link

mikhail-barg commented Sep 7, 2023

While implementing the parent operator in my .Net Jsonata port, I stumbled upon the following test in the suite. It says that applying the query

Account.Order.Product.[`Product Name`, %.OrderID]

to the Invoice dataset should result in a flat array,

[
  "Bowler Hat",
  "order103",
  "Trilby hat",
  "order103",
  "Bowler Hat",
  "order104",
  "Cloak",
  "order104"
]

which indeed it does: https://try.jsonata.org/3IY-yuZkE

But why? Isn't the braces here are the explicit array constructor? Consider changing the query to one without parent operator, e.g.:

Account.Order.Product.[`Product Name`, SKU]

This would result in a nested array:

[
  [
    "Bowler Hat",
    "0406654608"
  ],
  [
    "Trilby hat",
    "0406634348"
  ],
  [
    "Bowler Hat",
    "040657863"
  ],
  [
    "Cloak",
    "0406654603"
  ]
]

Aren't the queries are just the same in the aspect of result structure?

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

No branches or pull requests

1 participant