Skip to content

Commit

Permalink
Merge branch 'master' of github.com:JoshuaWise/better-sqlite3
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaWise committed Apr 3, 2024
2 parents 3e629d9 + 080f863 commit 126bb57
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 27 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Keep GitHub Actions up to date with GitHub's Dependabot...
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
version: 2
updates:
- package-ecosystem: github-actions
directory: /
groups:
github-actions:
patterns:
- "*" # Group all Actions updates into a single larger pull request
schedule:
interval: weekly
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

env:
NODE_BUILD_CMD: npx --no-install prebuild -r node -t 18.0.0 -t 20.0.0 -t 21.0.0 --include-regex 'better_sqlite3.node$'
ELECTRON_BUILD_CMD: npx --no-install prebuild -r electron -t 16.0.0 -t 17.0.0 -t 18.0.0 -t 19.0.0 -t 20.0.0 -t 21.0.0 -t 22.0.0 -t 23.0.0 -t 24.0.0 -t 25.0.0 -t 26.0.0 -t 27.0.0 -t 28.0.0 --include-regex 'better_sqlite3.node$'
ELECTRON_BUILD_CMD: npx --no-install prebuild -r electron -t 16.0.0 -t 17.0.0 -t 18.0.0 -t 19.0.0 -t 20.0.0 -t 21.0.0 -t 22.0.0 -t 23.0.0 -t 24.0.0 -t 25.0.0 -t 26.0.0 -t 27.0.0 -t 28.0.0 -t 29.0.0 --include-regex 'better_sqlite3.node$'

