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 support for custom functions #55985

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Nov 24, 2024

This commit adds support to node:sqlite for defining custom functions that can be invoked from SQL.

Fixes: #54349

@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 Nov 24, 2024
Copy link

codecov bot commented Nov 24, 2024

Codecov Report

Attention: Patch coverage is 87.15084% with 23 lines in your changes missing coverage. Please review.

Project coverage is 88.53%. Comparing base (64cc3b8) to head (e0435f0).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 87.15% 10 Missing and 13 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55985      +/-   ##
==========================================
- Coverage   88.54%   88.53%   -0.01%     
==========================================
  Files         657      657              
  Lines      189970   190149     +179     
  Branches    36482    36516      +34     
==========================================
+ Hits       168200   168348     +148     
- Misses      14979    14986       +7     
- Partials     6791     6815      +24     
Files with missing lines Coverage Δ
src/node_sqlite.h 70.00% <ø> (ø)
src/node_sqlite.cc 81.72% <87.15%> (+1.46%) ⬆️

... and 42 files with indirect coverage changes

@@ -132,6 +132,31 @@ This method allows one or more SQL statements to be executed without returning
any results. This method is useful when executing SQL statements read from a
file. This method is a wrapper around [`sqlite3_exec()`][].

### `database.function(name[, options], function)`
Copy link
Member

Choose a reason for hiding this comment

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

Two questions:

  • Why isn't the optional parameter the last one?
  • Why not call it createFunction? I think that makes the method more self-explanatory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The boring answer to both questions is "because that's how better-sqlite3 does it."

@cjihrig cjihrig closed this Nov 28, 2024
@cjihrig cjihrig reopened this Dec 9, 2024
@cjihrig cjihrig requested a review from himself65 December 9, 2024 18:01
@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 9, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 9, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Dec 10, 2024

src/node_sqlite.cc Outdated Show resolved Hide resolved
This commit adds support to node:sqlite for defining custom
functions that can be invoked from SQL.

Fixes: nodejs#54349
@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 11, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 11, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Dec 11, 2024

@cjihrig cjihrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed needs-ci PRs that need a full CI run. labels Dec 12, 2024
@cjihrig cjihrig requested a review from juanarbol December 12, 2024 15:03
@cjihrig cjihrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 12, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 12, 2024
@nodejs-github-bot nodejs-github-bot merged commit e5524ea into nodejs:main Dec 12, 2024
64 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in e5524ea

@cjihrig cjihrig deleted the sqlite-funcs branch December 12, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. sqlite Issues and PRs related to the SQLite subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sqlite: support sqlite3_create_function
5 participants