Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: TryGhost/node-sqlite3
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.1.6
Choose a base ref
...
head repository: TryGhost/node-sqlite3
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on May 29, 2023

  1. Updated bundled SQLite to v3.42.0

    refs https://www.sqlite.org/releaselog/3_42_0.html
    
    - sha3-256sum: `643898e9fcc8f6069bcd47b0e6057221c1ed17bbee57da20d2752c79d91274e8`
    daniellockyer committed May 29, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    22ac6cc View commit details
  2. - Extensively utilized automatic type deduction for improved code rea…

    …dability
    
    - Implemented RAII to ensure resource safety and exception safety
    - Leveraged range-based for loops for cleaner and more efficient iteration
    - Addressed and resolved all project-related warnings for enhanced code quality
    zenon8adams authored and daniellockyer committed May 29, 2023

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    cdf78bf View commit details
  3. Removed unused variable

    daniellockyer committed May 29, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    dfbe3ba View commit details

Commits on Oct 4, 2023

  1. Copy the full SHA
    44e570a View commit details

Commits on Dec 18, 2023

  1. Copy the full SHA
    7552aa0 View commit details

Commits on Dec 22, 2023

  1. Revert "Update actions/setup-node action to v4"

    This reverts commit 7552aa0.
    daniellockyer committed Dec 22, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    3aeb548 View commit details
  2. Updated bundled SQLite to v3.44.2

    refs https://www.sqlite.org/releaselog/3_44_2.html
    
    - sha3-256sum: `6c427f0547e2f7babe636b748dd5d5a1f2f31601adadef7e2805e7d1f7171861`
    daniellockyer committed Dec 22, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    8d78ce7 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    56ad63c View commit details
  4. Removed useless try-catch

    - this doesn't do anything because we just rethrow the error
    daniellockyer committed Dec 22, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    10f38fe View commit details

Commits on Dec 23, 2023

  1. Installed setuptools in CI workflow

    - Python 3.12 no longer ships with this and GHA CI has updated to 3.12,
      which breaks our build scripts
    - this should fix that until we can update node-gyp
    daniellockyer committed Dec 23, 2023
    Copy the full SHA
    080c0d1 View commit details
  2. Condensed npm scripts

    - merged pretest and test
    - removed `pack` as it is not needed
    daniellockyer committed Dec 23, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    93ed997 View commit details

Commits on Dec 24, 2023

  1. Added CI step to check semver compatibility

    - right now our way to check semver compatibility is to run the tests on
      every version
    - this is really inefficient as it results in a lot of CI jobs that we
      don't need
    - this should run a CI job that ensures the minimum version we accept is
      Node 10.12.0
    daniellockyer committed Dec 24, 2023
    Copy the full SHA
    cff38a3 View commit details
  2. Reworked CI versions

    - bumped building on Node 16 to Node 18
    - removed all matrix executions apart from Node 18
    daniellockyer committed Dec 24, 2023
    Copy the full SHA
    9e8b2ee View commit details
  3. Copy the full SHA
    c74f267 View commit details
  4. Copy the full SHA
    8482aaf View commit details
  5. Copy the full SHA
    83e282d View commit details
  6. Copy the full SHA
    7674271 View commit details
  7. Copy the full SHA
    a2cee71 View commit details
  8. Replaced @mapbox/node-pre-gyp in favor of prebuild + `prebuild-in…

    …stall`
    
    fixes #1641
    fixes #1721
    fixes #1714
    fixes #1713
    fixes #1700
    fixes #1704
    
    - `@mapbox/node-pre-gyp` is effectively unmaintained [1] as has a few bugs
      which our users keep running into
    - it seems the prebuilt binary world has moved in favor of prebuild +
      it's various other forms
    - one option would be to use prebuildify to bundle all binaries into the
      package, but that's a step too far removed from the current situation
      for now
    - instead, we can use prebuild-install to download the binaries, and
      `prebuild` to build + upload the binaries
    - this means we can remove node-pre-gyp and fix a bunch of issues!
    - eventually, we could start providing electron prebuilt binaries too
    
    [1]: mapbox/node-pre-gyp#657
    daniellockyer committed Dec 24, 2023
    Copy the full SHA
    605c7f9 View commit details
  9. Updated list of supported targets

    - switched to just providing a list of platform + arch instead of the
      full formatted string
    daniellockyer committed Dec 24, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    2595304 View commit details
  10. Extracted common Node-API queuing code into macro

    - this fixes building in debug mode because the compiler (at least, on
      macOS) doesn't like the `assert(status == 0)`
    - this also DRYs up some common code by moving it into a macro
    daniellockyer committed Dec 24, 2023
    Copy the full SHA
    c775b81 View commit details
  11. Copy the full SHA
    aabd297 View commit details
  12. Fixed uploading prebuilt binaries from Docker

    - the path here was incorrect
    daniellockyer committed Dec 24, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    5809f62 View commit details

