Socket
Socket
Sign inDemoInstall

better-sqlite3

Package Overview
Dependencies
66
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.1 to 7.0.0

.github/FUNDING.yml

3

benchmark/index.js

@@ -1,2 +0,1 @@

#!/usr/bin/env node
'use strict';

@@ -73,3 +72,3 @@ const { execFileSync } = require('child_process');

try {
const result = execFileSync('./benchmark.js', [ctx], { stdio: 'pipe', encoding: 'utf8' });
const result = execFileSync('node', ['./benchmark.js', ctx], { stdio: 'pipe', encoding: 'utf8' });
console.log(erase() + `${driverName} x ${result}`);

@@ -76,0 +75,0 @@ } catch (err) {

@@ -12,7 +12,6 @@ # API

- [Database#pragma()](#pragmastring-options---results)
- [Database#checkpoint()](#checkpointdatabasename---this)
- [Database#backup()](#backupdestination-options---promise)
- [Database#function()](#functionname-options-function---this)
- [Database#aggregate()](#aggregatename-options---this)
- [Database#loadExtension()](#loadextensionpath---this)
- [Database#loadExtension()](#loadextensionpath-entrypoint---this)
- [Database#exec()](#execstring---this)

@@ -24,8 +23,6 @@ - [Database#close()](#close---this)

Creates a new database connection. If the database file does not exist, it is created. This happens synchronously, which means you can start executing queries right away.
Creates a new database connection. If the database file does not exist, it is created. This happens synchronously, which means you can start executing queries right away. You can create an [in-memory database](https://www.sqlite.org/inmemorydb.html) by passing `":memory:"` as the first argument.
Various options are accepted:
- `options.memory`: open an in-memory database, rather than a disk-bound one (default: `false`).
- `options.readonly`: open the database connection in readonly mode (default: `false`).

@@ -90,2 +87,4 @@

Any arguments passed to the transaction function will be forwarded to the wrapped function, and any values returned from the wrapped function will be returned from the transaction function. The wrapped function will also have access to the same [`this`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this) binding as the transaction function.
#### Caveats

@@ -123,16 +122,2 @@

### .checkpoint([*databaseName*]) -> *this*
Runs a [WAL mode checkpoint](https://www.sqlite.org/wal.html) on all attached databases (including the main database).
Unlike [automatic checkpoints](https://www.sqlite.org/wal.html#automatic_checkpoint), this method executes a checkpoint in "RESTART" mode, which ensures a complete checkpoint operation even if other processes are using the database at the same time. You only need to use this method if you are accessing the database from multiple processes at the same time.
```js
setInterval(() => db.checkpoint(), 30000).unref();
```
If `databaseName` is provided, it should be the name of an attached database (or `"main"`). This causes only that database to be checkpointed.
If the checkpoint fails, an `Error` is thrown.
### .backup(*destination*, [*options*]) -> *promise*

@@ -161,3 +146,3 @@

If the `progress` callback throws an exception, the backup will be aborted. Usually this happens due to an unexpected error, but you can also use this behavior to voluntarily cancel the backup operation. If the parent database connection is closed, all pending backups will be automatically aborted.
If the backup is successful, the returned promise will contain an object that has the same properties as the one provided to the `progress` callback, but `.remainingPages` will be `0`. If the `progress` callback throws an exception, the backup will be aborted. Usually this happens due to an unexpected error, but you can also use this behavior to voluntarily cancel the backup operation. If the parent database connection is closed, all pending backups will be automatically aborted.

@@ -252,3 +237,3 @@ ```js

### .loadExtension(*path*) -> *this*
### .loadExtension(*path*, [*entryPoint*]) -> *this*

@@ -255,0 +240,0 @@ Loads a compiled [SQLite3 extension](https://sqlite.org/loadext.html) and applies it to the current database connection.

@@ -14,26 +14,26 @@ # Benchmark

These results are from 10/08/2018, on a MacBook Pro (Retina, 15-inch, Mid 2014, OSX 10.11.6), using nodejs v10.11.0.
These results are from 03/29/2020, on a MacBook Pro (Retina, 15-inch, Mid 2014, OSX 10.11.6), using nodejs v12.16.1.
```
--- reading rows individually ---
better-sqlite3 x 283,745 ops/sec ±0.16%
node-sqlite3 x 27,191 ops/sec ±0.39%
better-sqlite3 x 313,899 ops/sec ±0.13%
node-sqlite3 x 26,780 ops/sec ±2.9%
--- reading 100 rows into an array ---
better-sqlite3 x 6,650 ops/sec ±0.25%
node-sqlite3 x 2,978 ops/sec ±0.33%
better-sqlite3 x 8,508 ops/sec ±0.27%
node-sqlite3 x 2,930 ops/sec ±0.37%
--- iterating over 100 rows ---
better-sqlite3 x 5,231 ops/sec ±0.28%
node-sqlite3 x 278 ops/sec ±0.62%
better-sqlite3 x 6,532 ops/sec ±0.32%
node-sqlite3 x 268 ops/sec ±3.4%
--- inserting rows individually ---
better-sqlite3 x 64,920 ops/sec ±5.86%
node-sqlite3 x 23,564 ops/sec ±3.58%
better-sqlite3 x 62,554 ops/sec ±7.33%
node-sqlite3 x 22,637 ops/sec ±4.37%
--- inserting 100 rows in a single transaction ---
better-sqlite3 x 4,155 ops/sec ±4.45%
node-sqlite3 x 321 ops/sec ±1.4%
better-sqlite3 x 4,141 ops/sec ±4.57%
node-sqlite3 x 265 ops/sec ±4.87%
```
> All benchmarks are executed in [WAL mode](./performance.md).

@@ -6,7 +6,31 @@ # Custom configuration

```bash
npm install --sqlite3=/my/path/to/sqlite-amalgamation
npm install better-sqlite3 --build-from-source --sqlite3=/path/to/sqlite-amalgamation
```
Your amalgamation directory should contain `sqlite3.c` and `sqlite3.h`. Any desired [compile time options](https://www.sqlite.org/compile.html) must be defined directly within `sqlite3.c`.
However, if you simply run `npm install` while `better-sqlite3` is listed as a dependency in your `package.json`, the required flags above will *not* be applied. Therefore, it's recommened that you remove `better-sqlite3` from your dependency list, and instead add a [`preinstall` script](https://docs.npmjs.com/misc/scripts) like the one shown below.
```json
{
"scripts": {
"preinstall": "npm install better-sqlite3@'^7.0.0' --no-save --build-from-source --sqlite3=\"$(pwd)/sqlite-amalgamation\""
}
}
```
Your amalgamation directory must contain `sqlite3.c` and `sqlite3.h`. Any desired [compile time options](https://www.sqlite.org/compile.html) must be defined directly within `sqlite3.c`.
### Step by step example
If you're creating a package that relies on a custom build of `better-sqlite3`, you can follow these steps to get started.
1. Download the SQLite3 source code from [their website](https://sqlite.com/download.html) (e.g., `sqlite-amalgamation-1234567.zip`)
2. Unzip the compressed archive
3. Move the `sqlite3.c` and `sqlite3.h` files to your project folder
4. Add a `preinstall` script to your `package.json`, like the one shown above
5. Make sure the `--sqlite3` flag points to the location of your `sqlite3.c` and `sqlite3.h` files
6. Define your preferred [compile time options](https://www.sqlite.org/compile.html) at the top of `sqlite3.c`
7. Run `npm install` in your project folder
If you're using a SQLite3 encryption extension that is a drop-in replacement for SQLite3 (such as [SEE](https://www.sqlite.org/see/doc/release/www/readme.wiki) or [sqleet](https://github.com/resilar/sqleet)), then simply replace `sqlite3.c` and `sqlite3.h` with the source files of your encryption extension.
# Bundled configuration

@@ -19,3 +43,4 @@

SQLITE_LIKE_DOESNT_MATCH_BLOBS
SQLITE_THREADSAFE=0
SQLITE_THREADSAFE=2
SQLITE_USE_URI=0
SQLITE_DEFAULT_MEMSTATUS=0

@@ -26,2 +51,3 @@ SQLITE_OMIT_DEPRECATED

SQLITE_OMIT_PROGRESS_CALLBACK
SQLITE_OMIT_SHARED_CACHE
SQLITE_TRACE_SIZE_LIMIT=32

@@ -31,3 +57,2 @@ SQLITE_DEFAULT_CACHE_SIZE=-16000

SQLITE_DEFAULT_WAL_SYNCHRONOUS=1
SQLITE_USE_URI=1
SQLITE_ENABLE_COLUMN_METADATA

@@ -42,4 +67,5 @@ SQLITE_ENABLE_UPDATE_DELETE_LIMIT

SQLITE_ENABLE_RTREE
SQLITE_ENABLE_GEOPOLY
SQLITE_INTROSPECTION_PRAGMAS
SQLITE_SOUNDEX
```

@@ -1,27 +0,25 @@

# The `Integer` class
# The `BigInt` primitive type
SQLite3 can store data in 64-bit signed integers, which are too big for JavaScript's [number format](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) to fully represent. To support this data type, `better-sqlite3` uses the immutable `Integer` class. To view the complete `Integer` documentation, [click here](https://github.com/JoshuaWise/integer).
SQLite3 can store data in 64-bit signed integers, which are too big for JavaScript's [number format](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) to fully represent. To support this data type, `better-sqlite3` is fully compatible with [BigInts](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt).
```js
const { Integer } = require('better-sqlite3');
const integer = Integer('95073701505997');
integer.toString(); // returns "95073701505997"
integer.toNumber(); // returns 95073701505997
const bigInteger = Integer('1152735103331642317');
bigInteger.toString(); // returns "1152735103331642317"
bigInteger.toNumber(); // throws a RangeError, cannot be represented in JavaScript
const big = BigInt('1152735103331642317');
big === 1152735103331642317n; // returns true
big.toString(); // returns "1152735103331642317"
typeof big; // returns "bigint"
```
## Binding Integers
## Binding BigInts
`Integers` can bind to [`Statements`](./api.md#class-statement) just like regular numbers. You can also return `Integers` from [user-defined functions](./api.md#functionname-options-function---this).
`BigInts` can bind to [`Statements`](./api.md#class-statement) just like regular numbers. You can also return `BigInts` from [user-defined functions](./api.md#functionname-options-function---this). However, if you provide a `BigInt` that's too large to be a 64-bit signed integer, you'll get an error so that data integrity is protected.
```js
db.prepare("SELECT * FROM users WHERE id=?").get(Integer('1152735103331642317'));
db.prepare("INSERT INTO users (id) VALUES (?)").run(Integer('1152735103331642317'));
db.prepare("SELECT * FROM users WHERE id=?").get(BigInt('1152735103331642317'));
db.prepare("INSERT INTO users (id) VALUES (?)").run(BigInt('1152735103331642317'));
db.prepare("SELECT ?").get(2n ** 63n - 1n); // returns successfully
db.prepare("SELECT ?").get(2n ** 63n); // throws a RangeError
```
## Getting Integers from the database
## Getting BigInts from the database

@@ -31,5 +29,5 @@ By default, integers returned from the database (including the [`info.lastInsertRowid`](./api.md#runbindparameters---object) property) are normal JavaScript numbers. You can change this default as you please:

```js
db.defaultSafeIntegers(); // Integers by default
db.defaultSafeIntegers(true); // Integers by default
db.defaultSafeIntegers(false); // JavaScript numbers by default
db.defaultSafeIntegers(); // BigInts by default
db.defaultSafeIntegers(true); // BigInts by default
db.defaultSafeIntegers(false); // Numbers by default
```

@@ -47,13 +45,13 @@

[User-defined functions](./api.md#functionname-options-function---this) can receive `Integers` as arguments. You can override the database's default setting like so:
[User-defined functions](./api.md#functionname-options-function---this) can receive `BigInts` as arguments. You can override the database's default setting like so:
```js
db.function('isInt', { safeIntegers: true }, (value) => {
return String(value instanceof Integer);
return String(typeof value === 'bigint');
});
db.prepare('SELECT isInt(?)').pluck().get('foobar'); // => "false"
db.prepare('SELECT isInt(?)').pluck().get(Integer.MAX_VALUE); // => "true"
db.prepare('SELECT isInt(?)').pluck().get(10); // => "false"
db.prepare('SELECT isInt(?)').pluck().get(10n); // => "true"
```
It's worth noting that REAL (FLOAT) values returned from the database will always be represented as JavaScript numbers.
It's worth noting that REAL (FLOAT) values returned from the database will always be represented as normal numbers.

@@ -21,5 +21,5 @@ # Performance

If you don't access the database from multiple processes simultaneously, you'll never encounter this issue.
If you don't access the database from multiple processes or threads simultaneously, you'll never encounter this issue.
If you do access the database from multiple processes simultaneously, just use the [`db.checkpoint()`](./api.md#checkpointdatabasename---this) method when the WAL file gets too big.
If you do access the database from multiple processes or threads simultaneously, just use the [`wal_checkpoint(RESTART)`](https://www.sqlite.org/pragma.html#pragma_wal_checkpoint) pragma when the WAL file gets too big.

@@ -31,3 +31,3 @@ ```js

} else if (stat.size > someUnacceptableSize) {
db.checkpoint();
db.pragma('wal_checkpoint(RESTART)');
}

@@ -34,0 +34,0 @@ }), 5000).unref();

@@ -5,3 +5,3 @@ # Troubleshooting installation

1. Make sure you're using nodejs v8.9.4 or later
1. Make sure you're using nodejs v10.20.1 or later

@@ -14,5 +14,5 @@ 2. Make sure you have [`node-gyp`](https://github.com/nodejs/node-gyp#installation) globally installed, including all of [its dependencies](https://github.com/nodejs/node-gyp#on-unix). On Windows you may need to [configure some things manually](https://github.com/nodejs/node-gyp#on-windows).

1. Install the **latest** of node 8, node 10, or node 12. Earlier versions of node (like 10.2.x) will not compile.
1. Start an Admin PowerShell: Right-click the start icon, then pick `Windows PowerShell (Admin)`
1. Install *both* vs2015 and vs2017 libraries. Each line will take ~5-10 minutes.
1. Install the **latest** of node 10 or node 12.
2. Start an Admin PowerShell: Right-click the start icon, then pick `Windows PowerShell (Admin)`
3. Install *both* vs2015 and vs2017 libraries. Each line will take ~5-10 minutes.
```sh

@@ -22,6 +22,6 @@ npm install --global --production --vs2015 --add-python-to-path windows-build-tools

```
1. In your project, make sure you're not fighting with old build configurations. Delete **both**
4. In your project, make sure you're not fighting with old build configurations. Delete **both**
* your `%USERPROFILE%/.node-gyp` and
* your project's `node_modules` directories.
1. Set up `%USERPROFILE%/.npmrc` correctly:
5. Set up `%USERPROFILE%/.npmrc` correctly:
```sh

@@ -32,4 +32,4 @@ msvs_version=2015

(where `%USERPROFILE%` is your home directory).
1. Run `npm install` or `yarn install`
6. Run `npm install`
If none of these solved your problem, try browsing [previous issues](https://github.com/JoshuaWise/better-sqlite3/issues?q=is%3Aissue) or open a [new issue](https://github.com/JoshuaWise/better-sqlite3/issues/new).

@@ -17,3 +17,2 @@ 'use strict';

if (filename === ':memory:') throw new TypeError('Invalid backup filename ":memory:"');
if (filename.toLowerCase().startsWith('file:')) throw new TypeError('URI filenames are reserved for internal use only');

@@ -20,0 +19,0 @@ const attachedName = 'attached' in options ? options.attached : 'main';

@@ -6,3 +6,6 @@ 'use strict';

const CPPDatabase = require('bindings')('better_sqlite3.node').Database;
const {
Database: CPPDatabase,
setErrorConstructor,
} = require('bindings')('better_sqlite3.node');

@@ -14,9 +17,7 @@ function Database(filenameGiven, options) {

if (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');
let filename = filenameGiven.trim();
if (filename.toLowerCase().startsWith('file:')) throw new TypeError('URI filenames are reserved for internal use only');
if ('readOnly' in options) throw new TypeError('Misspelled option "readOnly" should be "readonly"');
if ('memory' in options) throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
const filename = filenameGiven.trim();
const anonymous = filename === '' || filename === ':memory:';
const memory = util.getBooleanOption(options, 'memory');
const readonly = util.getBooleanOption(options, 'readonly');

@@ -27,4 +28,3 @@ const fileMustExist = util.getBooleanOption(options, 'fileMustExist');

if (readonly && (memory || anonymous)) throw new TypeError('In-memory databases cannot be readonly');
if (anonymous && !memory && 'memory' in options) throw new TypeError('Option "memory" conflicts with non-existent filename');
if (readonly && anonymous) throw new TypeError('In-memory/temporary databases cannot be readonly');
if (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the "timeout" option to be a positive integer');

@@ -34,20 +34,9 @@ if (timeout > 0x7fffffff) throw new RangeError('Option "timeout" cannot be greater than 2147483647');

if (!memory && !anonymous && !fs.existsSync(path.dirname(filename))) {
if (!anonymous && !fs.existsSync(path.dirname(filename))) {
throw new TypeError('Cannot open database because the directory does not exist');
}
if (memory && !anonymous) {
if (process.platform === 'win32') {
filename = filename.replace(/\\/g, '/').replace(/^[a-z]:\//i, '/$&');
}
filename = 'file:'
+ filename
.replace(/#/g, '%23')
.replace(/\?/g, '%3f')
.replace(/\/\/+/g, '/')
+ '?mode=memory&cache=shared';
}
return new CPPDatabase(filename, filenameGiven, memory || anonymous, readonly, fileMustExist, timeout, verbose || null);
return new CPPDatabase(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null);
}
setErrorConstructor(require('./sqlite-error'));
util.wrap(CPPDatabase, 'pragma', require('./pragma'));

@@ -54,0 +43,0 @@ util.wrap(CPPDatabase, 'function', require('./function'));

'use strict';
module.exports = require('./database');
module.exports.Integer = require('integer');
module.exports.SqliteError = require('./sqlite-error');

@@ -11,11 +11,11 @@ 'use strict';

let stmt;
setPragmaMode.call(this, true);
try {
return simple
? this.prepare(`PRAGMA ${source}`).pluck().get()
: this.prepare(`PRAGMA ${source}`).all();
stmt = this.prepare(`PRAGMA ${source}`);
} finally {
setPragmaMode.call(this, false);
}
return simple ? stmt.pluck().get() : stmt.all();
};
};
{
"name": "better-sqlite3",
"version": "6.0.1",
"version": "7.0.0",
"description": "The fastest and simplest library for SQLite3 in Node.js.",

@@ -14,3 +14,2 @@ "homepage": "http://github.com/JoshuaWise/better-sqlite3",

"bindings": "^1.5.0",
"integer": "^3.0.1",
"prebuild-install": "^5.3.3",

@@ -17,0 +16,0 @@ "tar": "4.4.10"

# better-sqlite3 [![Build Status](https://travis-ci.org/JoshuaWise/better-sqlite3.svg?branch=master)](https://travis-ci.org/JoshuaWise/better-sqlite3) [![Build status](https://ci.appveyor.com/api/projects/status/ilk8hb8v95m54v6f/branch/master?svg=true)](https://ci.appveyor.com/project/JoshuaWise/better-sqlite3/branch/master)
The fastest and simplest library for SQLite3 in Node.js.

@@ -11,2 +10,3 @@

- 64-bit integers *(invisible until you need them)*
- Worker thread support *(did someone say they needed async?)*

@@ -17,2 +17,3 @@ ## Help this project stay strong! &#128170;

- [Become a GitHub sponsor](https://github.com/sponsors/JoshuaWise)
- [Become a backer on Patreon](https://www.patreon.com/joshuawise)

@@ -26,3 +27,3 @@ - [Make a one-time donation on PayPal](https://www.paypal.me/joshuathomaswise)

|better-sqlite3|1x|1x|1x|1x|1x|
|[sqlite](https://www.npmjs.com/package/sqlite) and [sqlite3](https://www.npmjs.com/package/sqlite3)|10.4x slower|2.2x slower|18.8x slower|2.8x slower|12.9x slower|
|[sqlite](https://www.npmjs.com/package/sqlite) and [sqlite3](https://www.npmjs.com/package/sqlite3)|11.7x slower|2.9x slower|24.4x slower|2.8x slower|15.6x slower|

@@ -37,2 +38,4 @@ > You can verify these results by [running the benchmark yourself](./docs/benchmark.md).

> You must be using Node.js v10 or above. Prebuilt binaries are available for [LTS versions](https://nodejs.org/en/about/releases/) + Linux/OSX.
> If you have trouble installing, check the [troubleshooting guide](./docs/troubleshooting.md).

@@ -45,3 +48,3 @@

const row = db.prepare('SELECT * FROM users WHERE id=?').get(userId);
const row = db.prepare('SELECT * FROM users WHERE id = ?').get(userId);
console.log(row.firstName, row.lastName, row.email);

@@ -74,2 +77,4 @@ ```

- [64-bit integer support](./docs/integer.md)
- [Worker thread support](./docs/threads.md)
- [Unsafe mode (advanced)](./docs/unsafe.md)
- [SQLite3 compilation](./docs/compilation.md)

@@ -76,0 +81,0 @@

@@ -24,10 +24,4 @@ 'use strict';

expect(() => (this.db = new Database(util.next(), { readonly: undefined }))).to.throw(TypeError);
expect(() => (this.db = new Database(util.next(), { memory: undefined }))).to.throw(TypeError);
expect(() => (this.db = new Database(util.next(), { fileMustExist: undefined }))).to.throw(TypeError);
});
it('should not allow URI file paths', function () {
expect(() => (this.db = new Database(`FILE:${util.next()}`))).to.throw(TypeError);
expect(() => (this.db = new Database(`file:${util.next()}`))).to.throw(TypeError);
expect(() => (this.db = new Database(`file:${util.next()}?mode=memory&cache=shared`))).to.throw(TypeError);
});
it('should allow anonymous temporary databases to be created', function () {

@@ -57,12 +51,2 @@ for (const args of [[''], [], [null], [undefined], ['', { timeout: 2000 }]]) {

});
it('should allow named in-memory databases to be created', function () {
expect(existsSync(util.next())).to.be.false;
const db = this.db = new Database(util.current(), { memory: true });
expect(db.name).to.equal(util.current());
expect(db.memory).to.be.true;
expect(db.readonly).to.be.false;
expect(db.open).to.be.true;
expect(db.inTransaction).to.be.false;
expect(existsSync(util.current())).to.be.false;
});
it('should allow disk-bound databases to be created', function () {

@@ -78,8 +62,2 @@ expect(existsSync(util.next())).to.be.false;

});
it('should not allow conflicting in-memory options', function () {
expect(() => (this.db = new Database(':memory:', { memory: false }))).to.throw(TypeError);
expect(() => (this.db = new Database('', { memory: false }))).to.throw(TypeError);
(new Database(':memory:', { memory: true })).close();
(new Database('', { memory: true })).close();
});
it('should allow readonly database connections to be created', function () {

@@ -100,3 +78,2 @@ expect(existsSync(util.next())).to.be.false;

expect(existsSync(util.next())).to.be.false;
expect(() => (this.db = new Database(util.current(), { memory: true, readonly: true }))).to.throw(TypeError);
expect(() => (this.db = new Database(':memory:', { readonly: true }))).to.throw(TypeError);

@@ -103,0 +80,0 @@ expect(() => (this.db = new Database('', { readonly: true }))).to.throw(TypeError);

@@ -31,3 +31,2 @@ 'use strict';

expect(() => this.db.pragma('cache_size')).to.throw(TypeError);
expect(() => this.db.checkpoint()).to.throw(TypeError);
expect(() => this.db.function('foo', () => {})).to.throw(TypeError);

@@ -34,0 +33,0 @@ expect(() => this.db.aggregate('foo', { step: () => {} })).to.throw(TypeError);

@@ -37,3 +37,4 @@ 'use strict';

expect(() => this.db.prepare('CREATE TABLE people (name TEXT);CREATE TABLE animals (name TEXT)')).to.throw(RangeError);
expect(() => this.db.prepare('CREATE TABLE people (name TEXT);;')).to.throw(RangeError);
expect(() => this.db.prepare('CREATE TABLE people (name TEXT);/')).to.throw(RangeError);
expect(() => this.db.prepare('CREATE TABLE people (name TEXT);-')).to.throw(RangeError);
});

@@ -40,0 +41,0 @@ it('should create a prepared Statement object', function () {

@@ -5,3 +5,3 @@ 'use strict';

describe('Database#checkpoint()', function () {
describe('Database#pragma(\'wal_checkpoint(RESTART)\')', function () {
let db1, db2;

@@ -39,3 +39,3 @@ before(function () {

db1.prepare(`ATTACH '${db2.name}' AS foobar`).run();
expect(db1.checkpoint()).to.deep.equal(db1);
db1.pragma('wal_checkpoint(RESTART)');
fillWall(10, (b, a) => expect(b).to.equal(a));

@@ -57,3 +57,3 @@ });

db1.prepare(`ATTACH '${db2.name}' AS bazqux`).run();
expect(db1.checkpoint('bazqux')).to.equal(db1);
db1.pragma('bazqux.wal_checkpoint(RESTART)');
fillWall(10, (b, a, db) => {

@@ -60,0 +60,0 @@ if (db === db1) expect(b).to.be.above(a);

@@ -35,7 +35,2 @@ 'use strict';

});
it('should not allow a URI file path', async function () {
await rejectsWith(TypeError, this.db.backup(`FILE:${util.next()}`));
await rejectsWith(TypeError, this.db.backup(`file:${util.next()}`));
await rejectsWith(TypeError, this.db.backup(`file:${util.next()}?mode=memory&cache=shared`));
});
it('should not allow a :memory: destination', async function () {

@@ -42,0 +37,0 @@ await rejectsWith(TypeError, this.db.backup(':memory:'));

@@ -93,13 +93,13 @@ 'use strict';

describe('Database#checkpoint()', function () {
describe('Database#pragma(\'wal_checkpoint(RESTART)\')', function () {
specify('while iterating (blocked)', function () {
whileIterating(this, blocked(() => this.db.checkpoint()));
normally(allowed(() => this.db.checkpoint()));
whileIterating(this, blocked(() => this.db.pragma('wal_checkpoint(RESTART)')));
normally(allowed(() => this.db.pragma('wal_checkpoint(RESTART)')));
});
specify('while busy (blocked)', function () {
whileBusy(this, blocked(() => this.db.checkpoint()));
normally(allowed(() => this.db.checkpoint()));
whileBusy(this, blocked(() => this.db.pragma('wal_checkpoint(RESTART)')));
normally(allowed(() => this.db.pragma('wal_checkpoint(RESTART)')));
});
specify('while closed (blocked)', function () {
whileClosed(this, blocked(() => this.db.checkpoint()));
whileClosed(this, blocked(() => this.db.pragma('wal_checkpoint(RESTART)')));
});

@@ -106,0 +106,0 @@ });

'use strict';
const Database = require('../.');
const { Integer } = Database;

@@ -34,6 +33,6 @@ describe('verbose mode', function () {

db.prepare('create table data (x)').run();
stmt.get(Integer(10));
stmt.all(Integer(15));
stmt.iterate(Integer(20)).return();
for (const x of stmt.iterate(Integer(25))) {}
stmt.get(BigInt(10));
stmt.all(BigInt(15));
stmt.iterate(BigInt(20)).return();
for (const x of stmt.iterate(BigInt(25))) {}
db.pragma('cache_size');

@@ -40,0 +39,0 @@ db.prepare("insert into data values ('hi')").run();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc