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

@contember/database

Package Overview
Dependencies
Maintainers
5
Versions
263
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contember/database - npm Package Compare versions

Comparing version 0.9.0-alpha.1 to 0.9.0-alpha.4

4

dist/src/builders/Compiler.js

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

case 'inner':
return query
return query //
.appendString(' inner join ')

@@ -128,3 +128,3 @@ .append(tableArg)

case 'left':
return query
return query //
.appendString(' left join ')

@@ -131,0 +131,0 @@ .append(tableArg)

@@ -6,2 +6,16 @@ import { Value } from '../types';

export declare type ConditionCallback = (builder: ConditionBuilder) => ConditionBuilder;
export declare enum Operator {
'notEq' = "!=",
'eq' = "=",
'gt' = ">",
'gte' = ">=",
'lt' = "<",
'lte' = "<=",
'contains' = "contains",
'startsWith' = "startsWith",
'endsWith' = "endsWith",
'containsCI' = "containsCI",
'startsWithCI' = "startsWithCI",
'endsWithCI' = "endsWithCI"
}
export declare class ConditionBuilder {

@@ -28,13 +42,2 @@ readonly expressions: Literal[];

}
export declare enum Operator {
'notEq' = "!=",
'eq' = "=",
'gt' = ">",
'gte' = ">=",
'lt' = "<",
'lte' = "<=",
'contains' = "contains",
'startsWith' = "startsWith",
'endsWith' = "endsWith"
}
//# sourceMappingURL=ConditionBuilder.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Operator = exports.ConditionBuilder = void 0;
exports.ConditionBuilder = exports.Operator = void 0;
const Literal_1 = require("../Literal");
const formatUtils_1 = require("./formatUtils");
const Compiler_1 = require("./Compiler");
var Operator;
(function (Operator) {
Operator["notEq"] = "!=";
Operator["eq"] = "=";
Operator["gt"] = ">";
Operator["gte"] = ">=";
Operator["lt"] = "<";
Operator["lte"] = "<=";
Operator["contains"] = "contains";
Operator["startsWith"] = "startsWith";
Operator["endsWith"] = "endsWith";
Operator["containsCI"] = "containsCI";
Operator["startsWithCI"] = "startsWithCI";
Operator["endsWithCI"] = "endsWithCI";
})(Operator = exports.Operator || (exports.Operator = {}));
const likeOperators = [
Operator.contains,
Operator.containsCI,
Operator.startsWith,
Operator.startsWithCI,
Operator.endsWith,
Operator.endsWithCI,
];
class ConditionBuilder {

@@ -38,3 +61,3 @@ constructor(expressions) {

}
if (operator === Operator.contains || operator === Operator.endsWith || operator === Operator.startsWith) {
if (likeOperators.includes(operator)) {
if (typeof value !== 'string') {

@@ -60,6 +83,12 @@ throw new Error(`Operator ${operator} supports only a string value`);

return `${left} LIKE '%' || ${right} || '%'`;
case Operator.containsCI:
return `${left} ILIKE '%' || ${right} || '%'`;
case Operator.startsWith:
return `${left} LIKE ${right} || '%'`;
case Operator.startsWithCI:
return `${left} ILIKE ${right} || '%'`;
case Operator.endsWith:
return `${left} LIKE '%' || ${right}`;
case Operator.endsWithCI:
return `${left} ILIKE '%' || ${right}`;
}

@@ -110,14 +139,2 @@ return `${left} ${operator} ${right}`;

exports.ConditionBuilder = ConditionBuilder;
var Operator;
(function (Operator) {
Operator["notEq"] = "!=";
Operator["eq"] = "=";
Operator["gt"] = ">";
Operator["gte"] = ">=";
Operator["lt"] = "<";
Operator["lte"] = "<=";
Operator["contains"] = "contains";
Operator["startsWith"] = "startsWith";
Operator["endsWith"] = "endsWith";
})(Operator = exports.Operator || (exports.Operator = {}));
//# sourceMappingURL=ConditionBuilder.js.map

@@ -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 });

@@ -16,5 +16,3 @@ "use strict";

if (this.limit !== undefined || this.skip !== undefined) {
let window = WindowFunction_1.WindowFunction.createEmpty()
.rowNumber()
.partitionBy(this.groupBy);
let window = WindowFunction_1.WindowFunction.createEmpty().rowNumber().partitionBy(this.groupBy);
if (this.orderByCallback !== undefined) {

@@ -25,3 +23,3 @@ ;

qb = qb.select(window.compile(), 'rowNumber_');
let wrapperQb = SelectBuilder_1.SelectBuilder.create()
let wrapperQb = SelectBuilder_1.SelectBuilder.create() //
.with('data', qb)

@@ -28,0 +26,0 @@ .from('data')

@@ -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 });

@@ -10,5 +10,6 @@ "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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapIdentifier = void 0;
__exportStar(require("./client"), exports);

@@ -15,0 +16,0 @@ __exportStar(require("./builders"), exports);

@@ -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 });

