@evershop/postgres-query-builder
Advanced tools
Comparing version 1.0.6 to 1.0.7
40
index.js
@@ -46,2 +46,28 @@ const uniqid = require('uniqid'); | ||
class RawLeaf { | ||
constructor(link, rawSql, binding = {}) { | ||
this._link = link; | ||
this._binding = binding; | ||
this._rawSql = rawSql; | ||
} | ||
getBinding() { | ||
return this._binding; | ||
} | ||
parent() { | ||
return this._parent; | ||
} | ||
render() { | ||
return `${this._link} ${this._rawSql}`; | ||
} | ||
clone(node) { | ||
let cp = new RawLeaf(this._link, this._rawSql, this._binding); | ||
cp._parent = node; | ||
return cp; | ||
} | ||
} | ||
class Leaf { | ||
@@ -145,2 +171,7 @@ constructor(link, field, operator, value, node) { | ||
addRaw(link, sql, binding = {}) { | ||
this._tree.push(new RawLeaf(link, sql, binding)); | ||
return this; | ||
} | ||
addNode(node) { | ||
@@ -161,3 +192,5 @@ node._parent = this; | ||
getLeafs() { | ||
return this._tree.filter((e) => e.constructor.name === 'Leaf'); | ||
return this._tree.filter( | ||
(e) => e.constructor.name === 'Leaf' || e.constructor.name === 'RawLeaf' | ||
); | ||
} | ||
@@ -238,3 +271,3 @@ | ||
cp._tree = this._tree.map((t) => { | ||
if (t.constructor === Leaf) { | ||
if (t.constructor === Leaf || t.constructor === RawLeaf) { | ||
return t.clone(cp); | ||
@@ -445,2 +478,3 @@ } else { | ||
this._where = new Where(this); | ||
this._where._link = 'AND'; | ||
this._binding = []; | ||
@@ -615,3 +649,3 @@ } | ||
this.removeOrderBy(); | ||
return await super.execute(connection, releaseConnection); | ||
return await super.execute(connection, false); | ||
} else if (e.code.toLowerCase() === '22p02') { | ||
@@ -618,0 +652,0 @@ // In case of invalid input type, we consider it as empty result |
{ | ||
"name": "@evershop/postgres-query-builder", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "A PostgreSQL query builder for NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
31540
1002