@balena/abstract-sql-compiler
Advanced tools
Comparing version 7.8.1 to 7.8.2-fix-schema-optimizations-bb989d17aa9308aa6bfba56065cff391d0023608
@@ -7,2 +7,6 @@ # Change Log | ||
## 7.8.2 - 2021-01-15 | ||
* Fix schema optimizations when table and resource names are different [Pagan Gazzard] | ||
## 7.8.1 - 2021-01-04 | ||
@@ -9,0 +13,0 @@ |
@@ -12,2 +12,3 @@ "use strict"; | ||
const sbvrTypes = require("@balena/sbvr-types"); | ||
const _ = require("lodash"); | ||
const AbstractSQLCompiler_1 = require("./AbstractSQLCompiler"); | ||
@@ -32,3 +33,2 @@ const countFroms = (n) => { | ||
var _a; | ||
var _b; | ||
const ruleBodyNode = rule.find((r) => r[0] === 'Body'); | ||
@@ -86,9 +86,12 @@ if (ruleBodyNode == null || typeof ruleBodyNode === 'string') { | ||
const sha = sbvrTypes.SHA.validateSync(`${tableName}$${JSON.stringify(ruleBody)}`).replace(/^\$sha256\$/, ''); | ||
(_a = (_b = abstractSqlModel.tables[tableName]).checks) !== null && _a !== void 0 ? _a : (_b.checks = []); | ||
abstractSqlModel.tables[tableName].checks.push({ | ||
description: ruleSE, | ||
name: `${tableName.slice(0, 30)}$${sha}`.slice(0, 63), | ||
abstractSql: whereNode, | ||
}); | ||
return; | ||
const table = _.find(abstractSqlModel.tables, (t) => t.name === tableName); | ||
if (table) { | ||
(_a = table.checks) !== null && _a !== void 0 ? _a : (table.checks = []); | ||
table.checks.push({ | ||
description: ruleSE, | ||
name: `${tableName.slice(0, 30)}$${sha}`.slice(0, 63), | ||
abstractSql: whereNode, | ||
}); | ||
return; | ||
} | ||
} | ||
@@ -95,0 +98,0 @@ } |
{ | ||
"name": "@balena/abstract-sql-compiler", | ||
"version": "7.8.1", | ||
"version": "7.8.2-fix-schema-optimizations-bb989d17aa9308aa6bfba56065cff391d0023608", | ||
"description": "A translator for abstract sql into sql.", | ||
@@ -5,0 +5,0 @@ "main": "out/AbstractSQLCompiler.js", |
@@ -112,10 +112,16 @@ export const enum Engines { | ||
abstractSqlModel.tables[tableName].checks ??= []; | ||
abstractSqlModel.tables[tableName].checks!.push({ | ||
description: ruleSE, | ||
// Trim the trigger to a max of 63 characters, reserving at least 32 characters for the hash | ||
name: `${tableName.slice(0, 30)}$${sha}`.slice(0, 63), | ||
abstractSql: whereNode, | ||
}); | ||
return; | ||
const table = _.find( | ||
abstractSqlModel.tables, | ||
(t) => t.name === tableName, | ||
); | ||
if (table) { | ||
table.checks ??= []; | ||
table.checks!.push({ | ||
description: ruleSE, | ||
// Trim the trigger to a max of 63 characters, reserving at least 32 characters for the hash | ||
name: `${tableName.slice(0, 30)}$${sha}`.slice(0, 63), | ||
abstractSql: whereNode, | ||
}); | ||
return; | ||
} | ||
} | ||
@@ -122,0 +128,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
582374
12821
2