New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sworm

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sworm - npm Package Compare versions

Comparing version 3.4.0 to 3.5.0

test/browser/websqlSpec.js

8

index.js

@@ -8,2 +8,3 @@ var crypto = require("crypto");

var sqliteDriver = require("./sqliteDriver");
var websqlDriver = require("./websqlDriver");
var debug = require("debug")("sworm");

@@ -463,3 +464,4 @@ var debugResults = require("debug")("sworm:results");

oracle: oracleDriver,
sqlite: sqliteDriver
sqlite: sqliteDriver,
websql: websqlDriver
}[this.config.driver];

@@ -573,4 +575,6 @@

function configFromUrl(url) {
var isBrowser = typeof window !== 'undefined'
var parsedUrl = urlUtils.parse(url)
var protocol = parsedUrl.protocol? parsedUrl.protocol.replace(/:$/, ''): 'sqlite'
var protocol = parsedUrl.protocol? parsedUrl.protocol.replace(/:$/, ''): (isBrowser? 'websql': 'sqlite')
var driver = {

@@ -577,0 +581,0 @@ postgres: 'pg',

{
"name": "sworm",
"version": "3.4.0",
"version": "3.5.0",
"description": "a lightweight write-only ORM for MSSQL, MySQL, PostgreSQL, Oracle, Sqlite 3",

@@ -17,2 +17,4 @@ "main": "index.js",

"chai-as-promised": "5.3.0",
"electron": "1.6.2",
"electron-mocha": "3.3.0",
"es6-promise": "3.2.1",

@@ -27,3 +29,3 @@ "fs-promise": "0.5.0",

"scripts": {
"test": "mocha"
"test": "mocha && electron-mocha --renderer test/browser"
},

@@ -30,0 +32,0 @@ "repository": {

@@ -10,2 +10,3 @@ # SWORM [![npm version](https://img.shields.io/npm/v/sworm.svg)](https://www.npmjs.com/package/sworm) [![npm](https://img.shields.io/npm/dm/sworm.svg)](https://www.npmjs.com/package/sworm) [![Build Status](https://travis-ci.org/featurist/sworm.svg?branch=master)](https://travis-ci.org/featurist/sworm)

* Sqlite 3
* Browser Web SQL

@@ -24,2 +25,4 @@ ## NPM

There's no need to install a driver for Web SQL, sworm will pick it up from the `window` object.
See [sworm](https://www.npmjs.org/package/sworm) in NPM.

@@ -163,3 +166,3 @@

* `options.driver`, one of `'mssql'`, `'mysql'`, `'pg'`, `'oracle'` or `'sqlite'`.
* `options.driver`, one of `'mssql'`, `'mysql'`, `'pg'`, `'oracle'`, `'sqlite'` or `'websql'`.
* `options.config` see configuration for databases in respective section below

@@ -307,2 +310,21 @@

* **websql**
URL: `websql:///db-name` or `db-name`
```js
{
driver: 'websql',
config: {
name: 'db-name',
// the `openDatabase` function to connect to the DB, defaulting to `window.openDatabase`
openDatabase: window.openDatabase,
// dababase size, defaulting to 5M
size: 5 * 1024 * 1024
}
}
```
### Close

@@ -333,2 +355,3 @@

* `sworm:sqlite` exact query passed to sqlite3
* `sworm:websql` exact query passed to websql

@@ -335,0 +358,0 @@ ## Models

@@ -13,19 +13,21 @@ var fs = require("fs-promise");

describe(name, function() {
describe("missing modules", function() {
var moduleName = __dirname + "/../node_modules/" + database.driverModuleName;
if (!database.noModule) {
describe("missing modules", function() {
var moduleName = __dirname + "/../node_modules/" + database.driverModuleName;
beforeEach(function() {
return fs.rename(moduleName, moduleName + ".missing");
});
beforeEach(function() {
return fs.rename(moduleName, moduleName + ".missing");
});
afterEach(function() {
return fs.rename(moduleName + ".missing", moduleName);
});
afterEach(function() {
return fs.rename(moduleName + ".missing", moduleName);
});
it("throws an exception if the driver module is not present", function() {
return expect(function() {
sworm.db(config).connect();
}).to.throw("npm install " + database.driverModuleName);
it("throws an exception if the driver module is not present", function() {
return expect(function() {
sworm.db(config).connect();
}).to.throw("npm install " + database.driverModuleName);
});
});
});
}

@@ -202,112 +204,125 @@ context('with a database', function () {

describe('transactions', function () {
beforeEach(function () {
if (database.setAutoCommit) {
database.setAutoCommit(false);
}
});
if (!database.hasOwnProperty('transactions') || database.transactions != false) {
describe('transactions', function () {
beforeEach(function () {
if (database.setAutoCommit) {
database.setAutoCommit(false);
}
});
afterEach(function () {
if (database.setAutoCommit) {
database.setAutoCommit(true);
}
});
afterEach(function () {
if (database.setAutoCommit) {
database.setAutoCommit(true);
}
});
describe('rollback', function () {
describe('explicit', function () {
it('rolls back when rollback is called', function () {
return db.begin().then(function () {
var bob = person({ name: 'bob' });
return bob.save().then(function () {
return db.query('select * from people');
}).then(function (people) {
expect(people).to.eql([
{
id: bob.id,
name: 'bob',
address_id: null,
photo: null
}
]);
}).then(function() {
return db.rollback();
}).then(function() {
return db.query('select * from people');
}).then(function(people) {
expect(people).to.eql([
]);
describe('rollback', function () {
describe('explicit', function () {
it('rolls back when rollback is called', function () {
return db.begin().then(function () {
var bob = person({ name: 'bob' });
return bob.save().then(function () {
return db.query('select * from people');
}).then(function (people) {
expect(people).to.eql([
{
id: bob.id,
name: 'bob',
address_id: null,
photo: null
}
]);
}).then(function() {
return db.rollback();
}).then(function() {
return db.query('select * from people');
}).then(function(people) {
expect(people).to.eql([
]);
});
});
});
});
});
describe('scoped', function () {
it('rolls back if the transaction scope throws an exception', function () {
return expect(db.transaction(function () {
var bob = person({ name: 'bob' });
return bob.save().then(function() {
describe('scoped', function () {
it('rolls back if the transaction scope throws an exception', function () {
return expect(db.transaction(function () {
var bob = person({ name: 'bob' });
return bob.save().then(function() {
return db.query('select * from people');
}).then(function(people) {
expect(people).to.eql([
{
id: bob.id,
name: 'bob',
address_id: null,
photo: null
}
]);
throw new Error('uh oh');
});
})).to.be.rejectedWith('uh oh').then(function() {
return db.query('select * from people');
}).then(function(people) {
expect(people).to.eql([
{
id: bob.id,
name: 'bob',
address_id: null,
photo: null
}
]);
throw new Error('uh oh');
});
})).to.be.rejectedWith('uh oh').then(function() {
return db.query('select * from people');
}).then(function(people) {
expect(people).to.eql([
]);
});
});
});
});
describe('commit', function () {
describe('explicit', function () {
it('makes changes after commit is called', function () {
return db.begin().then(function () {
var bob = person({ name: 'bob' });
return bob.save().then(function() {
return db.query('select * from people');
}).then(function(people) {
expect(people).to.eql([
{
id: bob.id,
name: 'bob',
address_id: null,
photo: null
}
]);
}).then(function() {
return db.commit();
}).then(function() {
return db.query('select * from people');
}).then(function(people) {
expect(people).to.eql([
{
id: bob.id,
name: 'bob',
address_id: null,
photo: null
}
]);
describe('commit', function () {
describe('explicit', function () {
it('makes changes after commit is called', function () {
return db.begin().then(function () {
var bob = person({ name: 'bob' });
return bob.save().then(function() {
return db.query('select * from people');
}).then(function(people) {
expect(people).to.eql([
{
id: bob.id,
name: 'bob',
address_id: null,
photo: null
}
]);
}).then(function() {
return db.commit();
}).then(function() {
return db.query('select * from people');
}).then(function(people) {
expect(people).to.eql([
{
id: bob.id,
name: 'bob',
address_id: null,
photo: null
}
]);
});
});
});
});
});
describe('scoped', function () {
it('makes changes after commit is called', function () {
var bob;
describe('scoped', function () {
it('makes changes after commit is called', function () {
var bob;
return db.transaction(function () {
bob = person({ name: 'bob' });
return bob.save().then(function() {
return db.transaction(function () {
bob = person({ name: 'bob' });
return bob.save().then(function() {
return db.query('select * from people');
}).then(function(people) {
expect(people).to.eql([
{
id: bob.id,
name: 'bob',
address_id: null,
photo: null
}
]);
});
}).then(function() {
return db.query('select * from people');

@@ -324,13 +339,2 @@ }).then(function(people) {

});
}).then(function() {
return db.query('select * from people');
}).then(function(people) {
expect(people).to.eql([
{
id: bob.id,
name: 'bob',
address_id: null,
photo: null
}
]);
});

@@ -340,3 +344,11 @@ });

});
});
} else {
describe('no transactions', function () {
it('throws when asked to create a new transaction', function () {
expect(function () {
db.begin()
}).to.throw('transactions are not supported')
})
})
}

@@ -1074,3 +1086,3 @@ describe("concurrency", function() {

return db.query("select * from addresses").then(function(addresses) {
return db.query('select * from addresses order by address').then(function(addresses) {
return expect(database.clean(addresses)).to.eql([

@@ -1077,0 +1089,0 @@ {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc