Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pg-sql2

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-sql2 - npm Package Compare versions

Comparing version 2.2.2 to 2.2.3

24

lib/index.js

@@ -20,3 +20,3 @@ "use strict";

function makeIdentifierNode(names) {
if (!Array.isArray(names) || !names.every(isStringOrSymbol)) {
if (!Array.isArray(names) || names.length === 0 || !names.every(isStringOrSymbol)) {
throw new Error("Invalid argument to makeIdentifierNode - expected array of strings/symbols");

@@ -58,15 +58,8 @@ }

for (let itemIndex = 0; itemIndex < itemCount; itemIndex++) {
const rawItem = items[itemIndex];
const item = enforceValidNode(rawItem);
const item = enforceValidNode(items[itemIndex]);
switch (item.type) {
case "RAW":
if (typeof item.text !== "string") {
throw new Error("RAW node expected string");
}
sqlFragments[itemIndex] = item.text;
break;
case "IDENTIFIER":
if (item.names.length === 0) {
throw new Error("Identifier must have a name");
}
case "IDENTIFIER": {
const nameCount = item.names.length;

@@ -97,2 +90,3 @@ const mappedNames = new Array(nameCount);

break;
}
case "VALUE":

@@ -114,3 +108,3 @@ values.push(item.value);

function enforceValidNode(node) {
if (node !== null && typeof node === "object" && node[$$trusted] === true) {
if (node !== null && node[$$trusted] === true) {
return node;

@@ -248,9 +242,5 @@ }

// Trivial performance optimisations by Benjie.
// Replaced with regexp because it's 11x faster by Benjie.
function escapeSqlIdentifier(str) {
let escaped = "";
for (let i = 0, l = str.length; i < l; i++) {
const c = str[i];
escaped += c === '"' ? '""' : c;
}
return '"' + escaped + '"';
return `"${str.replace(/"/g, '""')}"`;
}

@@ -257,0 +247,0 @@ exports.escapeSqlIdentifier = escapeSqlIdentifier;

{
"name": "pg-sql2",
"version": "2.2.2",
"version": "2.2.3",
"description": "Generate safe Postgres-compliant SQL with tagged template literals",

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

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