Open chekuchose opened 2 years ago
This is a sharp observation. Those lines try to remove columns that contains None
value, but the side effect is that it may unintentionally change column order.
For kvm-ubuntu1804Gen2-NoneDisk
, only Name
, Location
, ResouceGroup
are preserved in new_entry
, causing Disk
to be moved to the last column.
There doesn't seem to be a simple fix. I will revisit this topic when time permits.
Problem
When json value has "null", knack in Azure CLI unintentionally changes column order regardless of specifying order of the columns by JMESPath.
Reproduce steps
Prepare some json data including null value in member like this
Run JMESPath query using --query option:
As the above --query result shows different order of columns regardless the query specifies "Name, Location, Disk, ResourceGroup" orders.
In my view
The behavior seems to change the result when the first record includes "null" value. If the first record has no "null" value, the result expectly shows according to --query order:
This null value behavior seems to be caused by the following line: knack/output.py at d407b81d451d36c6ca1baeb3cd067a3f1275cb85 · microsoft/knack
Request
Could you enhance/fix this behavior? We want you to show the same result whether the first record includes null value or not.