better-sqlite3
Advanced tools
Comparing version 3.3.0 to 4.0.0
@@ -6,3 +6,3 @@ 'use strict'; | ||
{type: 'select-all', table: 'allSmall', columns: ['integer', 'real', 'text', 'nul']}, | ||
{type: 'select-each', table: 'allSmall', columns: ['integer', 'real', 'text', 'nul']}, | ||
{type: 'select-iterate', table: 'allSmall', columns: ['integer', 'real', 'text', 'nul']}, | ||
{type: 'insert', table: 'allSmall', columns: ['integer', 'real', 'text', 'nul'], pragma: ['journal_mode = WAL', 'synchronous = 1']}, | ||
@@ -30,9 +30,9 @@ {type: 'insert', table: 'allSmall', columns: ['integer', 'real', 'text', 'nul'], pragma: ['journal_mode = DELETE', 'synchronous = 2']}, | ||
{type: 'select-all', table: 'allLarge', columns: ['blob']}, | ||
{type: 'select-each', table: 'allSmall', columns: ['integer']}, | ||
{type: 'select-each', table: 'allSmall', columns: ['real']}, | ||
{type: 'select-each', table: 'allSmall', columns: ['text']}, | ||
{type: 'select-each', table: 'allSmall', columns: ['blob']}, | ||
{type: 'select-each', table: 'allSmall', columns: ['nul']}, | ||
{type: 'select-each', table: 'allLarge', columns: ['text']}, | ||
{type: 'select-each', table: 'allLarge', columns: ['blob']}, | ||
{type: 'select-iterate', table: 'allSmall', columns: ['integer']}, | ||
{type: 'select-iterate', table: 'allSmall', columns: ['real']}, | ||
{type: 'select-iterate', table: 'allSmall', columns: ['text']}, | ||
{type: 'select-iterate', table: 'allSmall', columns: ['blob']}, | ||
{type: 'select-iterate', table: 'allSmall', columns: ['nul']}, | ||
{type: 'select-iterate', table: 'allLarge', columns: ['text']}, | ||
{type: 'select-iterate', table: 'allLarge', columns: ['blob']}, | ||
{type: 'insert', table: 'integerSmall', columns: ['integer'], pragma: ['journal_mode = WAL', 'synchronous = 1']}, | ||
@@ -39,0 +39,0 @@ {type: 'insert', table: 'realSmall', columns: ['real'], pragma: ['journal_mode = WAL', 'synchronous = 1']}, |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var rowid = 99; | ||
benchmark.on('cycle', function () {rowid = 0;}); | ||
benchmark.on('cycle', function () {rowid = 99;}); | ||
@@ -11,0 +11,0 @@ var betterSqlite3Select = betterSqlite3.prepare(SQL); |
{ | ||
"name": "better-sqlite3", | ||
"version": "3.3.0", | ||
"version": "4.0.0", | ||
"description": "The fastest and simplest library for SQLite3 in Node.js.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/JoshuaWise/better-sqlite3", |
@@ -13,6 +13,6 @@ # better-sqlite3 [![Build Status](https://travis-ci.org/JoshuaWise/better-sqlite3.svg?branch=master)](https://travis-ci.org/JoshuaWise/better-sqlite3) | ||
| |select 1 row `get()`|select 100 rows `all()`|select 100 rows `each()`|insert 1 row `run()`|insert 100 rows in a transaction| | ||
| |select 1 row `get()`|select 100 rows `all()`|select 100 rows `iterate()`|insert 1 row `run()`|insert 100 rows in a transaction| | ||
|---|---|---|---|---|---| | ||
|better-sqlite3|1x|1x|1x|1x|1x| | ||
|[sqlite](https://www.npmjs.com/package/sqlite) and [sqlite3](https://www.npmjs.com/package/sqlite3)|7.8x slower|3.4x slower|3.4x slower|3.5x slower|6.2x slower| | ||
|[sqlite](https://www.npmjs.com/package/sqlite) and [sqlite3](https://www.npmjs.com/package/sqlite3)|8.4x slower|3.7x slower|28.2x slower|3.6x slower|6.0x slower| | ||
@@ -19,0 +19,0 @@ > You can verify these results by [running the benchmark yourself](https://github.com/JoshuaWise/better-sqlite3/wiki/Benchmark). |
@@ -29,3 +29,3 @@ var expect = require('chai').expect; | ||
db.prepare('SELECT * FROM people').all(); | ||
db.prepare('SELECT * FROM people').each(function () {}); | ||
db.prepare('SELECT * FROM people').iterate().return(); | ||
db.prepare("INSERT INTO people VALUES ('foobar')").run(); | ||
@@ -41,3 +41,3 @@ db.transaction(["INSERT INTO people VALUES ('foobar')"]).run(); | ||
expect(function () {stmt1.all();}).to.throw(TypeError); | ||
expect(function () {stmt1.each(function () {});}).to.throw(TypeError); | ||
expect(function () {stmt1.iterate();}).to.throw(TypeError); | ||
expect(function () {stmt2.run();}).to.throw(TypeError); | ||
@@ -44,0 +44,0 @@ expect(function () {trans.run();}).to.throw(TypeError); |
@@ -111,7 +111,7 @@ var expect = require('chai').expect; | ||
var ranOnce = false; | ||
db.prepare('SELECT 2').pluck().each(function (a) { | ||
for (var a of db.prepare('SELECT 2').pluck().iterate()) { | ||
expect(a).to.equal(2); | ||
ranOnce = true; | ||
expect(function () {db.register(function xd1() {});}).to.throw(TypeError); | ||
}); | ||
} | ||
expect(ranOnce).to.be.true; | ||
@@ -157,2 +157,21 @@ db.register(function xd2() {}); | ||
}); | ||
it('should close a statement iterator that caused its function to throw', function () { | ||
var i = 0; | ||
var err = new Error('foo'); | ||
register(function throwsIterator1(x) {if (++i >= 5) throw err; return x}); | ||
db.prepare('CREATE TABLE iterable (value INTEGER)').run(); | ||
db.prepare('INSERT INTO iterable WITH RECURSIVE temp(a) AS (SELECT 1 UNION ALL SELECT a * 2 FROM temp LIMIT 10) SELECT * FROM temp').run(); | ||
var iterator = db.prepare('SELECT throwsIterator1(value) FROM iterable').pluck().iterate(); | ||
var total = 0; | ||
expect(function () { | ||
for (var value of iterator) { | ||
total += value; | ||
expect(function () {db.prepare('SELECT throwsIterator1(value) FROM iterable');}).to.throw(TypeError); | ||
} | ||
}).to.throw(err); | ||
expect(total).to.equal(1 + 2 + 4 + 8); | ||
expect(iterator.next()).to.deep.equal({value: undefined, done: true}); | ||
db.prepare('SELECT throwsIterator1(value) FROM iterable').pluck().iterate().return(); | ||
expect(total).to.equal(1 + 2 + 4 + 8); | ||
}); | ||
it('should be able to register multiple functions with the same name', function () { | ||
@@ -194,7 +213,7 @@ register(function ia1() {return 0;}); | ||
}); | ||
db.prepare('SELECT k1(555)').pluck().each(function (n) { | ||
for (var n of db.prepare('SELECT k1(555)').pluck().iterate()) { | ||
ranOnce = true; | ||
expect(n).to.equal(1110); | ||
expect(function () {db.prepare('SELECT 555');}).to.throw(TypeError); | ||
}); | ||
} | ||
expect(ranOnce).to.be.true; | ||
@@ -201,0 +220,0 @@ db.prepare('SELECT 555'); |
@@ -46,7 +46,7 @@ var expect = require('chai').expect; | ||
var invoked = false; | ||
db.prepare('select 555').pluck().each(function (value) { | ||
for (var value of db.prepare('select 555').pluck().iterate()) { | ||
expect(value).to.equal(555); | ||
expect(function () {db.loadExtension(filepath);}).to.throw(TypeError); | ||
invoked = true; | ||
}); | ||
} | ||
expect(invoked).to.be.true; | ||
@@ -53,0 +53,0 @@ }); |
@@ -111,3 +111,3 @@ var expect = require('chai').expect; | ||
var stmt2 = db.prepare('INSERT INTO entries VALUES (?, ?, ?)'); | ||
stmt1.each(function () { | ||
for (var row of stmt1.iterate()) { | ||
ranOnce = true; | ||
@@ -118,5 +118,5 @@ expect(function () {stmt1.safeIntegers();}).to.throw(TypeError); | ||
expect(function () {stmt2.safeIntegers(false);}).to.throw(TypeError); | ||
}); | ||
} | ||
expect(ranOnce).to.be.true; | ||
}); | ||
}); |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2821783
72
4425