-
Notifications
You must be signed in to change notification settings - Fork 15
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
Convert row results to array based instead of object based #20
Comments
@MasterOdin I would like to take a crack at this. I see that the latest version of the mysql2 package supports this. I will check the others as well. Does this test case describe what you're looking for? Anything else I should keep in mind? Thoughts on how to do this without making this a breaking change for all clients?
|
I started some work on this in https://github.com/sqlectron/sqlectron-db-core/commits/array_results branch. That has a basic test case that demonstrates the desired behavior:
Essentially, the result object is shaped like:
The client (e.g. sqlectron-gui) would then be responsible for taking this info and generating the table to show to the user. I expect this to be a breaking change across all adapters except for sqlite3 as it does not support this yet (see TryGhost/node-sqlite3#1445). This being BC incompatible is fine as the current method is objectively wrong in that some queries return "wrong" results (duplicate columns clobber each other) as compared to running it directly against the DB. We may wish to do further disambiguation ourselves (e.g. parse the second instance of |
Many (all?) of the providers suffer from the inability to properly display duplicate column names as they return the data as an object:
where if you run a query that uses the same name for 2+ columns, then there'll be a collision and then it's undefined behavior what'll happen then.
Instead, we should always return the result-set as a flat array (e.g.
["test", "foo"]
) which we can then combine with thefields
field which is an array of column objects to determine the appropriate column information for displaying.The text was updated successfully, but these errors were encountered: