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

sqlite: add setReturnArrays method to StatementSync #57542

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

gurgunday
Copy link
Contributor

Add a new StatementSync method setReturnArrays() that allows query results to be returned as arrays instead of objects. This is more efficient when column names are meaningless, auto-generated, or when working with hundreds of columns.

Fixes #57534

It's my first significant C++ PR, hopefully first of many :)

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/sqlite

Sorry, something went wrong.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels Mar 19, 2025
@gurgunday gurgunday changed the title sqlite: add setReturnArrays method to StatementSync for toggling arra… sqlite: add setReturnArrays method to StatementSync for toggling array row support Mar 19, 2025
@gurgunday gurgunday changed the title sqlite: add setReturnArrays method to StatementSync for toggling array row support sqlite: add setReturnArrays method to StatementSync Mar 19, 2025
@anonrig anonrig requested review from anonrig, cjihrig and jasnell March 19, 2025 01:30
@anonrig
Copy link
Member

anonrig commented Mar 19, 2025

Cc @nodejs/cpp-reviewers

Copy link

codecov bot commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 82.82828% with 17 lines in your changes missing coverage. Please review.

Project coverage is 90.23%. Comparing base (922ce9d) to head (77a7558).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 82.82% 2 Missing and 15 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57542      +/-   ##
==========================================
- Coverage   90.23%   90.23%   -0.01%     
==========================================
  Files         629      629              
  Lines      184939   185009      +70     
  Branches    36232    36244      +12     
==========================================
+ Hits       166885   166940      +55     
- Misses      11011    11016       +5     
- Partials     7043     7053      +10     
Files with missing lines Coverage Δ
src/node_sqlite.h 70.00% <ø> (ø)
src/node_sqlite.cc 78.66% <82.82%> (+0.18%) ⬆️

... and 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

t.assert.strictEqual(setup, undefined);

const query = db.prepare('SELECT key, val FROM data WHERE key = 1');
t.assert.deepStrictEqual(query.get(), { __proto__: null, key: 1, val: 'one' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth having dedicated test cases for get(), all(), and iterate() so that no one comes along in the future and refactors what might seem like an unnecessarily complex test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change the tests or just add a different suite for them?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests themselves look fine. I would just split them up.

@cjihrig
Copy link
Contributor

cjihrig commented Mar 19, 2025

Oh, and this needs documentation.

@gurgunday
Copy link
Contributor Author

gurgunday commented Mar 19, 2025

I'll add docs once the code is approved

@cjihrig
Copy link
Contributor

cjihrig commented Mar 20, 2025

I've opened #57569 to refactor the iterator implementation. I think we should land that PR before this one so that we can avoid exposing iterator internal state to JS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

node:sqlite to support retrieving rows as arrays instead of objects
5 participants