Commits on Dec 27, 2023

  1. Refactored Database to use macros for method definitions

    - this cleans up similar definitions and makes further refactors easier
    daniellockyer committed Dec 27, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    8bda876 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    603e468 View commit details
  3. Increased number of rows inserted into benchmark database

    - the whole benchmark suite needs reworking but this should be a good
      poor mans method to make the benchmarking suite heavier
    daniellockyer committed Dec 27, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    77b327c View commit details
  4. Improved RowToJS performance by removing Napi::String::New instan…

    …tiation
    
    refs https://github.com/nodejs/node-addon-api/blob/main/doc/object.md#set
    
    - according to the node-addon-api docs, you can set various things as
      the key for a Napi::Object, including a std::string ref
    - instantiating a `Napi::String::New` is quite heavy, especially when
      we're doing it for every row we return, so we can avoid doing that and
      speed up the function
    - locally, this speeds up the benchmark by 5-15% (a lot of variance) but YMMV
    daniellockyer committed Dec 27, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    3372130 View commit details
  5. Inlined init() functions into class header files

    - these extra functions aren't really necessary and means there is more
      redirection occurring
    - as a bonus, this fixes a variable shadowing issue in the Statement
      implementation
    daniellockyer committed Dec 27, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    e99160a View commit details
  6. Removed extraneous parameter to event emit function

    - this was never passed to the user because the value below is `1`
    - our documentation says the close event doesn't emit any parameters, so
      we can just remove it from the array
    daniellockyer committed Dec 27, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    4ef11bf View commit details

Commits on Dec 29, 2023

  1. 1
    Copy the full SHA
    f792f69 View commit details
  2. Configured releases to be created as prereleases

    - we don't want to suggest it's released until all the builds are done
    - also configured verbose logging for uploads
    daniellockyer committed Dec 29, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    83c8c0a View commit details
  3. Fixed uploading release assets on Windows

    - I foolishly used a bash env var format but Windows uses Powershell
    - simplest here is just to remove the env var and pass it in directly
    daniellockyer committed Dec 29, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    8b86e41 View commit details
  4. Fixed uploading assets from Docker

    - the folder here has changed since we switched to prebuild
    daniellockyer committed Dec 29, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    8398daa View commit details
  5. v5.1.7-rc.0

    daniellockyer committed Dec 29, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    03d6e75 View commit details

Commits on Dec 30, 2023

  1. Removed Node version from matrix title

    - we only run CI on one version so it's not needed any more
    daniellockyer committed Dec 30, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    d04c1fb View commit details

Commits on Jan 5, 2024

  1. v5.1.7

    daniellockyer committed Jan 5, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    daniellockyer Daniel Lockyer
    Copy the full SHA
    ba4ba07 View commit details

Commits on Jan 16, 2024

  1. Updated bundled SQLite to v3.45.0

    refs https://www.sqlite.org/releaselog/3_45_0.html
    
    - sha3-256sum: `9fc2a78088875ae7c112957d58ccc52b1a0a4afa34ac669290be42f352b1aa76`
    daniellockyer committed Jan 16, 2024
    Copy the full SHA
    1609684 View commit details

Commits on Nov 6, 2024

  1. Updated actions/upload-artifact to v4

    daniellockyer authored Nov 6, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2f0c799 View commit details

Commits on Jan 20, 2025

  1. 2025

    Co-authored-by: Hannah Wolfe github.erisds@gmail.com
    JohnONolan authored and ErisDS committed Jan 20, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    ErisDS Hannah Wolfe
    Copy the full SHA
    528e15a View commit details
76 changes: 33 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -27,28 +27,20 @@ jobs:
target:
- x64
node:
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
include:
- os: windows-latest
node: 16
node: 18
host: x86
target: x86
- os: macos-m1
node: 16
node: 18
host: arm64
target: arm64
name: ${{ matrix.os }} (node=${{ matrix.node }}, host=${{ matrix.host }}, target=${{ matrix.target }})
name: ${{ matrix.os }} (host=${{ matrix.host }}, target=${{ matrix.target }})
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
architecture: ${{ matrix.host }}
@@ -57,6 +49,10 @@ jobs:
if: matrix.os == 'macos-m1'
run: npm install -g yarn

