New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@balena/abstract-sql-compiler

Package Overview
Dependencies
Maintainers
3
Versions
481
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@balena/abstract-sql-compiler - npm Package Compare versions

Comparing version

to
9.1.0-build-partial-unique-index-555a2f627402e1dca0fc32611e708d460f6ff6b2-1

7

CHANGELOG.md

@@ -7,7 +7,12 @@ # Change Log

## 9.1.0 - 2023-11-26
## 9.1.0 - 2024-01-05
* Export the generateRuleHashAcronym helper [Thodoris Greasidis]
* Add support for unique indexes with NOT DISTINCT NULLS [Thodoris Greasidis]
* Add support for partial unique indexes [Thodoris Greasidis]
## 9.0.4 - 2024-01-02
* Update dependency @types/node to v20 [Self-hosted Renovate Bot]
## 9.0.3 - 2023-08-09

@@ -14,0 +19,0 @@

@@ -383,2 +383,3 @@ export declare const enum Engines {

optimizeSchema: (abstractSqlModel: AbstractSqlModel, createCheckConstraints?: boolean) => AbstractSqlModel;
generateRuleHashAcronym: (tableName: string, ruleBody: AbstractSqlType) => string;
compileSchema: (abstractSqlModel: AbstractSqlModel) => SqlModel;

@@ -393,2 +394,3 @@ compileRule: (abstractSQL: AbstractSqlQuery) => SqlResult | [SqlResult, SqlResult];

optimizeSchema: (abstractSqlModel: AbstractSqlModel, createCheckConstraints?: boolean) => AbstractSqlModel;
generateRuleHashAcronym: (tableName: string, ruleBody: AbstractSqlType) => string;
compileSchema: (abstractSqlModel: AbstractSqlModel) => SqlModel;

@@ -403,2 +405,3 @@ compileRule: (abstractSQL: AbstractSqlQuery) => SqlResult | [SqlResult, SqlResult];

optimizeSchema: (abstractSqlModel: AbstractSqlModel, createCheckConstraints?: boolean) => AbstractSqlModel;
generateRuleHashAcronym: (tableName: string, ruleBody: AbstractSqlType) => string;
compileSchema: (abstractSqlModel: AbstractSqlModel) => SqlModel;

@@ -405,0 +408,0 @@ compileRule: (abstractSQL: AbstractSqlQuery) => SqlResult | [SqlResult, SqlResult];

@@ -384,2 +384,3 @@ "use strict";

optimizeSchema: AbstractSQLSchemaOptimiser_1.optimizeSchema,
generateRuleHashAcronym: AbstractSQLSchemaOptimiser_1.generateRuleHashAcronym,
compileSchema: (abstractSqlModel) => compileSchema(abstractSqlModel, engine, ifNotExists),

@@ -386,0 +387,0 @@ compileRule: (abstractSQL) => compileRule(abstractSQL, engine, false),

3

out/AbstractSQLSchemaOptimiser.d.ts

@@ -7,3 +7,4 @@ export declare const enum Engines {

export { Binding, SqlResult } from './AbstractSQLRules2SQL';
import { AbstractSqlModel } from './AbstractSQLCompiler';
import { AbstractSqlModel, AbstractSqlType } from './AbstractSQLCompiler';
export declare const generateRuleHashAcronym: (tableName: string, ruleBody: AbstractSqlType) => string;
export declare const optimizeSchema: (abstractSqlModel: AbstractSqlModel, createCheckConstraints?: boolean) => AbstractSqlModel;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.optimizeSchema = exports.Engines = void 0;
exports.optimizeSchema = exports.generateRuleHashAcronym = exports.Engines = void 0;
var Engines;

@@ -28,2 +28,7 @@ (function (Engines) {

};
const generateRuleHashAcronym = (tableName, ruleBody) => {
const sha = sbvr_types_1.default.SHA.validateSync(`${tableName}$${JSON.stringify(ruleBody)}`).replace(/^\$sha256\$/, '');
return `${tableName.slice(0, 30)}$${sha}`.slice(0, 63);
};
exports.generateRuleHashAcronym = generateRuleHashAcronym;
const optimizeSchema = (abstractSqlModel, createCheckConstraints = true) => {

@@ -86,3 +91,2 @@ abstractSqlModel.rules = abstractSqlModel.rules

const tableName = fromNode[1];
const sha = sbvr_types_1.default.SHA.validateSync(`${tableName}$${JSON.stringify(ruleBody)}`).replace(/^\$sha256\$/, '');
const table = _.find(abstractSqlModel.tables, (t) => t.name === tableName);

@@ -93,3 +97,3 @@ if (table) {

description: ruleSE,
name: `${tableName.slice(0, 30)}$${sha}`.slice(0, 63),
name: (0, exports.generateRuleHashAcronym)(tableName, ruleBody),
abstractSql: whereNode,

@@ -96,0 +100,0 @@ });

{
"name": "@balena/abstract-sql-compiler",
"version": "9.1.0-build-partial-unique-index-12e3a0c5b8ab677e073e7ab524d980a431a558d6-1",
"version": "9.1.0-build-partial-unique-index-555a2f627402e1dca0fc32611e708d460f6ff6b2-1",
"description": "A translator for abstract sql into sql.",

@@ -32,3 +32,3 @@ "main": "out/AbstractSQLCompiler.js",

"@types/mocha": "^10.0.1",
"@types/node": "^18.15.11",
"@types/node": "^20.0.0",
"chai": "^4.3.7",

@@ -65,4 +65,4 @@ "common-tags": "^1.8.2",

"versionist": {
"publishedAt": "2023-11-26T14:25:25.911Z"
"publishedAt": "2024-01-05T16:42:59.831Z"
}
}

@@ -16,4 +16,7 @@ export const enum Engines {

import * as _ from 'lodash';
import { optimizeSchema } from './AbstractSQLSchemaOptimiser';
import {
optimizeSchema,
generateRuleHashAcronym,
} from './AbstractSQLSchemaOptimiser';
import {
getReferencedFields,

@@ -1079,2 +1082,3 @@ getRuleReferencedFields,

optimizeSchema,
generateRuleHashAcronym,
compileSchema: (abstractSqlModel: AbstractSqlModel) =>

@@ -1081,0 +1085,0 @@ compileSchema(abstractSqlModel, engine, ifNotExists),

@@ -35,2 +35,13 @@ export const enum Engines {

export const generateRuleHashAcronym = (
tableName: string,
ruleBody: AbstractSqlType,
) => {
const sha = sbvrTypes.SHA.validateSync(
`${tableName}$${JSON.stringify(ruleBody)}`,
).replace(/^\$sha256\$/, '');
// Trim the trigger to a max of 63 characters, reserving at least 32 characters for the hash
return `${tableName.slice(0, 30)}$${sha}`.slice(0, 63);
};
export const optimizeSchema = (

@@ -114,6 +125,2 @@ abstractSqlModel: AbstractSqlModel,

const tableName = fromNode[1];
const sha = sbvrTypes.SHA.validateSync(
`${tableName}$${JSON.stringify(ruleBody)}`,
).replace(/^\$sha256\$/, '');
const table = _.find(

@@ -127,4 +134,3 @@ abstractSqlModel.tables,

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),
name: generateRuleHashAcronym(tableName, ruleBody),
abstractSql: whereNode,

@@ -131,0 +137,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