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

Support @vscode/sqlite3 #4866

Merged
merged 2 commits into from Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/dialects/sqlite3/index.js
Expand Up @@ -29,7 +29,7 @@ class Client_SQLite3 extends Client {
}

_driver() {
return require('sqlite3');
return require('@vscode/sqlite3');
}

schemaCompiler() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -95,6 +95,7 @@
},
"devDependencies": {
"@types/node": "^16.11.6",
"@vscode/sqlite3": "^5.0.7",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"chai-subset-in-order": "^3.1.0",
Expand Down Expand Up @@ -122,7 +123,6 @@
"sinon": "^12.0.1",
"sinon-chai": "^3.7.0",
"source-map-support": "^0.5.20",
"sqlite3": "^5.0.2",
"tap-spec": "^5.0.0",
"tape": "^5.3.1",
"tedious": "^12.2.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/runkit-example.js
@@ -1,4 +1,4 @@
require('sqlite3');
require('@vscode/sqlite3');
const Knex = require('knex');

const knexSqlite = Knex({
Expand Down
2 changes: 1 addition & 1 deletion test/cli/esm-interop.spec.js
Expand Up @@ -3,7 +3,7 @@ const assert = require('assert');
const path = require('path');
const fs = require('fs');
const { execCommand } = require('cli-testlab');
const sqlite3 = require('sqlite3');
const sqlite3 = require('@vscode/sqlite3');
const semver = require('semver');
const KNEX = path.normalize(__dirname + '/../../bin/cli.js');
const NODE_VERSION = Number((/v(\d+)/i.exec(process.version) || [])[1]);
Expand Down
2 changes: 1 addition & 1 deletion test/cli/migrate-unlock.spec.js
@@ -1,7 +1,7 @@
'use strict';

const path = require('path');
const sqlite3 = require('sqlite3');
const sqlite3 = require('@vscode/sqlite3');
const { expect } = require('chai');
const { execCommand } = require('cli-testlab');
const { getRootDir } = require('./cli-test-utils');
Expand Down
2 changes: 1 addition & 1 deletion test/cli/migrate.spec.js
@@ -1,7 +1,7 @@
'use strict';

const path = require('path');
const sqlite3 = require('sqlite3');
const sqlite3 = require('@vscode/sqlite3');
const { expect } = require('chai');
const { execCommand } = require('cli-testlab');
const { getRootDir, setupFileHelper } = require('./cli-test-utils');
Expand Down
4 changes: 2 additions & 2 deletions test/integration2/schema/alter.spec.js
Expand Up @@ -125,7 +125,7 @@ describe('Schema', () => {
knex('alter_table').insert({ column_notNullable: 'text' })
).to.be.rejectedWith(
Error,
"insert into `alter_table` (`column_notNullable`) values ('text') - SQLITE_CONSTRAINT: NOT NULL constraint failed: alter_table.column_string"
"insert into `alter_table` (`column_notNullable`) values ('text') - SQLITE_CONSTRAINT_NOTNULL: NOT NULL constraint failed: alter_table.column_string"
);
expect(tableAfter).to.equal(
"CREATE TABLE \"alter_table\" (`column_integer` integer DEFAULT '0', `column_string` varchar(255) NOT NULL, `column_datetime` datetime NOT NULL DEFAULT '0', `column_defaultTo` integer DEFAULT '0', `column_notNullable` varchar(255) NOT NULL, `column_defaultToAndNotNullable` datetime NOT NULL DEFAULT '0', `column_nullable` boolean NULL)"
Expand Down Expand Up @@ -163,7 +163,7 @@ describe('Schema', () => {
knex('alter_table').insert({ column_notNullable: 'text' })
).to.be.rejectedWith(
Error,
"insert into `alter_table` (`column_notNullable`) values ('text') - SQLITE_CONSTRAINT: NOT NULL constraint failed: alter_table.column_nullable"
"insert into `alter_table` (`column_notNullable`) values ('text') - SQLITE_CONSTRAINT_NOTNULL: NOT NULL constraint failed: alter_table.column_nullable"
);
expect(tableAfter).to.equal(
"CREATE TABLE \"alter_table\" (`column_integer` integer, `column_string` varchar(255), `column_datetime` datetime, `column_defaultTo` integer DEFAULT '0', `column_notNullable` varchar(255) NOT NULL, `column_defaultToAndNotNullable` datetime NOT NULL DEFAULT '0', `column_nullable` boolean NOT NULL)"
Expand Down
4 changes: 2 additions & 2 deletions test/integration2/schema/foreign-keys.spec.js
Expand Up @@ -201,7 +201,7 @@ describe('Schema', () => {
} catch (err) {
if (isSQLite(knex)) {
expect(err.message).to.equal(
`insert into \`foreign_keys_table_one\` (\`fkey_three\`, \`fkey_two\`) values (99, 9999) - SQLITE_CONSTRAINT: FOREIGN KEY constraint failed`
`insert into \`foreign_keys_table_one\` (\`fkey_three\`, \`fkey_two\`) values (99, 9999) - SQLITE_CONSTRAINT_FOREIGNKEY: FOREIGN KEY constraint failed`
);
}
if (isPostgreSQL(knex)) {
Expand Down Expand Up @@ -332,7 +332,7 @@ describe('Schema', () => {
} catch (err) {
if (isSQLite(knex)) {
expect(err.message).to.equal(
`insert into \`foreign_keys_table_one\` (\`fkey_four_part1\`, \`fkey_four_part2\`, \`fkey_three\`, \`fkey_two\`) values ('a', 'b', 99, 9999) - SQLITE_CONSTRAINT: FOREIGN KEY constraint failed`
`insert into \`foreign_keys_table_one\` (\`fkey_four_part1\`, \`fkey_four_part2\`, \`fkey_three\`, \`fkey_two\`) values ('a', 'b', 99, 9999) - SQLITE_CONSTRAINT_FOREIGNKEY: FOREIGN KEY constraint failed`
);
}
if (isPostgreSQL(knex)) {
Expand Down
8 changes: 4 additions & 4 deletions test/integration2/schema/primary-keys.spec.js
Expand Up @@ -47,7 +47,7 @@ describe('Schema', () => {
} catch (err) {
if (isSQLite(knex)) {
expect(err.message).to.equal(
'insert into `primary_table` (`id_four`) values (1) - SQLITE_CONSTRAINT: UNIQUE constraint failed: primary_table.id_four'
'insert into `primary_table` (`id_four`) values (1) - SQLITE_CONSTRAINT_PRIMARYKEY: UNIQUE constraint failed: primary_table.id_four'
);
}
if (isPgBased(knex)) {
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('Schema', () => {
} catch (err) {
if (isSQLite(knex)) {
expect(err.message).to.equal(
'insert into `primary_table` (`id_four`) values (1) - SQLITE_CONSTRAINT: UNIQUE constraint failed: primary_table.id_four'
'insert into `primary_table` (`id_four`) values (1) - SQLITE_CONSTRAINT_PRIMARYKEY: UNIQUE constraint failed: primary_table.id_four'
);
}
if (isPgBased(knex)) {
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('Schema', () => {
} catch (err) {
if (isSQLite(knex)) {
expect(err.message).to.equal(
'insert into `primary_table` (`id_three`, `id_two`) values (1, 1) - SQLITE_CONSTRAINT: UNIQUE constraint failed: primary_table.id_two, primary_table.id_three'
'insert into `primary_table` (`id_three`, `id_two`) values (1, 1) - SQLITE_CONSTRAINT_PRIMARYKEY: UNIQUE constraint failed: primary_table.id_two, primary_table.id_three'
);
}
if (isPgBased(knex)) {
Expand Down Expand Up @@ -156,7 +156,7 @@ describe('Schema', () => {
} catch (err) {
if (isSQLite(knex)) {
expect(err.message).to.equal(
'insert into `primary_table` (`id_three`, `id_two`) values (1, 1) - SQLITE_CONSTRAINT: UNIQUE constraint failed: primary_table.id_two, primary_table.id_three'
'insert into `primary_table` (`id_three`, `id_two`) values (1, 1) - SQLITE_CONSTRAINT_PRIMARYKEY: UNIQUE constraint failed: primary_table.id_two, primary_table.id_three'
);
}
if (isPgBased(knex)) {
Expand Down
2 changes: 1 addition & 1 deletion test/integration2/schema/set-nullable.spec.js
Expand Up @@ -90,7 +90,7 @@ describe('Schema', () => {
errorMessage = 'ORA-01400: cannot insert NULL into';
} else if (isSQLite(knex)) {
errorMessage =
'insert into `primary_table` (`id_not_nullable`, `id_nullable`) values (1, NULL) - SQLITE_CONSTRAINT: NOT NULL constraint failed: primary_table.id_nullable';
'insert into `primary_table` (`id_not_nullable`, `id_nullable`) values (1, NULL) - SQLITE_CONSTRAINT_NOTNULL: NOT NULL constraint failed: primary_table.id_nullable';
}

await expect(
Expand Down
2 changes: 1 addition & 1 deletion test/jake/jakelib/migrate-test.js
Expand Up @@ -6,7 +6,7 @@ const os = require('os');
const fs = require('fs');
const rimrafSync = require('rimraf').sync;
const path = require('path');
const sqlite3 = require('sqlite3');
const sqlite3 = require('@vscode/sqlite3');
const { assert } = require('chai');
const {
assertExec,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/knex.js
Expand Up @@ -2,7 +2,7 @@ const Knex = require('../../lib/index');
const QueryBuilder = require('../../lib/query/querybuilder');
const { expect } = require('chai');
const sqliteConfig = require('../knexfile').sqlite3;
const sqlite3 = require('sqlite3');
const sqlite3 = require('@vscode/sqlite3');
const { noop } = require('lodash');
const sinon = require('sinon');

Expand Down