- name: Add setuptools for Python 3.12 (temp)
if: matrix.os != 'macos-m1'
run: pip install setuptools

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.3
if: contains(matrix.os, 'windows')
@@ -66,6 +62,9 @@ jobs:
- name: Install dependencies
run: yarn install --ignore-scripts

- name: Check Node compatibility
run: node tools/semver-check.js

- name: Add env vars
shell: bash
run: |
@@ -83,48 +82,41 @@ jobs:
echo "CFLAGS=${CFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV
echo "CXXFLAGS=${CXXFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV
- name: Configure build
run: yarn node-pre-gyp configure --target_arch=${{ env.TARGET }}

- name: Build binaries
run: yarn node-pre-gyp build --target_arch=${{ env.TARGET }}
run: yarn prebuild -a ${{ env.TARGET }}

- name: Print binary info
if: contains(matrix.os, 'ubuntu')
run: |
ldd lib/binding/*/node_sqlite3.node
ldd build/**/node_sqlite3.node
echo "---"
nm lib/binding/*/node_sqlite3.node | grep "GLIBC_" | c++filt || true
nm build/**/node_sqlite3.node | grep "GLIBC_" | c++filt || true
echo "---"
file lib/binding/napi-v*/*
file build/**/node_sqlite3.node
- name: Run tests
run: yarn test

- name: Package prebuilt binaries
run: yarn node-pre-gyp package --target_arch=${{ env.TARGET }}

