sedentary-pg
Advanced tools
+32
-17
@@ -85,2 +85,3 @@ "use strict"; | ||
| let rowCount = 0; | ||
| let withError = true; | ||
| try { | ||
@@ -90,6 +91,7 @@ const query = `DELETE FROM ${tableName}${where ? ` WHERE ${where}` : ""}`; | ||
| ({ rowCount } = (await client.query(query))); | ||
| withError = false; | ||
| } | ||
| finally { | ||
| if (!tx) | ||
| client.release(); | ||
| client.release(withError); | ||
| } | ||
@@ -124,2 +126,3 @@ return rowCount; | ||
| const oidPK = {}; | ||
| let withError = true; | ||
| try { | ||
@@ -144,2 +147,3 @@ const forUpdate = lock ? " FOR UPDATE" : ""; | ||
| entry.postLoad(); | ||
| withError = false; | ||
| } | ||
@@ -163,3 +167,3 @@ else { | ||
| if (!tx) | ||
| client.release(); | ||
| client.release(withError); | ||
| } | ||
@@ -177,2 +181,3 @@ return ret; | ||
| let removed; | ||
| let withError = true; | ||
| try { | ||
@@ -182,6 +187,7 @@ const query = `DELETE FROM ${tableName} WHERE ${pkFldName} = ${self.escape(this[pkAttrName])}`; | ||
| removed = (await client.query(query)).rowCount; | ||
| withError = false; | ||
| } | ||
| finally { | ||
| if (!this[sedentary_1.transaction]) | ||
| client.release(); | ||
| client.release(withError); | ||
| } | ||
@@ -200,2 +206,3 @@ return removed; | ||
| let result = null; | ||
| let withError = true; | ||
| const save = async (query) => { | ||
@@ -231,6 +238,7 @@ self.log(query); | ||
| } | ||
| withError = false; | ||
| } | ||
| finally { | ||
| if (!this[sedentary_1.transaction]) | ||
| client.release(); | ||
| client.release(withError); | ||
| } | ||
@@ -331,2 +339,3 @@ return changed && result.rowCount; | ||
| async syncDataBase() { | ||
| let withError = true; | ||
| try { | ||
@@ -336,6 +345,7 @@ await super.syncDataBase(); | ||
| this.oidLoad[table.oid || 0] = (ids) => table.model.load({ [table.pk.attributeName]: ["IN", ids] }); | ||
| withError = false; | ||
| } | ||
| finally { | ||
| this.released = true; | ||
| this._client.release(); | ||
| this._client.release(withError); | ||
| } | ||
@@ -537,8 +547,10 @@ } | ||
| } | ||
| release() { | ||
| this.released = true; | ||
| this._client.release(); | ||
| release(error = false) { | ||
| if (!this.released) { | ||
| this.released = true; | ||
| this._client.release(error); | ||
| } | ||
| } | ||
| async commit() { | ||
| if (!this.released) { | ||
| try { | ||
| this.preCommit(); | ||
@@ -550,14 +562,17 @@ this.log("COMMIT"); | ||
| } | ||
| catch (error) { | ||
| this.release(true); | ||
| throw error; | ||
| } | ||
| } | ||
| async rollback() { | ||
| try { | ||
| if (!this.released) { | ||
| await super.rollback(); | ||
| this.log("ROLLBACK"); | ||
| await this._client.query("ROLLBACK"); | ||
| } | ||
| await super.rollback(); | ||
| this.log("ROLLBACK"); | ||
| await this._client.query("ROLLBACK"); | ||
| this.release(); | ||
| } | ||
| finally { | ||
| if (!this.released) | ||
| this.release(); | ||
| catch (error) { | ||
| this.release(true); | ||
| throw error; | ||
| } | ||
@@ -564,0 +579,0 @@ } |
+32
-17
@@ -80,2 +80,3 @@ // cSpell:ignore adbin adnum adrelid adsrc amname attinhcount attisdropped attislocal attname attnotnull attnum attrdef attrelid atttypid atttypmod confdeltype confdeltype | ||
| let rowCount = 0; | ||
| let withError = true; | ||
| try { | ||
@@ -85,6 +86,7 @@ const query = `DELETE FROM ${tableName}${where ? ` WHERE ${where}` : ""}`; | ||
| ({ rowCount } = (await client.query(query))); | ||
| withError = false; | ||
| } | ||
| finally { | ||
| if (!tx) | ||
| client.release(); | ||
| client.release(withError); | ||
| } | ||
@@ -119,2 +121,3 @@ return rowCount; | ||
| const oidPK = {}; | ||
| let withError = true; | ||
| try { | ||
@@ -139,2 +142,3 @@ const forUpdate = lock ? " FOR UPDATE" : ""; | ||
| entry.postLoad(); | ||
| withError = false; | ||
| } | ||
@@ -158,3 +162,3 @@ else { | ||
| if (!tx) | ||
| client.release(); | ||
| client.release(withError); | ||
| } | ||
@@ -172,2 +176,3 @@ return ret; | ||
| let removed; | ||
| let withError = true; | ||
| try { | ||
@@ -177,6 +182,7 @@ const query = `DELETE FROM ${tableName} WHERE ${pkFldName} = ${self.escape(this[pkAttrName])}`; | ||
| removed = (await client.query(query)).rowCount; | ||
| withError = false; | ||
| } | ||
| finally { | ||
| if (!this[transaction]) | ||
| client.release(); | ||
| client.release(withError); | ||
| } | ||
@@ -195,2 +201,3 @@ return removed; | ||
| let result = null; | ||
| let withError = true; | ||
| const save = async (query) => { | ||
@@ -226,6 +233,7 @@ self.log(query); | ||
| } | ||
| withError = false; | ||
| } | ||
| finally { | ||
| if (!this[transaction]) | ||
| client.release(); | ||
| client.release(withError); | ||
| } | ||
@@ -326,2 +334,3 @@ return changed && result.rowCount; | ||
| async syncDataBase() { | ||
| let withError = true; | ||
| try { | ||
@@ -331,6 +340,7 @@ await super.syncDataBase(); | ||
| this.oidLoad[table.oid || 0] = (ids) => table.model.load({ [table.pk.attributeName]: ["IN", ids] }); | ||
| withError = false; | ||
| } | ||
| finally { | ||
| this.released = true; | ||
| this._client.release(); | ||
| this._client.release(withError); | ||
| } | ||
@@ -532,8 +542,10 @@ } | ||
| } | ||
| release() { | ||
| this.released = true; | ||
| this._client.release(); | ||
| release(error = false) { | ||
| if (!this.released) { | ||
| this.released = true; | ||
| this._client.release(error); | ||
| } | ||
| } | ||
| async commit() { | ||
| if (!this.released) { | ||
| try { | ||
| this.preCommit(); | ||
@@ -545,16 +557,19 @@ this.log("COMMIT"); | ||
| } | ||
| catch (error) { | ||
| this.release(true); | ||
| throw error; | ||
| } | ||
| } | ||
| async rollback() { | ||
| try { | ||
| if (!this.released) { | ||
| await super.rollback(); | ||
| this.log("ROLLBACK"); | ||
| await this._client.query("ROLLBACK"); | ||
| } | ||
| await super.rollback(); | ||
| this.log("ROLLBACK"); | ||
| await this._client.query("ROLLBACK"); | ||
| this.release(); | ||
| } | ||
| finally { | ||
| if (!this.released) | ||
| this.release(); | ||
| catch (error) { | ||
| this.release(true); | ||
| throw error; | ||
| } | ||
| } | ||
| } |
+2
-2
@@ -12,3 +12,3 @@ { | ||
| "pg-format": "^1.0.4", | ||
| "sedentary": "0.1.2" | ||
| "sedentary": "0.1.3" | ||
| }, | ||
@@ -48,3 +48,3 @@ "description": "The ORM which never needs to migrate - PostgreSQL", | ||
| "types": "./dist/types/index.d.ts", | ||
| "version": "0.1.2" | ||
| "version": "0.1.3" | ||
| } |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
59121
1.71%1230
2.5%+ Added
- Removed
Updated