Huge News!Announcing our $40M Series B led by Abstract Ventures.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 2.8.1 to 2.9.0

43

oracleDriver.js
var optionalRequire = require('./optionalRequire');
var promisify = require('./promisify');
var debug = require('debug')('sworm:oracle');
var swormDebug = require('debug')('sworm');
var _ = require('underscore');
var urlUtils = require('url');
var redactConfig = require('./redactConfig');

@@ -40,5 +42,5 @@ module.exports = function () {

connect: function (_config) {
connect: function (swormConfig) {
var self = this;
var config = _config.url? parseUrl(_config.url): _config.config;
var config = swormConfig.url? parseUrl(swormConfig.url): swormConfig.config;

@@ -53,3 +55,3 @@ if (config.options) {

if (config.pool === true) {
return self.connectionPool(config).then(pool => {
return connectionPool(oracledb, config, swormConfig).then(pool => {
return promisify(cb => pool.getConnection(cb));

@@ -69,18 +71,2 @@ });

connectionPoolCache: {},
connectionPool: function(config) {
var key = JSON.stringify(config);
var value = this.connectionPoolCache[key];
if (!value) {
value = this.connectionPoolCache[key] = promisify(function (cb) {
oracledb.createPool(config, cb);
});
}
return value;
},
close: function () {

@@ -183,1 +169,20 @@ var self = this;

}
var connectionPoolCache = {};
module.exports.connectionPoolCache = connectionPoolCache;
function connectionPool(oracledb, config, swormConfig) {
var key = JSON.stringify(config);
var value = connectionPoolCache[key];
if (!value) {
value = connectionPoolCache[key] = promisify(function (cb) {
swormDebug('creating connection pool', redactConfig(swormConfig));
oracledb.createPool(config, cb);
});
}
return value;
}
{
"name": "sworm",
"version": "2.8.1",
"version": "2.9.0",
"description": "a lightweight write-only ORM for MSSQL, MySQL, PostgreSQL, Oracle, Sqlite 3",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,3 +9,3 @@ var urlUtils = require('url');

if (/darwin/i.test(os.type())) {
module.exports = '192.168.64.2';
module.exports = 'docker.local';
} else {

@@ -12,0 +12,0 @@ module.exports = 'localhost';

@@ -6,2 +6,3 @@ if (!process.env.TRAVIS) {

var oracledb = require('oracledb');
var driver = require('../oracleDriver');
var expect = require('chai').expect;

@@ -124,9 +125,17 @@ var _ = require('underscore');

var db;
var db1;
var db2;
afterEach(function () {
return db.close();
return Promise.all([
db? db.close(): undefined,
db1? db1.close(): undefined
]).then(() => {
db = undefined;
db1 = undefined;
});
});
function numberOfPools() {
return db.driver? Object.keys(db.driver.connectionPoolCache).length: 0;
return Object.keys(driver.connectionPoolCache).length;
}

@@ -143,18 +152,31 @@

it("pools connections when pool: true", function () {
db = sworm.db(config({pool: true}));
function testConnectionPooling(config) {
var db1 = sworm.db(config);
var poolsBefore = numberOfPools();
return db.query('select * from people').then((rows) => {
return db1.query('select * from people').then((rows) => {
expect(rows).to.eql([]);
expect(numberOfPools()).to.equal(poolsBefore + 1);
}).then(() => {
db2 = sworm.db(config);
return db2.query('select * from people').then((rows) => {
expect(rows).to.eql([]);
expect(numberOfPools()).to.equal(poolsBefore + 1);
}).then(() => {
return db2.close();
});
}).then(() => {
return db1.query('select * from people').then((rows) => {
expect(rows).to.eql([]);
expect(numberOfPools()).to.equal(poolsBefore + 1);
});
});
}
it("pools connections when pool: true", function () {
return testConnectionPooling(config({pool: true}));
});
it("pools connections when &pool=true", function () {
db = sworm.db(urlConfig({pool: true}));
var poolsBefore = numberOfPools();
return db.query('select * from people').then((rows) => {
expect(rows).to.eql([]);
expect(numberOfPools()).to.equal(poolsBefore + 1);
});
return testConnectionPooling(urlConfig({pool: true}));
});

@@ -161,0 +183,0 @@ });

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