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

@nearform/sql

Package Overview
Dependencies
Maintainers
17
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nearform/sql - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

3

benchmark/index.js

@@ -13,3 +13,4 @@ const Benchmark = require('benchmark')

.add('@nearform/sql', function () {
SQL1`INSERT INTO users (username, email, password) VALUES (${username},${email},${password})`
const result = SQL1`INSERT INTO users (username, email, password) VALUES (${username},${email},${password})`
return result.text
})

@@ -16,0 +17,0 @@ .add('sql-template-strings', function () {

{
"name": "@nearform/sql",
"version": "1.0.0",
"version": "1.0.1",
"description": "",

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

# SQL
[![build status][1]][2] [![js-standard-style][3]][4]
A simple SQL injection protection module that allows you to use ES6 template strings for escaped statements. Works with [pg](https://www.npmjs.com/package/pg) library.
A simple SQL injection protection module that allows you to use ES6 template strings for escaped statements. Works with [postgres](https://www.npmjs.com/package/pg).
[![npm version][1]][2] [![build status][3]][4] [![js-standard-style][5]][6]
1. [Install](#install)

@@ -32,3 +34,7 @@ 2. [Usage](#usage)

const sql = SQL`INSERT INTO users (username, email, password) VALUES (${username},${email},${password})` // generate SQL query
// generate SQL query
const sql = SQL`
INSERT INTO users (username, email, password)
VALUES (${username},${email},${password})
`

@@ -66,3 +72,3 @@ db.query(sql) // execute query

## How it works?
The SQL template string tag parses query and returns an objects that's understandable by postgres:
The SQL template string tag parses query and returns an objects that's understandable by [pg](https://www.npmjs.com/package/pg) library:
```js

@@ -94,5 +100,7 @@ const username = 'user'

[1]: https://circleci.com/gh/nearform/sql/tree/master.svg?style=shield&circle-token=ec5a946d225c797d503fc5a748137db7b82ab47f
[2]: https://circleci.com/gh/nearform/sql
[3]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[4]: https://github.com/feross/standard
[1]: https://img.shields.io/npm/v/@nearform/sql.svg?style=flat-square
[2]: https://npmjs.org/package/@nearform/sql
[3]: https://circleci.com/gh/nearform/sql/tree/master.svg?style=shield&circle-token=ec5a946d225c797d503fc5a748137db7b82ab47f
[4]: https://circleci.com/gh/nearform/sql
[5]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[6]: https://github.com/feross/standard

@@ -44,3 +44,3 @@ class SqlStatement {

return text.replace(/^\s+/, '')
return text.replace(/^\s+|\s+$/mg, '')
}

@@ -47,0 +47,0 @@

@@ -19,2 +19,18 @@ const test = require('tap').test

test('SQL helper - multiline', (t) => {
const name = 'Team 5'
const description = 'description'
const teamId = 7
const organizationId = 'WONKA'
const sql = SQL`
UPDATE teams SET name = ${name}, description = ${description}
WHERE id = ${teamId} AND org_id = ${organizationId}
`
t.equal(sql.text, 'UPDATE teams SET name = $1, description = $2\nWHERE id = $3 AND org_id = $4')
t.deepEqual(sql.values, [name, description, teamId, organizationId])
t.end()
})
test('SQL helper - build complex query with glue', (t) => {

@@ -21,0 +37,0 @@ const name = 'Team 5'

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