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

@imatic/pgqb

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@imatic/pgqb - npm Package Compare versions

Comparing version 0.1.30 to 0.1.31

2

dist/index.js

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

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};

@@ -13,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

@@ -22,3 +22,7 @@ export interface InlineParam {

export declare type Expr = [BinaryOperator, ExprOperand, ExprOperand] | string | VarExpr | FunctionCall | [UnaryOperator, any] | Value | Sql;
export declare type Join = ['INNER' | 'LEFT' | 'RIGHT' | 'FULL' | 'CROSS', TableExpr, Expr];
export declare type Join = [
'INNER' | 'LEFT' | 'RIGHT' | 'FULL' | 'CROSS',
TableExpr,
Expr
];
export declare type OrderBy = [Expr, 'ASC' | 'DESC', 'NULLS FIRST' | 'NULLS LAST'];

@@ -25,0 +29,0 @@ export interface Sql {

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

}
return sql_template_strings_1.SQL `(`.append(text).append(')');
return (0, sql_template_strings_1.SQL) `(`.append(text).append(')');
}

@@ -109,3 +109,3 @@ /**

return intersperse(', ', row.map((v) => convertValue(v)))
.reduce((sql, part) => sql.append(part), sql_template_strings_1.SQL `(`)
.reduce((sql, part) => sql.append(part), (0, sql_template_strings_1.SQL) `(`)
.append(')');

@@ -124,7 +124,7 @@ }

if (inlineParam !== undefined) {
return sql_template_strings_1.SQL `${inlineParam}`;
return (0, sql_template_strings_1.SQL) `${inlineParam}`;
}
const rawValue = val['r'];
if (rawValue !== undefined) {
return sql_template_strings_1.SQL ``.append(rawValue);
return (0, sql_template_strings_1.SQL) ``.append(rawValue);
}

@@ -146,3 +146,3 @@ throw new Error(`Invalid expr value: ${JSON.stringify(val)}`);

? convertObjectValue(val)
: sql_template_strings_1.SQL ``.append(escape(val));
: (0, sql_template_strings_1.SQL) ``.append(escape(val));
}

@@ -201,3 +201,3 @@ /**

function varOperatorHandler(operator) {
return (...exprs) => wrapInParens(appendToStatement(sql_template_strings_1.SQL ``, intersperse(` ${operator} `, exprs.map((expr) => handleExpr(expr)))));
return (...exprs) => wrapInParens(appendToStatement((0, sql_template_strings_1.SQL) ``, intersperse(` ${operator} `, exprs.map((expr) => handleExpr(expr)))));
}

@@ -231,7 +231,7 @@ /**

return statements.length === 2
? sql_template_strings_1.SQL `WHEN `
? (0, sql_template_strings_1.SQL) `WHEN `
.append(statements[0])
.append(' THEN ')
.append(statements[1])
: sql_template_strings_1.SQL `ELSE `.append(statements[0]);
: (0, sql_template_strings_1.SQL) `ELSE `.append(statements[0]);
}

@@ -268,3 +268,3 @@ function notInHandler(expr, ...vals) {

as: binaryOperatorHandler('as'),
'%': (f, ...args) => sql_template_strings_1.SQL ``.append(f.toUpperCase()).append(wrapInParens(appendToStatement(sql_template_strings_1.SQL ``, intersperse(', ', args.map((expr) => handleExpr(expr)))))),
'%': (f, ...args) => (0, sql_template_strings_1.SQL) ``.append(f.toUpperCase()).append(wrapInParens(appendToStatement((0, sql_template_strings_1.SQL) ``, intersperse(', ', args.map((expr) => handleExpr(expr)))))),
and: varOperatorHandler('AND'),

@@ -274,5 +274,5 @@ or: varOperatorHandler('OR'),

not_null: (expr) => handleExpr(expr).append(' IS NOT NULL'),
not: (expr) => sql_template_strings_1.SQL `NOT `.append(wrapInParens(handleExpr(expr))),
exists: (sqlMap) => sql_template_strings_1.SQL `EXISTS `.append(wrapInParens(handleExpr(sqlMap))),
case_when: (...args) => appendToStatement(sql_template_strings_1.SQL `CASE `, intersperse(' ', splitEvery(2, args.map((expr) => handleExpr(expr))).map((statements) => handleCaseExprTuple(statements)))).append(' END'),
not: (expr) => (0, sql_template_strings_1.SQL) `NOT `.append(wrapInParens(handleExpr(expr))),
exists: (sqlMap) => (0, sql_template_strings_1.SQL) `EXISTS `.append(wrapInParens(handleExpr(sqlMap))),
case_when: (...args) => appendToStatement((0, sql_template_strings_1.SQL) `CASE `, intersperse(' ', splitEvery(2, args.map((expr) => handleExpr(expr))).map((statements) => handleCaseExprTuple(statements)))).append(' END'),
in: inHandler,

@@ -293,3 +293,3 @@ not_in: notInHandler,

return function (exprs) {
return appendToStatement(sql_template_strings_1.SQL ``.append(statementStart), intersperse(', ', exprs.map((expr) => handleExpr(expr))));
return appendToStatement((0, sql_template_strings_1.SQL) ``.append(statementStart), intersperse(', ', exprs.map((expr) => handleExpr(expr))));
};

@@ -305,3 +305,3 @@ }

return function (table) {
return sql_template_strings_1.SQL ``.append(statementStart).append(tableExpr(table));
return (0, sql_template_strings_1.SQL) ``.append(statementStart).append(tableExpr(table));
};

@@ -318,3 +318,3 @@ }

select_distinct: ({ on, exprs }) => {
const onSt = appendToStatement(sql_template_strings_1.SQL `SELECT DISTINCT ON (`, intersperse(', ', on.map((expr) => handleExpr(expr)))).append(') ');
const onSt = appendToStatement((0, sql_template_strings_1.SQL) `SELECT DISTINCT ON (`, intersperse(', ', on.map((expr) => handleExpr(expr)))).append(') ');
return appendToStatement(onSt, intersperse(', ', exprs.map((expr) => handleExpr(expr))));

@@ -325,3 +325,3 @@ },

columns: (columns) => columnList(columns),
values: (list) => list.length === 0 ? 'DEFAULT VALUES' : appendToStatement(sql_template_strings_1.SQL `VALUES `, intersperse(', ', list.map((row) => valueList(row)))),
values: (list) => list.length === 0 ? 'DEFAULT VALUES' : appendToStatement((0, sql_template_strings_1.SQL) `VALUES `, intersperse(', ', list.map((row) => valueList(row)))),
on_conflict: (columns) => `ON CONFLICT ${columnList(columns)}`,

@@ -332,3 +332,3 @@ do_update: exprsHandler('DO UPDATE SET '),

from: tableExprHandler('FROM '),
join: (joins) => appendToStatement(sql_template_strings_1.SQL ``, intersperse(' ', joins.map((join) => appendToStatement(sql_template_strings_1.SQL ``, intersperse(' ', [
join: (joins) => appendToStatement((0, sql_template_strings_1.SQL) ``, intersperse(' ', joins.map((join) => appendToStatement((0, sql_template_strings_1.SQL) ``, intersperse(' ', [
join[0],

@@ -340,6 +340,6 @@ 'JOIN',

]))))),
where: (expr) => sql_template_strings_1.SQL `WHERE `.append(handleExpr(expr)),
group_by: (exprs) => appendToStatement(sql_template_strings_1.SQL `GROUP BY `, intersperse(', ', exprs.map((expr) => handleExpr(expr)))),
having: (expr) => sql_template_strings_1.SQL `HAVING `.append(handleExpr(expr)),
order_by: (orderBy) => appendToStatement(sql_template_strings_1.SQL `ORDER BY `, intersperse(', ', orderBy.map((order) => handleExpr(order[0])
where: (expr) => (0, sql_template_strings_1.SQL) `WHERE `.append(handleExpr(expr)),
group_by: (exprs) => appendToStatement((0, sql_template_strings_1.SQL) `GROUP BY `, intersperse(', ', exprs.map((expr) => handleExpr(expr)))),
having: (expr) => (0, sql_template_strings_1.SQL) `HAVING `.append(handleExpr(expr)),
order_by: (orderBy) => appendToStatement((0, sql_template_strings_1.SQL) `ORDER BY `, intersperse(', ', orderBy.map((order) => handleExpr(order[0])
.append(' ')

@@ -407,3 +407,3 @@ .append(order[1])

.slice(1)
.reduce((sql, clauseKey) => sql.append(' ').append(clauseToSql(m, clauseKey)), sql_template_strings_1.SQL ``.append(clauseToSql(m, sortedClauses[0])));
.reduce((sql, clauseKey) => sql.append(' ').append(clauseToSql(m, clauseKey)), (0, sql_template_strings_1.SQL) ``.append(clauseToSql(m, sortedClauses[0])));
}

@@ -410,0 +410,0 @@ /**

{
"name": "@imatic/pgqb",
"version": "0.1.30",
"version": "0.1.31",
"description": "Functional PostgreSQL query builder",

@@ -17,12 +17,12 @@ "main": "./dist/index.js",

"sql-template-strings": "^2.2.2",
"typescript": "^3.5.2"
"typescript": "^4.5.2"
},
"devDependencies": {
"@types/chai": "^4.0.0",
"@types/mocha": "^7.0.2",
"@types/mocha": "^9.0.0",
"@types/node": "^16.7.13",
"chai": "^4.1.0",
"mocha": "^8.0.1",
"mocha": "^9.1.3",
"prettier": "^2.0.5",
"ts-node": "^8.3.0",
"ts-node": "^10.4.0",
"tslint": "^6.1.2"

@@ -29,0 +29,0 @@ },

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