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

odbc

Package Overview
Dependencies
Maintainers
3
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

odbc - npm Package Compare versions

Comparing version 2.4.0-alpha.0 to 2.4.0-beta.0

lib/Cursor.js

74

lib/Connection.js
const { Statement } = require('./Statement');
const { Cursor } = require('./Cursor');

@@ -29,18 +30,41 @@ class Connection {

*/
query(sql, params, cb) {
query(sql, params, opts, cb) {
// accepted parameter signatures:
// sql
// sql, params
// sql, opts
// sql, params, opts
// sql, cb
// sql, params, cb
// sql, opts, cb
// sql, params, opts, cb
let callback = cb;
let parameters = params;
let options = opts;
if (typeof callback === 'undefined') {
if (typeof parameters === 'function') {
// If callback is undefined, search for a function in another position
if (typeof callback === 'undefined')
{
if (typeof options === 'function')
{
callback = options;
options = undefined;
}
else if(typeof parameters === 'function')
{
callback = parameters;
options = undefined;
parameters = undefined;
}
}
if (typeof options === 'undefined')
{
if (typeof parameters === 'object' && parameters !== null && !Array.isArray(parameters))
{
options = parameters;
parameters = null;
} else if (typeof parameters === 'undefined') {
parameters = null;
} else {
options = null;
}

@@ -54,6 +78,10 @@ }

if (typeof sql !== 'string'
|| (parameters !== null && !Array.isArray(parameters))
|| (typeof callback !== 'function' && typeof callback !== 'undefined')) {
throw new TypeError('[node-odbc]: Incorrect function signature for call to connection.query({string}, {array}[optional], {function}[optional]).');
if (
typeof sql !== 'string' ||
(parameters !== null && !Array.isArray(parameters)) ||
(options !== null && typeof options !== 'object') ||
(typeof callback !== 'function' && typeof callback !== 'undefined')
)
{
throw new TypeError('[node-odbc]: Incorrect function signature for call to connection.query({string}, {array}[optional], {object}[optional], {function}[optional]).');
}

@@ -63,7 +91,15 @@

return new Promise((resolve, reject) => {
this.odbcConnection.query(sql, parameters, (error, result) => {
this.odbcConnection.query(sql, parameters, options, (error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
if (options && options.hasOwnProperty('fetchSize'))
{
const cursor = new Cursor(result);
resolve(cursor);
}
else
{
resolve(result);
}
}

@@ -75,3 +111,17 @@ });

process.nextTick(() => {
this.odbcConnection.query(sql, parameters, callback);
if (options && options.hasOwnProperty('fetchSize'))
{
this.odbcConnection.query(sql, parameters, options, (error, result) => {
if (error) {
return callback(error);
}
const cursor = new Cursor(result);
return callback(error, cursor);
});
}
else
{
this.odbcConnection.query(sql, parameters, options, callback);
}
})

@@ -78,0 +128,0 @@ }

8

lib/odbc.d.ts

@@ -58,4 +58,4 @@ declare namespace odbc {

////////////////////////////////////////////////////////////////////////////
query(sql: string, callback: (error: NodeOdbcError, result: Result<unknown>) => undefined): undefined;
query(sql: string, parameters: Array<number|string>, callback: (error: NodeOdbcError, result: Result<unknown>) => undefined): undefined;
query<T>(sql: string, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
query<T>(sql: string, parameters: Array<number|string>, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;

@@ -85,3 +85,3 @@ callProcedure(catalog: string, schema: string, name: string, callback: (error: NodeOdbcError, result: Result<unknown>) => undefined): undefined;

query(sql: string, parameters?: Array<number|string>): Promise<Result<unknown>>;
query<T>(sql: string, parameters?: Array<number|string>): Promise<Result<T>>;

@@ -144,2 +144,2 @@ callProcedure(catalog: string, schema: string, name: string, parameters?: Array<number|string>): Promise<Result<unknown>>;

export = odbc;
export = odbc;

@@ -15,3 +15,3 @@ const EventEmitter = require('events');

const INCREMENT_SIZE_DEFAULT = 10;
const MAX_SIZE_DEFAULT = null;
const MAX_SIZE_DEFAULT = Number.MAX_SAFE_INTEGER;
const SHRINK_DEFAULT = true;

@@ -46,2 +46,3 @@ const CONNECTION_TIMEOUT_DEFAULT = 0;

this.connectingCount = 0;
this.poolSize = 0;
this.connectionQueue = [];

@@ -78,3 +79,3 @@

// maxSize
this.maxSize = configObject.incrementSize !== undefined ? configObject.incrementSize : INCREMENT_SIZE_DEFAULT;
this.maxSize = configObject.maxSize !== undefined ? configObject.maxSize : MAX_SIZE_DEFAULT;

@@ -107,5 +108,8 @@ // shrink

// If the number of connections waiting is more (shouldn't happen) or
// equal to the number of connections connecting, then we will need to
// create MORE connections.
if (this.connectingCount <= this.connectionQueue.length)
// equal to the number of connections connecting, and the number of
// connections in the pool, in the process of connecting and that will be
// added is less than the maximum number of allowable connections, then
// we will need to create MORE connections.
if (this.connectingCount <= this.connectionQueue.length &&
this.poolSize + this.connectingCount + this.incrementSize <= this.maxSize)
{

@@ -203,2 +207,3 @@ this.increasePoolSize(this.incrementSize);

connection.nativeClose((error) => {
this.poolSize--;
cb(error);

@@ -218,2 +223,3 @@ });

connection.nativeClose((error) => {
this.poolSize--;
cb(error);

@@ -263,3 +269,3 @@ });

odbc.connect(connectionConfig, (error, nativeConnection) => {
let connection = undefined;
this.connectingCount--;
if (error) {

@@ -270,3 +276,4 @@ reject(error);

connection = new Connection(nativeConnection);
this.poolSize++;
let connection = new Connection(nativeConnection);
connection.nativeClose = connection.close;

@@ -292,2 +299,3 @@

connection.nativeClose((error, result) => {
this.poolSize--;
if (error) {

@@ -306,3 +314,2 @@ reject(error);

this.connectingCount--;
this.connectionEmitter.emit('connected', connection);

@@ -309,0 +316,0 @@ resolve();

{
"name": "odbc",
"description": "unixodbc bindings for node",
"version": "2.4.0-alpha.0",
"version": "2.4.0-beta.0",
"homepage": "http://github.com/markdirish/node-odbc/",

@@ -6,0 +6,0 @@ "main": "lib/odbc.js",

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc