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

node:sqlite to support retrieving rows as arrays instead of objects #57534

Open
WillAvudim opened this issue Mar 18, 2025 · 1 comment · May be fixed by #57542
Open

node:sqlite to support retrieving rows as arrays instead of objects #57534

WillAvudim opened this issue Mar 18, 2025 · 1 comment · May be fixed by #57542
Labels
feature request Issues that request new features to be added to Node.js. sqlite Issues and PRs related to the SQLite subsystem.

Comments

@WillAvudim
Copy link

WillAvudim commented Mar 18, 2025

What is the problem this feature will solve?

Currently node:sqlite Session.* methods retrieve rows only as objects. In the application we write columns are auto-generated, their names are inherently meaningless, and their retrieval as an object would result in node_sqlite wasting CPU cycles to construct the object, and then I would have to run through reverse lookup loop over the keys of that unnecessarily constructed object to reproduce the original array of values as specified in the SELECT <expression1>, <expression2>, ... <expressionN> sequence.

In other words,

  1. I'll have to encode it as
    SELECT <expression1> AS c0, <expression2> AS c1, ... <expressionN> AS cN
  2. node:sqlite would have to construct and return an object { c0: <val>, c1: <val>, ..., cN: <val>}
  3. And then I'll have to reconstruct the array by interating over the object keys [c0, c1, ..., cN] to arrive at [val0, val1, ..., valN].

I'd like to request support of array row retrieval, just like it's already supported by all other sqlite APIs (like better-sqlite3, native WASM sqlite api-oo1, etc).
Object retrieval is unnecessary wasteful and impractical, especially when the number of retrieved columns (expressions) is measured in hundreds and their names are inherently meaningless.

What is the feature you are proposing to solve the problem?

Either add a parameter to request an array per row instead of object per row, or add additional methods that achieve this.
Other libraries tend to pass this in as a parameter.

What alternatives have you considered?

better-sqlite3, sqlite WASM api-oo1, even python libraries support this.

@WillAvudim WillAvudim added the feature request Issues that request new features to be added to Node.js. label Mar 18, 2025
@github-project-automation github-project-automation bot moved this to Awaiting Triage in Node.js feature requests Mar 18, 2025
@WillAvudim WillAvudim changed the title node:sqlite to support array retrieval node:sqlite to support retrieving rows as arrays instead of objects Mar 18, 2025
@tniessen tniessen added the sqlite Issues and PRs related to the SQLite subsystem. label Mar 18, 2025
@targos targos moved this from Awaiting Triage to Triaged in Node.js feature requests Mar 18, 2025
@targos
Copy link
Member

targos commented Mar 18, 2025

I think that would be very reasonable to add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. sqlite Issues and PRs related to the SQLite subsystem.
Projects
Development

Successfully merging a pull request may close this issue.

3 participants