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

@databases/sql

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@databases/sql - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

lib/SQL.d.ts

30

lib/index.d.ts
import SQLQuery from './SQLQuery';
export { SQLQuery };
/**
* The interface we actually expect people to use.
*/
export interface SQL {
(strings: TemplateStringsArray, ...values: Array<any>): SQLQuery;
/**
* Joins multiple queries together and puts a separator in between if a
* separator was defined.
*/
join(queries: Array<SQLQuery>, separator?: SQLQuery): SQLQuery;
/**
* Joins multiple queries together and puts a separator in between if a
* separator was defined.
*/
join(queries: Array<SQLQuery>, separator: ',' | ', ' | ' AND ' | ' OR '): SQLQuery;
/**
* Joins multiple queries together and puts a separator in between if a
* separator was defined.
*
* @deprecated please do not pass the separator as a string, use sql`` to mark it as an SQL string
*/
join(queries: Array<SQLQuery>, separator: string): SQLQuery;
__dangerous__rawValue(text: string): SQLQuery;
import SQLBase from './SQL';
export interface SQL extends SQLBase {
file(filename: string): SQLQuery;
value(value: any): SQLQuery;
ident(...names: Array<any>): SQLQuery;
registerFormatter<T>(constructor: new (...args: any[]) => T, format: (value: T) => SQLQuery): void;
}
export { SQLQuery };
declare const modifiedSQL: SQL;
export default modifiedSQL;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = require("fs");
const minify = require("pg-minify");
const SQLQuery_1 = require("./SQLQuery");
exports.SQLQuery = SQLQuery_1.default;
SQLQuery_1.setPgMinify(minify);
SQLQuery_1.setReadFileSync(fs_1.readFileSync);
// Create the SQL interface we export.

@@ -12,3 +16,3 @@ const modifiedSQL = Object.assign((strings, ...values) => SQLQuery_1.default.query(strings, ...values), {

__dangerous__rawValue: SQLQuery_1.default.raw,
file: SQLQuery_1.default.file,
file: filename => SQLQuery_1.default.file(filename),
value: SQLQuery_1.default.value,

@@ -15,0 +19,0 @@ ident: SQLQuery_1.default.ident,

@@ -31,2 +31,6 @@ /**

}
export declare type MinifyFunction = (src: string) => string;
export declare type ReadFileSync = (filename: string, format: 'utf8') => string;
export declare function setPgMinify(minify: MinifyFunction): void;
export declare function setReadFileSync(readFileSyncArg: ReadFileSync): void;
/**

@@ -57,3 +61,3 @@ * The representation of a SQL query. Call `compile` to turn it into a SQL

*/
static join(queries: Array<SQLQuery>, separator: ',' | ', ' | ' AND ' | ' OR '): SQLQuery;
static join(queries: Array<SQLQuery>, separator: ',' | ', ' | ' AND ' | ' OR ' | ') AND (' | ') OR (' | ';'): SQLQuery;
/**

@@ -60,0 +64,0 @@ * Joins multiple queries together and puts a separator in between if a

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const minify = require("pg-minify");
const fs_1 = require("fs");
const warnedJoinSeparators = new Set();

@@ -15,2 +13,14 @@ var SQLItemType;

const DEFAULT_COMPILE_OPTIONS = { minify: true };
let pgMinify = s => s;
let readFileSync = () => {
throw new Error('This environment does not support reading files');
};
function setPgMinify(minify) {
pgMinify = minify;
}
exports.setPgMinify = setPgMinify;
function setReadFileSync(readFileSyncArg) {
readFileSync = readFileSyncArg;
}
exports.setReadFileSync = setReadFileSync;
/**

@@ -78,3 +88,3 @@ * The representation of a SQL query. Call `compile` to turn it into a SQL

static join(queries, separator) {
if (typeof separator === 'string' && ![',', ', ', ' AND ', ' OR ', ') AND (', ') OR ('].includes(separator) && !warnedJoinSeparators.has(separator)) {
if (typeof separator === 'string' && ![',', ', ', ' AND ', ' OR ', ') AND (', ') OR (', ';'].includes(separator) && !warnedJoinSeparators.has(separator)) {
warnedJoinSeparators.add(separator);

@@ -102,3 +112,3 @@ const err = new Error(`Passing join separators as a string is deprecated, please tag your string as an SQL query via "sql.join(..., sql\`${separator.includes('`') ? 'your_separator' : separator}\`)"`);

static file(filename) {
return new SQLQuery([{ type: SQLItemType.RAW, text: fs_1.readFileSync(filename, 'utf8') }]);
return new SQLQuery([{ type: SQLItemType.RAW, text: readFileSync(filename, 'utf8') }]);
}

@@ -204,3 +214,3 @@ /**

if (options.minify) {
query.text = minify(query.text);
query.text = pgMinify(query.text);
}

@@ -207,0 +217,0 @@ return query;

{
"name": "@databases/sql",
"version": "2.0.0",
"version": "2.1.0",
"description": "",

@@ -22,4 +22,6 @@ "main": "./lib/index.js",

"files": [
"lib/"
"lib/",
"web.js",
"web.d.ts"
]
}

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