jobs:
test:
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
needs: publish
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-qemu-action@v3
- run: |
docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform linux/${{ matrix.arch }} node:16-alpine -c "\
apk add build-base git python3 py3-setuptools --update-cache && \
Expand All @@ -135,7 +135,7 @@ jobs:
needs: publish
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-qemu-action@v3
- run: |
docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform linux/${{ matrix.arch }} node:16 -c "\
cd /tmp/project && \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
name: Bump to a new version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
fetch-depth: 0
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 16
- name: Configure user
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/update-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
ENV_YEAR: ${{ github.event.inputs.year }}
ENV_VERSION: ${{ github.event.inputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
fetch-depth: 0
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 16
- name: Create new update branch
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Download, compile and package SQLite
run: npm run download
- name: Push update branch
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update SQLite to version ${{ env.ENV_TRUE_VERSION }}
branch: sqlite-update-${{ env.ENV_VERSION }}
Expand Down
2 changes: 2 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ insertMany([

Transaction functions can be called from inside other transaction functions. When doing so, the inner transaction becomes a [savepoint](https://www.sqlite.org/lang_savepoint.html).

If an error is thrown inside of a nested transaction function, the nested transaction function will roll back to the state just before the savepoint and rethrow the error. If the error is not caught in the outer transaction function, this will cause the outer transaction function to roll back as well.

```js
const newExpense = db.prepare('INSERT INTO expenses (note, dollars) VALUES (?, ?)');

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "better-sqlite3",
"version": "9.4.3",
"version": "9.4.4",
"description": "The fastest and simplest library for SQLite3 in Node.js.",
"homepage": "http://github.com/WiseLibs/better-sqlite3",
"author": "Joshua Wise <joshuathomaswise@gmail.com>",
Expand All @@ -25,7 +25,7 @@
"fs-extra": "^11.1.1",
"mocha": "^10.2.0",
"nodemark": "^0.3.0",
"prebuild": "^12.0.0",
"prebuild": "^13.0.0",
"sqlite": "^5.0.1",
"sqlite3": "^5.1.6"
},
Expand Down
44 changes: 29 additions & 15 deletions src/better_sqlite3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,35 @@
//

#include "better_sqlite3.hpp"
#line 161 "./src/util/macros.lzz"
#line 153 "./src/util/macros.lzz"
void SetPrototypeGetter(
v8::Isolate* isolate,
v8::Local<v8::External> data,
v8::Local<v8::FunctionTemplate> recv,
const char* name,
v8::AccessorGetterCallback func
) {
v8::HandleScope scope(isolate);

#if defined NODE_MODULE_VERSION && NODE_MODULE_VERSION < 121
recv->InstanceTemplate()->SetAccessor(
InternalizedFromLatin1(isolate, name),
func,
0,
data,
v8::AccessControl::DEFAULT,
v8::PropertyAttribute::None
);
#else
recv->InstanceTemplate()->SetAccessor(
InternalizedFromLatin1(isolate, name),
func,
0,
data
);
#endif
}
#line 183 "./src/util/macros.lzz"
#ifndef V8_COMPRESS_POINTERS_IN_SHARED_CAGE
#define SAFE_NEW_BUFFER(env, data, length, finalizeCallback, finalizeHint) node::Buffer::New(env, data, length, finalizeCallback, finalizeHint)
#else
Expand Down Expand Up @@ -119,20 +147,6 @@ void SetPrototypeSymbolMethod (v8::Isolate * isolate, v8::Local <v8::External> d
v8::FunctionTemplate::New(isolate, func, data, v8::Signature::New(isolate, recv))
);
}
#line 142 "./src/util/macros.lzz"
void SetPrototypeGetter (v8::Isolate * isolate, v8::Local <v8::External> data, v8::Local <v8::FunctionTemplate> recv, char const * name, v8::AccessorGetterCallback func)
#line 148 "./src/util/macros.lzz"
{
v8::HandleScope scope(isolate);
recv->InstanceTemplate()->SetAccessor(
InternalizedFromLatin1(isolate, name),
func,
0,
data,
v8::AccessControl::DEFAULT,
v8::PropertyAttribute::None
);
}
#line 4 "./src/util/constants.lzz"
v8::Local <v8::String> CS::Code (v8::Isolate * isolate, int code)
#line 4 "./src/util/constants.lzz"
Expand Down
10 changes: 8 additions & 2 deletions src/better_sqlite3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
#include <node_buffer.h>
#line 31 "./src/util/macros.lzz"
template <class T> using CopyablePersistent = v8::Persistent<T, v8::CopyablePersistentTraits<T>>;
#line 144 "./src/util/macros.lzz"
void SetPrototypeGetter(
v8::Isolate* isolate,
v8::Local<v8::External> data,
v8::Local<v8::FunctionTemplate> recv,
const char* name,
v8::AccessorGetterCallback func
);
#line 36 "./src/util/binder.lzz"
static bool IsPlainObject(v8::Isolate* isolate, v8::Local<v8::Object> obj);
#define LZZ_INLINE inline
Expand Down Expand Up @@ -53,8 +61,6 @@ v8::Local <v8::FunctionTemplate> NewConstructorTemplate (v8::Isolate * isolate,
void SetPrototypeMethod (v8::Isolate * isolate, v8::Local <v8::External> data, v8::Local <v8::FunctionTemplate> recv, char const * name, v8::FunctionCallback func);
#line 129 "./src/util/macros.lzz"
void SetPrototypeSymbolMethod (v8::Isolate * isolate, v8::Local <v8::External> data, v8::Local <v8::FunctionTemplate> recv, v8::Local <v8::Symbol> symbol, v8::FunctionCallback func);
#line 142 "./src/util/macros.lzz"
void SetPrototypeGetter (v8::Isolate * isolate, v8::Local <v8::External> data, v8::Local <v8::FunctionTemplate> recv, char const * name, v8::AccessorGetterCallback func);
#line 1 "./src/util/constants.lzz"
class CS
{
Expand Down
22 changes: 22 additions & 0 deletions src/util/macros.lzz
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ void SetPrototypeSymbolMethod(
v8::FunctionTemplate::New(isolate, func, data, v8::Signature::New(isolate, recv))
);
}

#hdr
void SetPrototypeGetter(
v8::Isolate* isolate,
v8::Local<v8::External> data,
v8::Local<v8::FunctionTemplate> recv,
const char* name,
v8::AccessorGetterCallback func
);
#end
#src
void SetPrototypeGetter(
v8::Isolate* isolate,
v8::Local<v8::External> data,
Expand All @@ -147,6 +158,8 @@ void SetPrototypeGetter(
v8::AccessorGetterCallback func
) {
v8::HandleScope scope(isolate);

#if defined NODE_MODULE_VERSION && NODE_MODULE_VERSION < 121
recv->InstanceTemplate()->SetAccessor(
InternalizedFromLatin1(isolate, name),
func,
Expand All @@ -155,7 +168,16 @@ void SetPrototypeGetter(
v8::AccessControl::DEFAULT,
v8::PropertyAttribute::None
);
#else
recv->InstanceTemplate()->SetAccessor(
InternalizedFromLatin1(isolate, name),
func,
0,
data
);
#endif
}
#end

#src
#ifndef V8_COMPRESS_POINTERS_IN_SHARED_CAGE
Expand Down

0 comments on commit 126bb57

Please sign in to comment.