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

postgrejs

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postgrejs - npm Package Compare versions

Comparing version 2.22.1 to 2.22.2

9

CHANGELOG.md

@@ -0,3 +1,10 @@

# v2.22.2
[2024-11-04]
### Changes
* refactor: Improved displaying error line ([`3a6bbe9`](https://github.com/panates/postgrejs/commit/3a6bbe929efdb4f46a38c7b9626b4f28739ad341))
# v2.22.1
[2024-10-15]
[2024-10-16]

@@ -4,0 +11,0 @@ # v2.22.0

21

cjs/connection/connection.js

@@ -136,2 +136,3 @@ "use strict";

async execute(sql, options) {
this.emit('execute', sql, options);
return this._captureErrorStack(this._intlCon.execute(sql, options)).catch((e) => {

@@ -152,2 +153,3 @@ throw this._handleError(e, sql);

}
this.emit('query', sql, options);
const typeMap = options?.typeMap || data_type_map_js_1.GlobalTypeMap;

@@ -256,13 +258,12 @@ const paramTypes = options?.params?.map(prm => prm instanceof bind_param_js_1.BindParam ? prm.oid : typeMap.determine(prm));

_handleError(err, script) {
if (err.position) {
const i1 = script.lastIndexOf('\n', err.position) + 1;
let i2 = script.indexOf('\n', err.position);
if (i2 < 0)
i2 = Number.MAX_SAFE_INTEGER;
err.line = script.substring(i1, i2);
err.lineNr = [...script.substring(0, i1).matchAll(/\n/g)].length;
if (err.position != null) {
const i1 = script.lastIndexOf('\n', err.position - 1) + 1;
err.lineNr = [...script.substring(0, i1).matchAll(/\n/g)].length + 1;
err.colNr = err.position - i1;
err.message +=
`\nAt line ${err.lineNr} column ${err.colNr}` +
`\n | ${err.line}\n | ${' '.repeat(Math.max(err.colNr - 2, 0))}-^-`;
const lines = script.split('\n');
err.line = lines[err.lineNr - 1];
err.message += `\n at line ${err.lineNr} column ${err.colNr}`;
if (err.lineNr > 1)
err.message += `\n${String(err.lineNr - 1).padStart(3)}| ${lines[err.lineNr - 2]}`;
err.message += `\n${String(err.lineNr).padStart(3)}| ${err.line}\n .${'-'.repeat(Math.max(err.colNr - 1, 0))}^`;
}

@@ -269,0 +270,0 @@ return err;

@@ -138,2 +138,6 @@ "use strict";

connection.on('debug', (...args) => this.emit('debug', ...args));
if (this.listenerCount('execute'))
connection.on('execute', (...args) => this.emit('execute', ...args));
if (this.listenerCount('query'))
connection.on('query', (...args) => this.emit('query', ...args));
return connection;

@@ -140,0 +144,0 @@ }

@@ -133,2 +133,3 @@ import { ConnectionState } from '../constants.js';

async execute(sql, options) {
this.emit('execute', sql, options);
return this._captureErrorStack(this._intlCon.execute(sql, options)).catch((e) => {

@@ -149,2 +150,3 @@ throw this._handleError(e, sql);

}
this.emit('query', sql, options);
const typeMap = options?.typeMap || GlobalTypeMap;

@@ -253,13 +255,12 @@ const paramTypes = options?.params?.map(prm => prm instanceof BindParam ? prm.oid : typeMap.determine(prm));

_handleError(err, script) {
if (err.position) {
const i1 = script.lastIndexOf('\n', err.position) + 1;
let i2 = script.indexOf('\n', err.position);
if (i2 < 0)
i2 = Number.MAX_SAFE_INTEGER;
err.line = script.substring(i1, i2);
err.lineNr = [...script.substring(0, i1).matchAll(/\n/g)].length;
if (err.position != null) {
const i1 = script.lastIndexOf('\n', err.position - 1) + 1;
err.lineNr = [...script.substring(0, i1).matchAll(/\n/g)].length + 1;
err.colNr = err.position - i1;
err.message +=
`\nAt line ${err.lineNr} column ${err.colNr}` +
`\n | ${err.line}\n | ${' '.repeat(Math.max(err.colNr - 2, 0))}-^-`;
const lines = script.split('\n');
err.line = lines[err.lineNr - 1];
err.message += `\n at line ${err.lineNr} column ${err.colNr}`;
if (err.lineNr > 1)
err.message += `\n${String(err.lineNr - 1).padStart(3)}| ${lines[err.lineNr - 2]}`;
err.message += `\n${String(err.lineNr).padStart(3)}| ${err.line}\n .${'-'.repeat(Math.max(err.colNr - 1, 0))}^`;
}

@@ -266,0 +267,0 @@ return err;

@@ -135,2 +135,6 @@ import { Pool as LightningPool } from 'lightning-pool';

connection.on('debug', (...args) => this.emit('debug', ...args));
if (this.listenerCount('execute'))
connection.on('execute', (...args) => this.emit('execute', ...args));
if (this.listenerCount('query'))
connection.on('query', (...args) => this.emit('query', ...args));
return connection;

@@ -137,0 +141,0 @@ }

{
"name": "postgrejs",
"description": "Professional PostgreSQL client NodeJS",
"version": "2.22.1",
"version": "2.22.2",
"author": "Panates",

@@ -15,3 +15,3 @@ "license": "MIT",

"putil-varhelpers": "^1.6.5",
"tslib": "^2.8.0"
"tslib": "^2.8.1"
},

@@ -18,0 +18,0 @@ "type": "module",

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