@@ -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 });

@@ -35,2 +35,5 @@ "use strict";

.compare('i', src_1.Operator.endsWith, 'dolor%sit')
.compare('j', src_1.Operator.containsCI, 'X')
.compare('k', src_1.Operator.startsWithCI, 'Y')
.compare('l', src_1.Operator.endsWithCI, 'Z')
.compareColumns('z', src_1.Operator.eq, ['foo', 'x'])

@@ -47,4 +50,5 @@ .in('o', [1, 2, 3])

and "g" like '%' || ? || '%' and "h" like ? || '%' and "i" like '%' || ?
and "j" ilike '%' || ? || '%' and "k" ilike ? || '%' and "l" ilike '%' || ?
and "z" = "foo"."x" and "o" in (?, ?, ?) and "m" in (select ?) and "n" is null and false`,
parameters: [1, 2, 3, 4, 5, 6, 'foo\\\\\\%bar', 'lorem\\_ipsum', 'dolor\\%sit', 1, 2, 3, 1],
parameters: [1, 2, 3, 4, 5, 6, 'foo\\\\\\%bar', 'lorem\\_ipsum', 'dolor\\%sit', 'X', 'Y', 'Z', 1, 2, 3, 1],
});

@@ -258,6 +262,5 @@ });

query: async (wrapper) => {
const qb = wrapper.selectBuilder().select(expr => expr.window(window => window
.orderBy(['foo', 'bar'], 'desc')
.rowNumber()
.partitionBy(['lorem', 'ipsum'])));
const qb = wrapper
.selectBuilder()
.select(expr => expr.window(window => window.orderBy(['foo', 'bar'], 'desc').rowNumber().partitionBy(['lorem', 'ipsum'])));
await qb.getResult(wrapper);

@@ -274,6 +277,3 @@ },

query: async (wrapper) => {
const qb = wrapper
.selectBuilder()
.select(['foo', 'bar'])
.from('foo');
const qb = wrapper.selectBuilder().select(['foo', 'bar']).from('foo');
await new src_1.LimitByGroupWrapper(['foo', 'lorem'], (orderable, qb) => {

@@ -297,7 +297,3 @@ if (orderable) {

query: async (wrapper) => {
const qb = wrapper
.selectBuilder()
.select('id')
.from('foo')
.lock(src_1.LockType.forNoKeyUpdate);
const qb = wrapper.selectBuilder().select('id').from('foo').lock(src_1.LockType.forNoKeyUpdate);
await qb.getResult(wrapper);

@@ -304,0 +300,0 @@ },

{
"name": "@contember/database",
"version": "0.9.0-alpha.1",
"license": "Apache-2.0",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
"scripts": {
"test": "jasmine --config=jasmine.json"
},
"dependencies": {
"@contember/queryable": "^0.9.0-alpha.1",
"pg": "^7.17.1"
},
"devDependencies": {
"@contember/database-tester": "^0.9.0-alpha.1",
"@types/jasmine": "^3.5.10",
"@types/node": "^13.11.1",
"@types/pg": "^7.14.1",
"jasmine": "^3.5.0",
"typescript": "^3.9.5"
},
"gitHead": "ef9d3567bc86885591341cca901b7a12e0e46f74"
"name": "@contember/database",
"version": "0.9.0-alpha.4",
"license": "Apache-2.0",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
"scripts": {
"test": "jasmine --config=jasmine.json"
},
"dependencies": {
"@contember/queryable": "^0.9.0-alpha.4",
"pg": "^7.17.1"
},
"devDependencies": {
"@contember/database-tester": "^0.9.0-alpha.4",
"@types/jasmine": "^3.5.10",
"@types/node": "^14.6.4",
"@types/pg": "^7.14.1",
"jasmine": "^3.5.0"
}
}

@@ -154,3 +154,3 @@ import { assertNever, aliasLiteral, prependSchema, wrapIdentifier } from '../utils'

case 'inner':
return query
return query //
.appendString(' inner join ')

@@ -161,3 +161,3 @@ .append(tableArg)

case 'left':
return query
return query //
.appendString(' left join ')

@@ -164,0 +164,0 @@ .append(tableArg)

@@ -15,2 +15,27 @@ import { Value } from '../types'

export enum Operator {
'notEq' = '!=',
'eq' = '=',
'gt' = '>',
'gte' = '>=',
'lt' = '<',
'lte' = '<=',
'contains' = 'contains',
'startsWith' = 'startsWith',
'endsWith' = 'endsWith',
'containsCI' = 'containsCI',
'startsWithCI' = 'startsWithCI',
'endsWithCI' = 'endsWithCI',
}
const likeOperators = [
Operator.contains,
Operator.containsCI,
Operator.startsWith,
Operator.startsWithCI,
Operator.endsWith,
Operator.endsWithCI,
]
export class ConditionBuilder {

@@ -52,3 +77,4 @@ private constructor(public readonly expressions: Literal[]) {}

}
if (operator === Operator.contains || operator === Operator.endsWith || operator === Operator.startsWith) {
if (likeOperators.includes(operator)) {
if (typeof value !== 'string') {

@@ -81,6 +107,12 @@ throw new Error(`Operator ${operator} supports only a string value`)

return `${left} LIKE '%' || ${right} || '%'`
case Operator.containsCI:
return `${left} ILIKE '%' || ${right} || '%'`
case Operator.startsWith:
return `${left} LIKE ${right} || '%'`
case Operator.startsWithCI:
return `${left} ILIKE ${right} || '%'`
case Operator.endsWith:
return `${left} LIKE '%' || ${right}`
case Operator.endsWithCI:
return `${left} ILIKE '%' || ${right}`
}

@@ -146,13 +178,1 @@ return `${left} ${operator} ${right}`

}
export enum Operator {
'notEq' = '!=',
'eq' = '=',
'gt' = '>',
'gte' = '>=',
'lt' = '<',
'lte' = '<=',
'contains' = 'contains',
'startsWith' = 'startsWith',
'endsWith' = 'endsWith',
}

@@ -22,5 +22,3 @@ import { QueryBuilder } from './QueryBuilder'

if (this.limit !== undefined || this.skip !== undefined) {
let window = WindowFunction.createEmpty()
.rowNumber()
.partitionBy(this.groupBy)
let window = WindowFunction.createEmpty().rowNumber().partitionBy(this.groupBy)
if (this.orderByCallback !== undefined) {

@@ -32,3 +30,3 @@ ;[window, qb] = this.orderByCallback(window, qb)

let wrapperQb: SelectBuilder<R> = SelectBuilder.create<R>()
let wrapperQb: SelectBuilder<R> = SelectBuilder.create<R>() //
.with('data', qb)

@@ -35,0 +33,0 @@ .from('data')

@@ -46,2 +46,5 @@ import 'jasmine'

.compare('i', Operator.endsWith, 'dolor%sit')
.compare('j', Operator.containsCI, 'X')
.compare('k', Operator.startsWithCI, 'Y')
.compare('l', Operator.endsWithCI, 'Z')
.compareColumns('z', Operator.eq, ['foo', 'x'])

@@ -63,4 +66,5 @@ .in('o', [1, 2, 3])

and "g" like '%' || ? || '%' and "h" like ? || '%' and "i" like '%' || ?
and "j" ilike '%' || ? || '%' and "k" ilike ? || '%' and "l" ilike '%' || ?
and "z" = "foo"."x" and "o" in (?, ?, ?) and "m" in (select ?) and "n" is null and false`,
parameters: [1, 2, 3, 4, 5, 6, 'foo\\\\\\%bar', 'lorem\\_ipsum', 'dolor\\%sit', 1, 2, 3, 1],
parameters: [1, 2, 3, 4, 5, 6, 'foo\\\\\\%bar', 'lorem\\_ipsum', 'dolor\\%sit', 'X', 'Y', 'Z', 1, 2, 3, 1],
})

@@ -296,10 +300,7 @@ })

query: async wrapper => {
const qb = wrapper.selectBuilder().select(expr =>
expr.window(window =>
window
.orderBy(['foo', 'bar'], 'desc')
.rowNumber()
.partitionBy(['lorem', 'ipsum']),
),
)
const qb = wrapper
.selectBuilder()
.select(expr =>
expr.window(window => window.orderBy(['foo', 'bar'], 'desc').rowNumber().partitionBy(['lorem', 'ipsum'])),
)

@@ -318,6 +319,3 @@ await qb.getResult(wrapper)

query: async wrapper => {
const qb = wrapper
.selectBuilder()
.select(['foo', 'bar'])
.from('foo')
const qb = wrapper.selectBuilder().select(['foo', 'bar']).from('foo')

@@ -348,7 +346,3 @@ await new LimitByGroupWrapper(

query: async wrapper => {
const qb = wrapper
.selectBuilder()
.select('id')
.from('foo')
.lock(LockType.forNoKeyUpdate)
const qb = wrapper.selectBuilder().select('id').from('foo').lock(LockType.forNoKeyUpdate)

@@ -355,0 +349,0 @@ await qb.getResult(wrapper)

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

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

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