cmoog / vscode-sql-notebook

Open SQL files as VSCode Notebooks.
https://marketplace.visualstudio.com/items?itemName=cmoog.sqlnotebook
MIT License
120 stars 16 forks source link

SELECT number-labeled fields always display first in cell output #63

Open AJTonyKane opened 1 year ago

AJTonyKane commented 1 year ago

Certainly not a big deal...Just chalk the following up to an interesting case I thought you'd want to know about, where the field display order in notebook cell output deviates from the field order specified in an, admittedly non-typical, (MySQL) SELECT statement. For how I use your great extension, please know this does not amount to a hill of beans, but it came up while demonstrating a technique to create a "pivot table" via CASE statement this afternoon and figured you'd find it interesting, regardless. Best wishes, Tony

image

PS: My work-around for the subsequent demo was just changing field names from "2018", "2019", ... to "y2018", "y2019", ...

cmoog commented 1 year ago

Ah, interesting. Thanks for the detail here. I suspect the original order is lost when drivers return results as a column keyed JS object. To fix, we'd need to tweak the driver abstraction a bit, specifically the Row type would need to use a type that preserves column order https://github.com/cmoog/vscode-sql-notebook/blob/9602a251cf9d8431b21021c38edfda07475797fe/src/driver.ts#L27.

cmoog commented 1 year ago

Related to: https://github.com/cmoog/vscode-sql-notebook/issues/44