@imatic/pgqb
Advanced tools
Comparing version 0.1.18 to 0.1.19
@@ -64,3 +64,3 @@ import * as qb from './qb'; | ||
caseWhen: (arg: qb.Expr, ...args: qb.Expr[]) => qb.Expr; | ||
in: (expr: qb.Expr, values: qb.Sql | qb.Value[]) => qb.Expr; | ||
in: (expr: qb.Expr, values: qb.Value[] | qb.Sql) => qb.Expr; | ||
}; | ||
@@ -67,0 +67,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.val = exports.expr = exports.returning = exports.forUpdate = exports.offset = exports.limit = exports.orderBy = exports.groupBy = exports.where = exports.doNothing = exports.doUpdate = exports.leftJoin = exports.join = exports.joins = exports.from = exports.set = exports.onConflict = exports.values = exports.columns = exports.update = exports.insertInto = exports.select = exports.append = exports.merge = void 0; | ||
const r = require("ramda"); | ||
@@ -30,2 +31,3 @@ /** | ||
join: (j1, j2) => r.concat(j1, j2), | ||
group_by: (g1, g2) => r.concat(g1, g2), | ||
}; | ||
@@ -32,0 +34,0 @@ /** |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./qb")); | ||
__export(require("./helper")); | ||
__exportStar(require("./qb"), exports); | ||
__exportStar(require("./helper"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toSql = void 0; | ||
const r = require("ramda"); | ||
@@ -168,5 +169,3 @@ const sql_template_strings_1 = require("sql-template-strings"); | ||
function binaryOperatorHandler(operator) { | ||
return (op1, op2) => handleExpr(op1) | ||
.append(` ${operator} `) | ||
.append(handleExpr(op2)); | ||
return (op1, op2) => handleExpr(op1).append(` ${operator} `).append(handleExpr(op2)); | ||
} | ||
@@ -173,0 +172,0 @@ /** |
{ | ||
"name": "@imatic/pgqb", | ||
"version": "0.1.18", | ||
"version": "0.1.19", | ||
"description": "Functional PostgreSQL query builder", | ||
@@ -16,4 +16,4 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"@types/ramda": "^0.26.12", | ||
"ramda": "^0.26.1", | ||
"@types/ramda": "^0.27.6", | ||
"ramda": "^0.27.0", | ||
"sql-template-strings": "^2.2.2", | ||
@@ -24,8 +24,8 @@ "typescript": "^3.5.2" | ||
"@types/chai": "^4.0.0", | ||
"@types/mocha": "^5.2.7", | ||
"@types/mocha": "^7.0.2", | ||
"chai": "^4.1.0", | ||
"mocha": "^6.1.4", | ||
"prettier": "^1.4.2", | ||
"mocha": "^8.0.1", | ||
"prettier": "^2.0.5", | ||
"ts-node": "^8.3.0", | ||
"tslint": "^5.4.3" | ||
"tslint": "^6.1.2" | ||
}, | ||
@@ -39,7 +39,7 @@ "scripts": { | ||
"tslint": "tslint --project . --exclude 'dist/**'", | ||
"prettier": "prettier --tab-width 4 --single-quote --trailing-comma 'es5' --no-bracket-spacing --write 'bin/**/*.ts' 'src/**/*.ts' 'tests/**/*.ts'" | ||
"prettier": "prettier --tab-width 4 --single-quote --trailing-comma 'es5' --no-bracket-spacing --write 'src/**/*.ts' 'tests/**/*.ts'" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=12" | ||
} | ||
} |
@@ -34,2 +34,3 @@ import * as qb from './qb'; | ||
join: (j1: qb.Join[], j2: qb.Join[]) => r.concat(j1, j2), | ||
group_by: (g1: qb.Expr[], g2: qb.Expr[]) => r.concat(g1, g2), | ||
}; | ||
@@ -36,0 +37,0 @@ |
@@ -121,3 +121,6 @@ import * as r from 'ramda'; | ||
function escape(identifier: string): string { | ||
return r.join('.', r.map((id) => `"${id}"`, r.split('.', identifier))); | ||
return r.join( | ||
'.', | ||
r.map((id) => `"${id}"`, r.split('.', identifier)) | ||
); | ||
} | ||
@@ -293,5 +296,3 @@ | ||
return (op1: Expr, op2: Expr): SQLStatement => | ||
handleExpr(op1) | ||
.append(` ${operator} `) | ||
.append(handleExpr(op2)); | ||
handleExpr(op1).append(` ${operator} `).append(handleExpr(op2)); | ||
} | ||
@@ -397,3 +398,3 @@ | ||
function exprsHandler(statementStart: string) { | ||
return function(exprs: Expr[]): SQLStatement { | ||
return function (exprs: Expr[]): SQLStatement { | ||
return appendToStatement( | ||
@@ -413,3 +414,3 @@ SQL``.append(statementStart), | ||
function tableExprHandler(statementStart: string) { | ||
return function(table: TableExpr): SQLStatement { | ||
return function (table: TableExpr): SQLStatement { | ||
return SQL``.append(statementStart).append(tableExpr(table)); | ||
@@ -416,0 +417,0 @@ }; |
@@ -218,3 +218,6 @@ import {expect} from 'chai'; | ||
h.columns(['col1', 'col2']), | ||
h.values([['v1', 'v2'], ['v1.2', 'v2.2']]), | ||
h.values([ | ||
['v1', 'v2'], | ||
['v1.2', 'v2.2'], | ||
]), | ||
h.where(h.expr.eq('col1', 'col2')), | ||
@@ -226,3 +229,4 @@ h.set([h.expr.eq('col1', 'col2')]), | ||
h.join('table2', 't2', h.expr.eq('t2.id', 't3.id')) | ||
) | ||
), | ||
h.groupBy(['c1.1', 'c1.2']) | ||
), | ||
@@ -242,3 +246,4 @@ h.merge( | ||
) | ||
) | ||
), | ||
h.groupBy(['c2.1']) | ||
) | ||
@@ -249,3 +254,6 @@ ), | ||
columns: ['col1', 'col2', 'col3'], | ||
values: [['v1', 'v2', 'v3'], ['v1.2', 'v2.2', 'v3.2']], | ||
values: [ | ||
['v1', 'v2', 'v3'], | ||
['v1.2', 'v2.2', 'v3.2'], | ||
], | ||
where: [ | ||
@@ -256,3 +264,6 @@ 'and', | ||
], | ||
set: [['=', 'col1', 'col2'], ['=', 'col3', 'col4']], | ||
set: [ | ||
['=', 'col1', 'col2'], | ||
['=', 'col3', 'col4'], | ||
], | ||
order_by: [ | ||
@@ -267,2 +278,3 @@ ['col1', 'ASC', 'NULLS LAST'], | ||
], | ||
group_by: ['c1.1', 'c1.2', 'c2.1'], | ||
}, | ||
@@ -286,3 +298,6 @@ }, | ||
h.columns(['col1', 'col2']), | ||
h.values([['v1', 'v2'], ['v1.2', 'v2.2']]) | ||
h.values([ | ||
['v1', 'v2'], | ||
['v1.2', 'v2.2'], | ||
]) | ||
), | ||
@@ -293,3 +308,6 @@ {} | ||
columns: ['col1', 'col2'], | ||
values: [['v1', 'v2'], ['v1.2', 'v2.2']], | ||
values: [ | ||
['v1', 'v2'], | ||
['v1.2', 'v2.2'], | ||
], | ||
}, | ||
@@ -296,0 +314,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
87744
2020
+ Added@types/ramda@0.27.66(transitive)
+ Addedramda@0.27.2(transitive)
- Removed@types/ramda@0.26.44(transitive)
- Removedramda@0.26.1(transitive)
Updated@types/ramda@^0.27.6
Updatedramda@^0.27.0