- name: Upload binaries to commit artifacts
uses: actions/upload-artifact@v3
if: matrix.node == 16
uses: actions/upload-artifact@v4
if: matrix.node == 18
with:
name: prebuilt-binaries
path: build/stage/*/*
path: prebuilds/*
retention-days: 7

- name: Upload binaries to GitHub Release
run: yarn node-pre-gyp-github publish
if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/')
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ github.token }}
run: yarn upload --upload-all ${{ github.token }}
if: matrix.node == 18 && startsWith(github.ref, 'refs/tags/')

build-qemu:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
strategy:
fail-fast: false
matrix:
node:
- 16
- 18
target:
- linux/arm64
variant:
@@ -134,16 +126,16 @@ jobs:
# musl x64 builds
- target: linux/amd64
variant: alpine3.15
node: 16
node: 18
name: ${{ matrix.variant }} (node=${{ matrix.node }}, target=${{ matrix.target }})
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Build binaries and test
run: |
@@ -157,18 +149,16 @@ jobs:
--build-arg NODE_VERSION=${{ matrix.node }} \
.
CONTAINER_ID=$(docker create -it sqlite-builder)
docker cp $CONTAINER_ID:/usr/src/build/build/ ./build
docker cp $CONTAINER_ID:/usr/src/build/prebuilds/ ./prebuilds
- name: Upload binaries to commit artifacts
uses: actions/upload-artifact@v3
if: matrix.node == 16
uses: actions/upload-artifact@v4
if: matrix.node == 18
with:
name: prebuilt-binaries
path: build/stage/*/*
path: prebuilds/*
retention-days: 7

- name: Upload binaries to GitHub Release
run: yarn install --ignore-scripts && yarn node-pre-gyp-github publish
if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/')
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ github.token }}
run: yarn install --ignore-scripts && yarn upload --upload-all ${{ github.token }}
if: matrix.node == 18 && startsWith(github.ref, 'refs/tags/')
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -29,3 +29,4 @@ setup.sh
*.tgz
package-lock.json
yarn.lock
prebuilds
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) MapBox
Copyright (c) 2013-2025 Mapbox & Ghost Foundation
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
44 changes: 17 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ Asynchronous, non-blocking [SQLite3](https://sqlite.org/) bindings for [Node.js]
- [Extension support](https://github.com/TryGhost/node-sqlite3/wiki/API#databaseloadextensionpath-callback), including bundled support for the [json1 extension](https://www.sqlite.org/json1.html)
- Big test suite
- Written in modern C++ and tested for memory leaks
- Bundles SQLite v3.41.1, or you can build using a local SQLite
- Bundles SQLite v3.45.0, or you can build using a local SQLite

# Installing

@@ -35,32 +35,22 @@ yarn add sqlite3

`sqlite3` v5+ was rewritten to use [Node-API](https://nodejs.org/api/n-api.html) so prebuilt binaries do not need to be built for specific Node versions. `sqlite3` currently builds for both Node-API v3 and v6. Check the [Node-API version matrix](https://nodejs.org/api/n-api.html#node-api-version-matrix) to ensure your Node version supports one of these. The prebuilt binaries should be supported on Node v10+.

The module uses [node-pre-gyp](https://github.com/mapbox/node-pre-gyp) to download the prebuilt binary for your platform, if it exists. These binaries are hosted on GitHub Releases for `sqlite3` versions above 5.0.2, and they are hosted on S3 otherwise. The following targets are currently provided:

Format: `napi-v{napi_build_version}-{platform}-{libc}-{arch}`

* `napi-v3-darwin-unknown-arm64`
* `napi-v3-darwin-unknown-x64`
* `napi-v3-linux-glibc-arm64`
* `napi-v3-linux-glibc-x64`
* `napi-v3-linux-musl-arm64`
* `napi-v3-linux-musl-x64`
* `napi-v3-win32-unknown-ia32`
* `napi-v3-win32-unknown-x64`
* `napi-v6-darwin-unknown-arm64`
* `napi-v6-darwin-unknown-x64`
* `napi-v6-linux-glibc-arm64`
* `napi-v6-linux-glibc-x64`
* `napi-v6-linux-musl-arm64`
* `napi-v6-linux-musl-x64`
* `napi-v6-win32-unknown-ia32`
* `napi-v6-win32-unknown-x64`

Unfortunately, [node-pre-gyp](https://github.com/mapbox/node-pre-gyp) cannot differentiate between `armv6` and `armv7`, and instead uses `arm` as the `{arch}`. Until that is fixed, you will still need to install `sqlite3` from [source](#source-install).
The module uses [`prebuild-install`](https://github.com/prebuild/prebuild-install) to download the prebuilt binary for your platform, if it exists. These binaries are hosted on GitHub Releases for `sqlite3` versions above 5.0.2, and they are hosted on S3 otherwise. The following targets are currently provided:

* `darwin-arm64`
* `darwin-x64`
* `linux-arm64`
* `linux-x64`
* `linuxmusl-arm64`
* `linuxmusl-x64`
* `win32-ia32`
* `win32-x64`

Unfortunately, [prebuild](https://github.com/prebuild/prebuild/issues/174) cannot differentiate between `armv6` and `armv7`, and instead uses `arm` as the `{arch}`. Until that is fixed, you will still need to install `sqlite3` from [source](#source-install).

Support for other platforms and architectures may be added in the future if CI supports building on them.

If your environment isn't supported, it'll use `node-gyp` to build SQLite but you will need to install a C++ compiler and linker.
If your environment isn't supported, it'll use `node-gyp` to build SQLite, but you will need to install a C++ compiler and linker.

### Other ways to install

@@ -148,8 +138,6 @@ NODE_WEBKIT_VERSION="0.8.6" # see latest version at https://github.com/rogerwang
npm install sqlite3 --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION)
```

This command internally calls out to [`node-pre-gyp`](https://github.com/mapbox/node-pre-gyp) which itself calls out to [`nw-gyp`](https://github.com/rogerwang/nw-gyp) when the `--runtime=node-webkit` option is passed.

You can also run this command from within a `sqlite3` checkout:

```bash
@@ -254,7 +242,9 @@ This module was originally created by [Mapbox](https://mapbox.com/) & is now mai

We use [GitHub releases](https://github.com/TryGhost/node-sqlite3/releases) for notes on the latest versions. See [CHANGELOG.md](https://github.com/TryGhost/node-sqlite3/blob/b05f4594cf8b0de64743561fcd2cfe6f4571754d/CHANGELOG.md) in git history for details on older versions.

# License
# Copyright & license

Copyright (c) 2013-2025 Mapbox & Ghost Foundation

`node-sqlite3` is [BSD licensed](https://github.com/tryghost/node-sqlite3/raw/master/LICENSE).

14 changes: 2 additions & 12 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -2,7 +2,8 @@
"includes": [ "deps/common-sqlite.gypi" ],
"variables": {
"sqlite%":"internal",
"sqlite_libname%":"sqlite3"
"sqlite_libname%":"sqlite3",
"module_name": "node_sqlite3",
},
"targets": [
{
@@ -52,17 +53,6 @@
"src/statement.cc"
],
"defines": [ "NAPI_VERSION=<(napi_build_version)", "NAPI_DISABLE_CPP_EXCEPTIONS=1" ]
},
{
"target_name": "action_after_build",
"type": "none",
"dependencies": [ "<(module_name)" ],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
"destination": "<(module_path)"
}
]
}
]
}
2 changes: 1 addition & 1 deletion deps/common-sqlite.gypi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'variables': {
'sqlite_version%':'3410100',
'sqlite_version%':'3450000',
"toolset%":'',
},
'target_defaults': {
Binary file removed deps/sqlite-autoconf-3410100.tar.gz
Binary file not shown.
Binary file added deps/sqlite-autoconf-3450000.tar.gz
Binary file not shown.
6 changes: 1 addition & 5 deletions lib/sqlite3-binding.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
const binary = require('@mapbox/node-pre-gyp');
const path = require('path');
const binding_path = binary.find(path.resolve(path.join(__dirname,'../package.json')));
const binding = require(binding_path);
module.exports = exports = binding;
module.exports = require('bindings')('node_sqlite3.node');
30 changes: 13 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
{
"name": "sqlite3",
"description": "Asynchronous, non-blocking SQLite3 bindings",
"version": "5.1.6",
"version": "5.1.7",
"homepage": "https://github.com/TryGhost/node-sqlite3",
"author": {
"name": "Mapbox",
"url": "https://mapbox.com/"
},
"binary": {
"module_name": "node_sqlite3",
"module_path": "./lib/binding/napi-v{napi_build_version}-{platform}-{libc}-{arch}",
"host": "https://github.com/TryGhost/node-sqlite3/releases/download/",
"remote_path": "v{version}",
"package_name": "napi-v{napi_build_version}-{platform}-{libc}-{arch}.tar.gz",
"napi_versions": [
3,
6
]
},
"contributors": [
"Daniel Lockyer <hi@daniellockyer.com>",
"Konstantin Käfer <mail@kkaefer.com>",
"Dane Springmeyer <dane@mapbox.com>",
"Will White <will@mapbox.com>",
@@ -48,14 +44,15 @@
"url": "https://github.com/TryGhost/node-sqlite3.git"
},
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.0",
"node-addon-api": "^4.2.0",
"bindings": "^1.5.0",
"node-addon-api": "^7.0.0",
"prebuild-install": "^7.1.1",
"tar": "^6.1.11"
},
"devDependencies": {
"eslint": "6.8.0",
"mocha": "7.2.0",
"node-pre-gyp-github": "1.4.4"
"eslint": "8.56.0",
"mocha": "10.2.0",
"prebuild": "12.1.0"
},
"peerDependencies": {
"node-gyp": "8.x"
@@ -69,12 +66,11 @@
"node-gyp": "8.x"
},
"scripts": {
"build": "node-pre-gyp build",
"build:debug": "node-pre-gyp build --debug",
"install": "node-pre-gyp install --fallback-to-build",
"pretest": "node test/support/createdb.js",
"test": "mocha -R spec --timeout 480000",
"pack": "node-pre-gyp package"
"install": "prebuild-install -r napi || node-gyp rebuild",
"prebuild": "prebuild --runtime napi --all --verbose",
"rebuild": "node-gyp rebuild",
"upload": "prebuild --verbose --prerelease",
"test": "node test/support/createdb.js && mocha -R spec --timeout 480000"
},
"license": "BSD-3-Clause",
"keywords": [
11 changes: 5 additions & 6 deletions src/async.h
Original file line number Diff line number Diff line change
@@ -29,20 +29,19 @@ template <class Item, class Parent> class Async {
}

static void listener(uv_async_t* handle) {
Async* async = static_cast<Async*>(handle->data);
auto* async = static_cast<Async*>(handle->data);
std::vector<Item*> rows;
NODE_SQLITE3_MUTEX_LOCK(&async->mutex)
rows.swap(async->data);
NODE_SQLITE3_MUTEX_UNLOCK(&async->mutex)
for (unsigned int i = 0, size = rows.size(); i < size; i++) {
async->callback(async->parent, rows[i]);
}
for(auto row : rows)
async->callback(async->parent, row);
}

static void close(uv_handle_t* handle) {
assert(handle != NULL);
assert(handle->data != NULL);
Async* async = static_cast<Async*>(handle->data);
auto* async = static_cast<Async*>(handle->data);
delete async;
}

@@ -56,7 +55,7 @@ template <class Item, class Parent> class Async {

void add(Item* item) {
NODE_SQLITE3_MUTEX_LOCK(&mutex);
data.push_back(item);
data.emplace_back(item);
NODE_SQLITE3_MUTEX_UNLOCK(&mutex)
}

Loading