@imatic/pgqb
Advanced tools
Comparing version 0.1.19 to 0.1.20
@@ -65,2 +65,3 @@ import * as qb from './qb'; | ||
in: (expr: qb.Expr, values: qb.Value[] | qb.Sql) => qb.Expr; | ||
notIn: (expr: qb.Expr, values: qb.Value[] | qb.Sql) => qb.Expr; | ||
}; | ||
@@ -67,0 +68,0 @@ /** |
@@ -195,2 +195,3 @@ "use strict"; | ||
in: (expr, values) => ['in', expr, ...(Array.isArray(values) ? values : [values])], | ||
notIn: (expr, values) => ['not_in', expr, ...(Array.isArray(values) ? values : [values])], | ||
}; | ||
@@ -197,0 +198,0 @@ /** |
@@ -12,3 +12,3 @@ export interface InlineParam { | ||
export declare type BinaryOperator = '=' | '!=' | '>' | '>=' | '<' | '<=' | 'as' | 'like' | 'ilike'; | ||
export declare type VarOperator = 'and' | 'or' | 'case_when' | 'in'; | ||
export declare type VarOperator = 'and' | 'or' | 'case_when' | 'in' | 'not_in'; | ||
export interface FunctionCall extends Array<any> { | ||
@@ -15,0 +15,0 @@ 0: '%'; |
@@ -192,2 +192,9 @@ "use strict"; | ||
} | ||
function notInHandler(expr, ...vals) { | ||
return handleExpr(expr) | ||
.append(' NOT IN') | ||
.append(vals.length === 1 && !isValue(vals[0]) | ||
? wrapInParens(_toSql(vals[0])) | ||
: valueList(vals)); | ||
} | ||
function inHandler(expr, ...vals) { | ||
@@ -224,2 +231,3 @@ return handleExpr(expr) | ||
in: inHandler, | ||
not_in: notInHandler, | ||
like: binaryOperatorHandler('LIKE'), | ||
@@ -226,0 +234,0 @@ ilike: binaryOperatorHandler('ILIKE'), |
{ | ||
"name": "@imatic/pgqb", | ||
"version": "0.1.19", | ||
"version": "0.1.20", | ||
"description": "Functional PostgreSQL query builder", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -231,2 +231,4 @@ import * as qb from './qb'; | ||
['in', expr, ...(Array.isArray(values) ? values : [values])] as qb.Expr, | ||
notIn: (expr: qb.Expr, values: qb.Value[] | qb.Sql) => | ||
['not_in', expr, ...(Array.isArray(values) ? values : [values])] as qb.Expr, | ||
}; | ||
@@ -233,0 +235,0 @@ |
@@ -31,3 +31,3 @@ import * as r from 'ramda'; | ||
export type VarOperator = 'and' | 'or' | 'case_when' | 'in'; | ||
export type VarOperator = 'and' | 'or' | 'case_when' | 'in' | 'not_in'; | ||
@@ -327,2 +327,14 @@ export interface FunctionCall extends Array<any> { | ||
function notInHandler(expr: Expr, vals: Sql); | ||
function notInHandler(expr: Expr, ...vals: Value[]); | ||
function notInHandler(expr: Expr, ...vals: any[]) { | ||
return handleExpr(expr) | ||
.append(' NOT IN') | ||
.append( | ||
vals.length === 1 && !isValue(vals[0]) | ||
? wrapInParens(_toSql(vals[0])) | ||
: valueList(vals) | ||
); | ||
} | ||
function inHandler(expr: Expr, vals: Sql); | ||
@@ -385,2 +397,3 @@ function inHandler(expr: Expr, ...vals: Value[]); | ||
in: inHandler, | ||
not_in: notInHandler, | ||
like: binaryOperatorHandler('LIKE'), | ||
@@ -387,0 +400,0 @@ ilike: binaryOperatorHandler('ILIKE'), |
@@ -173,2 +173,3 @@ import {expect} from 'chai'; | ||
h.expr.ilike('t1.c', h.val.inlineParam('%text%')), | ||
h.expr.notIn('t.code', [h.val.inlineParam('red')]) | ||
]) | ||
@@ -201,2 +202,3 @@ ), | ||
['ilike', 't1.c', {ip: '%text%'}], | ||
['not_in', 't.code', {ip: 'red'}], | ||
], | ||
@@ -203,0 +205,0 @@ }, |
@@ -162,2 +162,3 @@ import {expect} from 'chai'; | ||
['ilike', 't1.c', {ip: '%text%'}], | ||
['not_in', 't.code', {ip: 'red'}], | ||
], | ||
@@ -185,3 +186,4 @@ }, | ||
` "t1"."c" LIKE $6,` + | ||
` "t1"."c" ILIKE $7`, | ||
` "t1"."c" ILIKE $7,` + | ||
` "t"."code" NOT IN($8)`, | ||
values: [ | ||
@@ -195,2 +197,3 @@ null, | ||
'%text%', | ||
'red' | ||
], | ||
@@ -197,0 +200,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89494
2049