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.24 to 0.1.25

.github/workflows/ci.yml

1

dist/helper.d.ts

@@ -67,2 +67,3 @@ import * as qb from './qb';

not: (expr: qb.Expr) => qb.Expr;
exists: (expr: qb.Sql) => qb.Expr;
caseWhen: (arg: qb.Expr, ...args: qb.Expr[]) => qb.Expr;

@@ -69,0 +70,0 @@ in: (expr: qb.Expr, values: qb.Value[] | qb.Sql) => qb.Expr;

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

not: (expr) => ['not', expr],
exists: (expr) => ['exists', expr],
caseWhen: (arg, ...args) => [

@@ -207,3 +208,7 @@ 'case_when',

in: (expr, values) => ['in', expr, ...(Array.isArray(values) ? values : [values])],
notIn: (expr, values) => ['not_in', expr, ...(Array.isArray(values) ? values : [values])],
notIn: (expr, values) => [
'not_in',
expr,
...(Array.isArray(values) ? values : [values]),
],
};

@@ -210,0 +215,0 @@ /**

2

dist/qb.d.ts

@@ -10,3 +10,3 @@ export interface InlineParam {

export declare type ExprOperand = Sql | Value;
export declare type UnaryOperator = 'null' | 'not_null' | 'not';
export declare type UnaryOperator = 'null' | 'not_null' | 'not' | 'exists';
export declare type BinaryOperator = '=' | '!=' | '>' | '>=' | '<' | '<=' | 'as' | 'like' | 'ilike' | '&&';

@@ -13,0 +13,0 @@ export declare type VarOperator = 'and' | 'or' | 'case_when' | 'in' | 'not_in';

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

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 `, r.intersperse(' ', r.map((statements) => handleCaseExprTuple(statements), r.splitEvery(2, r.map(handleExpr, args))))).append(' END'),

@@ -234,0 +235,0 @@ in: inHandler,

{
"name": "@imatic/pgqb",
"version": "0.1.24",
"version": "0.1.25",
"description": "Functional PostgreSQL query builder",

@@ -33,3 +33,3 @@ "main": "./dist/index.js",

"build": "yarn run clean && tsc -d",
"prepublish": "yarn install --prod && yarn run build",
"prepublish": "yarn run build",
"test": "mocha --require ts-node/register --sort './tests/**/*.ts'",

@@ -36,0 +36,0 @@ "test:watch": "mocha --require ts-node/register --sort './tests/**/*.ts' --watch-extensions 'ts' --watch",

@@ -235,2 +235,3 @@ import * as qb from './qb';

not: (expr: qb.Expr): qb.Expr => ['not', expr],
exists: (expr: qb.Sql): qb.Expr => ['exists', expr],
caseWhen: (arg: qb.Expr, ...args: qb.Expr[]): qb.Expr => [

@@ -244,3 +245,7 @@ 'case_when',

notIn: (expr: qb.Expr, values: qb.Value[] | qb.Sql) =>
['not_in', expr, ...(Array.isArray(values) ? values : [values])] as qb.Expr,
[
'not_in',
expr,
...(Array.isArray(values) ? values : [values]),
] as qb.Expr,
};

@@ -247,0 +252,0 @@

@@ -18,3 +18,3 @@ import * as r from 'ramda';

export type UnaryOperator = 'null' | 'not_null' | 'not';
export type UnaryOperator = 'null' | 'not_null' | 'not' | 'exists';

@@ -65,3 +65,3 @@ export type BinaryOperator =

select?: Expr[];
select_distinct?: {on: Expr[], exprs: Expr[]},
select_distinct?: {on: Expr[]; exprs: Expr[]};
insert_into?: TableExpr;

@@ -392,2 +392,4 @@ update?: TableExpr;

not: (expr: Expr) => SQL`NOT `.append(wrapInParens(handleExpr(expr))),
exists: (sqlMap: Sql) =>
SQL`EXISTS `.append(wrapInParens(handleExpr(sqlMap))),
case_when: (...args: Expr[]) =>

@@ -453,3 +455,3 @@ appendToStatement(

select: exprsHandler('SELECT '),
select_distinct: ({on, exprs}: {on: Expr[], exprs: Expr[]}) => {
select_distinct: ({on, exprs}: {on: Expr[]; exprs: Expr[]}) => {
const onSt = appendToStatement(

@@ -460,3 +462,6 @@ SQL`SELECT DISTINCT ON (`,

return appendToStatement(onSt, r.intersperse<SQLStatement | string>(', ', r.map(handleExpr, exprs)));
return appendToStatement(
onSt,
r.intersperse<SQLStatement | string>(', ', r.map(handleExpr, exprs))
);
},

@@ -463,0 +468,0 @@ insert_into: tableExprHandler('INSERT INTO '),

@@ -150,6 +150,9 @@ import {expect} from 'chai';

h.selectDistinct(['t.id'], [h.expr.fn('count', 't.id')]),
h.from('table', 't'),
h.from('table', 't')
),
expected: {
select_distinct: {on: ['t.id'], exprs: [['%', 'count', 't.id']]},
select_distinct: {
on: ['t.id'],
exprs: [['%', 'count', 't.id']],
},
from: ['table', 't'],

@@ -190,2 +193,3 @@ },

h.expr.not('t1.b'),
h.expr.exists(h.merge(h.select(['t.c']))),
])

@@ -220,3 +224,4 @@ ),

['&&', 't1.c', 't2.c'],
['not', 't1.b']
['not', 't1.b'],
['exists', {select: ['t.c']}],
],

@@ -298,3 +303,3 @@ },

group_by: ['c1.1', 'c1.2', 'c2.1'],
having: ['and', ['null', 'c1.1'], ['null', 'c2.1']]
having: ['and', ['null', 'c1.1'], ['null', 'c2.1']],
},

@@ -301,0 +306,0 @@ },

@@ -126,3 +126,6 @@ import {expect} from 'chai';

map: {
select_distinct: {on: ['t.id'], exprs: [['%', 'count', 't.id']]},
select_distinct: {
on: ['t.id'],
exprs: [['%', 'count', 't.id']],
},
from: ['table', 't'],

@@ -180,3 +183,4 @@ },

['&&', 't1.c', 't2.c'],
['not', 't1.b']
['not', 't1.b'],
['exists', {select: ['t.c']}],
],

@@ -207,3 +211,4 @@ },

` "t1"."c" && "t2"."c",` +
` NOT ("t1"."b")`,
` NOT ("t1"."b"),` +
` EXISTS ((SELECT "t"."c"))`,
values: [

@@ -217,3 +222,3 @@ null,

'%text%',
'red'
'red',
],

@@ -220,0 +225,0 @@ },

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