@balena/abstract-sql-compiler
Advanced tools
Comparing version 7.13.0-model-based-optimizations-37f50ae20f73dc307eea1aa0c87a138d08a50f00 to 8.0.0-true-boolean-5914ecfede7efc56e38162b4f9dfa5e19f0d0792
@@ -7,6 +7,14 @@ # Change Log | ||
## 7.13.0 - 2021-05-03 | ||
## 8.0.0 - 2021-05-07 | ||
* Add support for non-null ReferencedField optimization using model info [Pagan Gazzard] | ||
* Update sbvr-types and reflect the usage of BOOLEAN db type [Pagan Gazzard] | ||
## 7.12.4 - 2021-05-04 | ||
* Revert "Remove now unnecessary hack for casting SERIAL types" [Pagan Gazzard] | ||
## 7.12.3 - 2021-05-03 | ||
* Remove now unnecessary hack for casting SERIAL types [Pagan Gazzard] | ||
## 7.12.2 - 2021-03-22 | ||
@@ -13,0 +21,0 @@ |
@@ -231,12 +231,12 @@ export declare const enum Engines { | ||
export declare const isResourceNode: (n: AbstractSqlType) => n is ResourceNode; | ||
export declare function compileRule(abstractSQL: UpsertQueryNode, engine: Engines, noBinds: true, abstractSqlModel?: AbstractSqlModel): [string, string]; | ||
export declare function compileRule(abstractSQL: AbstractSqlQuery, engine: Engines, noBinds: true, abstractSqlModel?: AbstractSqlModel): string; | ||
export declare function compileRule(abstractSQL: UpsertQueryNode, engine: Engines, noBinds?: false, abstractSqlModel?: AbstractSqlModel): [SqlResult, SqlResult]; | ||
export declare function compileRule(abstractSQL: SelectQueryNode | UnionQueryNode | InsertQueryNode | UpdateQueryNode | DeleteQueryNode, engine: Engines, noBinds?: false, abstractSqlModel?: AbstractSqlModel): SqlResult; | ||
export declare function compileRule(abstractSQL: AbstractSqlQuery, engine: Engines, noBinds?: false, abstractSqlModel?: AbstractSqlModel): SqlResult | [SqlResult, SqlResult]; | ||
export declare function compileRule(abstractSQL: AbstractSqlQuery, engine: Engines, noBinds?: boolean, abstractSqlModel?: AbstractSqlModel): SqlResult | [SqlResult, SqlResult] | string; | ||
export declare function compileRule(abstractSQL: UpsertQueryNode, engine: Engines, noBinds: true): [string, string]; | ||
export declare function compileRule(abstractSQL: AbstractSqlQuery, engine: Engines, noBinds: true): string; | ||
export declare function compileRule(abstractSQL: UpsertQueryNode, engine: Engines, noBinds?: false): [SqlResult, SqlResult]; | ||
export declare function compileRule(abstractSQL: SelectQueryNode | UnionQueryNode | InsertQueryNode | UpdateQueryNode | DeleteQueryNode, engine: Engines, noBinds?: false): SqlResult; | ||
export declare function compileRule(abstractSQL: AbstractSqlQuery, engine: Engines, noBinds?: false): SqlResult | [SqlResult, SqlResult]; | ||
export declare function compileRule(abstractSQL: AbstractSqlQuery, engine: Engines, noBinds?: boolean): SqlResult | [SqlResult, SqlResult] | string; | ||
export declare const postgres: { | ||
optimizeSchema: (abstractSqlModel: AbstractSqlModel) => AbstractSqlModel; | ||
compileSchema: (abstractSqlModel: AbstractSqlModel) => SqlModel; | ||
compileRule: (abstractSQL: AbstractSqlQuery, abstractSqlModel?: AbstractSqlModel | undefined) => SqlResult | [SqlResult, SqlResult]; | ||
compileRule: (abstractSQL: AbstractSqlQuery) => SqlResult | [SqlResult, SqlResult]; | ||
dataTypeValidate: (value: any, field: Pick<AbstractSqlField, 'dataType' | 'required'>) => Promise<any>; | ||
@@ -250,3 +250,3 @@ getReferencedFields: (ruleBody: AbstractSqlQuery) => ReferencedFields; | ||
compileSchema: (abstractSqlModel: AbstractSqlModel) => SqlModel; | ||
compileRule: (abstractSQL: AbstractSqlQuery, abstractSqlModel?: AbstractSqlModel | undefined) => SqlResult | [SqlResult, SqlResult]; | ||
compileRule: (abstractSQL: AbstractSqlQuery) => SqlResult | [SqlResult, SqlResult]; | ||
dataTypeValidate: (value: any, field: Pick<AbstractSqlField, 'dataType' | 'required'>) => Promise<any>; | ||
@@ -260,3 +260,3 @@ getReferencedFields: (ruleBody: AbstractSqlQuery) => ReferencedFields; | ||
compileSchema: (abstractSqlModel: AbstractSqlModel) => SqlModel; | ||
compileRule: (abstractSQL: AbstractSqlQuery, abstractSqlModel?: AbstractSqlModel | undefined) => SqlResult | [SqlResult, SqlResult]; | ||
compileRule: (abstractSQL: AbstractSqlQuery) => SqlResult | [SqlResult, SqlResult]; | ||
dataTypeValidate: (value: any, field: Pick<AbstractSqlField, 'dataType' | 'required'>) => Promise<any>; | ||
@@ -263,0 +263,0 @@ getReferencedFields: (ruleBody: AbstractSqlQuery) => ReferencedFields; |
@@ -85,4 +85,4 @@ "use strict"; | ||
}; | ||
function compileRule(abstractSQL, engine, noBinds = false, abstractSqlModel) { | ||
abstractSQL = AbstractSQLOptimiser_1.AbstractSQLOptimiser(abstractSQL, noBinds, abstractSqlModel); | ||
function compileRule(abstractSQL, engine, noBinds = false) { | ||
abstractSQL = AbstractSQLOptimiser_1.AbstractSQLOptimiser(abstractSQL, noBinds); | ||
return AbstractSQLRules2SQL_1.AbstractSQLRules2SQL(abstractSQL, engine, noBinds); | ||
@@ -160,3 +160,3 @@ } | ||
CREATE ${orReplaceStr}VIEW "${table.name}" AS ( | ||
${compileRule(definitionAbstractSql, engine, true, abstractSqlModel).replace(/^/gm, ' ')} | ||
${compileRule(definitionAbstractSql, engine, true).replace(/^/gm, ' ')} | ||
);`, | ||
@@ -226,3 +226,3 @@ ], | ||
const constraintName = check.name ? `CONSTRAINT "${check.name}" ` : ''; | ||
const sql = compileRule(check.abstractSql, engine, true, abstractSqlModel); | ||
const sql = compileRule(check.abstractSql, engine, true); | ||
createSqlElements.push(`\ | ||
@@ -324,3 +324,3 @@ ${comment}${constraintName}CHECK (${sql})`); | ||
} | ||
const { query: ruleSQL, bindings: ruleBindings } = compileRule(ruleBody, engine, undefined, abstractSqlModel); | ||
const { query: ruleSQL, bindings: ruleBindings } = compileRule(ruleBody, engine); | ||
let referencedFields; | ||
@@ -361,3 +361,3 @@ try { | ||
compileSchema: (abstractSqlModel) => compileSchema(abstractSqlModel, engine, ifNotExists), | ||
compileRule: (abstractSQL, abstractSqlModel) => compileRule(abstractSQL, engine, false, abstractSqlModel), | ||
compileRule: (abstractSQL) => compileRule(abstractSQL, engine, false), | ||
dataTypeValidate, | ||
@@ -364,0 +364,0 @@ getReferencedFields: referenced_fields_1.getReferencedFields, |
@@ -1,2 +0,2 @@ | ||
import { AbstractSqlModel, AbstractSqlQuery } from './AbstractSQLCompiler'; | ||
export declare const AbstractSQLOptimiser: (abstractSQL: AbstractSqlQuery, $noBinds?: boolean, $abstractSqlModel?: AbstractSqlModel | undefined) => AbstractSqlQuery; | ||
import { AbstractSqlQuery } from './AbstractSQLCompiler'; | ||
export declare const AbstractSQLOptimiser: (abstractSQL: AbstractSqlQuery, $noBinds?: boolean) => AbstractSqlQuery; |
@@ -6,3 +6,3 @@ "use strict"; | ||
const AbstractSQLRules2SQL = require("./AbstractSQLRules2SQL"); | ||
const { isAbstractSqlQuery, getAbstractSqlQuery, checkArgs, checkMinArgs, } = AbstractSQLRules2SQL; | ||
const { isAbstractSqlQuery, getAbstractSqlQuery, checkArgs, checkMinArgs, isNotNullable, } = AbstractSQLRules2SQL; | ||
const escapeForLike = (str) => [ | ||
@@ -20,5 +20,3 @@ 'Replace', | ||
let helped = false; | ||
let aliases = {}; | ||
let noBinds = false; | ||
let abstractSqlModel; | ||
const Helper = (fn) => { | ||
@@ -50,18 +48,2 @@ return (...args) => { | ||
}; | ||
const isNotNullable = (node) => { | ||
var _a; | ||
switch (node[0]) { | ||
case 'ReferencedField': | ||
if (abstractSqlModel != null) { | ||
const [, aliasName, fieldName] = node; | ||
const tableName = (_a = aliases[aliasName]) !== null && _a !== void 0 ? _a : aliasName; | ||
const table = abstractSqlModel.tables[tableName]; | ||
const field = table === null || table === void 0 ? void 0 : table.fields.find((f) => f.fieldName === fieldName); | ||
if ((field === null || field === void 0 ? void 0 : field.required) === true) { | ||
return true; | ||
} | ||
} | ||
} | ||
return AbstractSQLRules2SQL.isNotNullable(node); | ||
}; | ||
const rewriteMatch = (name, matchers, rewriteFn) => (args) => { | ||
@@ -397,6 +379,2 @@ checkArgs(name, args, matchers.length); | ||
checkArgs('From', args, 1); | ||
const maybeAlias = args[0]; | ||
if (maybeAlias[0] === 'Alias' && maybeAlias[1][0] === 'Table') { | ||
aliases[maybeAlias[2]] = maybeAlias[1][1]; | ||
} | ||
return ['From', MaybeAlias(args[0], FromMatch)]; | ||
@@ -1141,8 +1119,6 @@ }, | ||
}; | ||
const AbstractSQLOptimiser = (abstractSQL, $noBinds = false, $abstractSqlModel) => { | ||
const AbstractSQLOptimiser = (abstractSQL, $noBinds = false) => { | ||
noBinds = $noBinds; | ||
abstractSqlModel = $abstractSqlModel; | ||
do { | ||
helped = false; | ||
aliases = {}; | ||
const [type, ...rest] = abstractSQL; | ||
@@ -1149,0 +1125,0 @@ switch (type) { |
@@ -663,3 +663,3 @@ "use strict"; | ||
} | ||
return b ? '1' : '0'; | ||
return b ? 'TRUE' : 'FALSE'; | ||
}, | ||
@@ -666,0 +666,0 @@ EmbeddedText: (args) => { |
@@ -48,3 +48,3 @@ "use strict"; | ||
} | ||
ruleBodyNode[1] = ruleBody = AbstractSQLOptimiser_1.AbstractSQLOptimiser(ruleBody, true, abstractSqlModel); | ||
ruleBodyNode[1] = ruleBody = AbstractSQLOptimiser_1.AbstractSQLOptimiser(ruleBody, true); | ||
const count = countFroms(ruleBody); | ||
@@ -51,0 +51,0 @@ if (count === 1 && |
{ | ||
"name": "@balena/abstract-sql-compiler", | ||
"version": "7.13.0-model-based-optimizations-37f50ae20f73dc307eea1aa0c87a138d08a50f00", | ||
"version": "8.0.0-true-boolean-5914ecfede7efc56e38162b4f9dfa5e19f0d0792", | ||
"description": "A translator for abstract sql into sql.", | ||
@@ -18,5 +18,5 @@ "main": "out/AbstractSQLCompiler.js", | ||
"dependencies": { | ||
"@balena/sbvr-types": "^3.4.2", | ||
"@balena/sbvr-types": "4.0.0-true-boolean-4d20b304f0092f3c3bbe389588059c11e679e08d", | ||
"@types/lodash": "^4.14.168", | ||
"@types/node": "^10.17.55", | ||
"@types/node": "^10.17.59", | ||
"lodash": "^4.17.21" | ||
@@ -26,7 +26,7 @@ }, | ||
"@balena/lf-to-abstract-sql": "^4.2.1", | ||
"@balena/lint": "^5.4.1", | ||
"@balena/lint": "^5.4.2", | ||
"@balena/odata-parser": "^2.2.3", | ||
"@balena/sbvr-parser": "^1.2.2", | ||
"@resin/odata-to-abstract-sql": "^3.3.0", | ||
"@types/chai": "^4.2.15", | ||
"@types/chai": "^4.2.17", | ||
"@types/common-tags": "^1.8.0", | ||
@@ -41,3 +41,3 @@ "@types/mocha": "^8.2.2", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.2.3" | ||
"typescript": "^4.2.4" | ||
}, | ||
@@ -44,0 +44,0 @@ "husky": { |
@@ -458,3 +458,2 @@ export const enum Engines { | ||
noBinds: true, | ||
abstractSqlModel?: AbstractSqlModel, | ||
): [string, string]; | ||
@@ -465,3 +464,2 @@ export function compileRule( | ||
noBinds: true, | ||
abstractSqlModel?: AbstractSqlModel, | ||
): string; | ||
@@ -472,3 +470,2 @@ export function compileRule( | ||
noBinds?: false, | ||
abstractSqlModel?: AbstractSqlModel, | ||
): [SqlResult, SqlResult]; | ||
@@ -484,3 +481,2 @@ export function compileRule( | ||
noBinds?: false, | ||
abstractSqlModel?: AbstractSqlModel, | ||
): SqlResult; | ||
@@ -491,3 +487,2 @@ export function compileRule( | ||
noBinds?: false, | ||
abstractSqlModel?: AbstractSqlModel, | ||
): SqlResult | [SqlResult, SqlResult]; | ||
@@ -498,3 +493,2 @@ export function compileRule( | ||
noBinds?: boolean, | ||
abstractSqlModel?: AbstractSqlModel, | ||
): SqlResult | [SqlResult, SqlResult] | string; | ||
@@ -505,5 +499,4 @@ export function compileRule( | ||
noBinds = false, | ||
abstractSqlModel?: AbstractSqlModel, | ||
): SqlResult | [SqlResult, SqlResult] | string | [string, string] { | ||
abstractSQL = AbstractSQLOptimiser(abstractSQL, noBinds, abstractSqlModel); | ||
abstractSQL = AbstractSQLOptimiser(abstractSQL, noBinds); | ||
return AbstractSQLRules2SQL(abstractSQL, engine, noBinds); | ||
@@ -603,8 +596,6 @@ } | ||
CREATE ${orReplaceStr}VIEW "${table.name}" AS ( | ||
${compileRule( | ||
definitionAbstractSql as AbstractSqlQuery, | ||
engine, | ||
true, | ||
abstractSqlModel, | ||
).replace(/^/gm, ' ')} | ||
${compileRule(definitionAbstractSql as AbstractSqlQuery, engine, true).replace( | ||
/^/gm, | ||
' ', | ||
)} | ||
);`, | ||
@@ -691,3 +682,2 @@ ], | ||
true, | ||
abstractSqlModel, | ||
); | ||
@@ -818,4 +808,2 @@ createSqlElements.push(`\ | ||
engine, | ||
undefined, | ||
abstractSqlModel, | ||
) as SqlResult; | ||
@@ -860,6 +848,4 @@ let referencedFields: ReferencedFields | undefined; | ||
compileSchema(abstractSqlModel, engine, ifNotExists), | ||
compileRule: ( | ||
abstractSQL: AbstractSqlQuery, | ||
abstractSqlModel?: AbstractSqlModel, | ||
) => compileRule(abstractSQL, engine, false, abstractSqlModel), | ||
compileRule: (abstractSQL: AbstractSqlQuery) => | ||
compileRule(abstractSQL, engine, false), | ||
dataTypeValidate, | ||
@@ -866,0 +852,0 @@ getReferencedFields, |
@@ -5,10 +5,6 @@ import * as _ from 'lodash'; | ||
import { | ||
AbstractSqlModel, | ||
AbstractSqlQuery, | ||
AbstractSqlType, | ||
AliasNode, | ||
DurationNode, | ||
ReferencedFieldNode, | ||
ReplaceNode, | ||
TableNode, | ||
} from './AbstractSQLCompiler'; | ||
@@ -22,2 +18,3 @@ import * as AbstractSQLRules2SQL from './AbstractSQLRules2SQL'; | ||
checkMinArgs, | ||
isNotNullable, | ||
} = AbstractSQLRules2SQL; | ||
@@ -44,5 +41,3 @@ | ||
let helped = false; | ||
let aliases: { [alias: string]: string } = {}; | ||
let noBinds = false; | ||
let abstractSqlModel: AbstractSqlModel | undefined; | ||
const Helper = <F extends (...args: any[]) => any>(fn: F) => { | ||
@@ -76,18 +71,2 @@ return (...args: Parameters<F>): ReturnType<F> => { | ||
const isNotNullable = (node: AbstractSqlQuery): boolean => { | ||
switch (node[0]) { | ||
case 'ReferencedField': | ||
if (abstractSqlModel != null) { | ||
const [, aliasName, fieldName] = node as ReferencedFieldNode; | ||
const tableName = aliases[aliasName] ?? aliasName; | ||
const table = abstractSqlModel.tables[tableName]; | ||
const field = table?.fields.find((f) => f.fieldName === fieldName); | ||
if (field?.required === true) { | ||
return true; | ||
} | ||
} | ||
} | ||
return AbstractSQLRules2SQL.isNotNullable(node); | ||
}; | ||
const rewriteMatch = ( | ||
@@ -483,6 +462,2 @@ name: string, | ||
checkArgs('From', args, 1); | ||
const maybeAlias = args[0] as AliasNode<TableNode>; | ||
if (maybeAlias[0] === 'Alias' && maybeAlias[1][0] === 'Table') { | ||
aliases[maybeAlias[2]] = maybeAlias[1][1]; | ||
} | ||
return ['From', MaybeAlias(args[0] as AbstractSqlQuery, FromMatch)]; | ||
@@ -1344,9 +1319,6 @@ }, | ||
$noBinds = false, | ||
$abstractSqlModel?: AbstractSqlModel, | ||
): AbstractSqlQuery => { | ||
noBinds = $noBinds; | ||
abstractSqlModel = $abstractSqlModel; | ||
do { | ||
helped = false; | ||
aliases = {}; | ||
const [type, ...rest] = abstractSQL; | ||
@@ -1353,0 +1325,0 @@ switch (type) { |
@@ -765,3 +765,3 @@ import * as _ from 'lodash'; | ||
} | ||
return b ? '1' : '0'; | ||
return b ? 'TRUE' : 'FALSE'; | ||
}, | ||
@@ -768,0 +768,0 @@ EmbeddedText: (args) => { |
@@ -63,7 +63,3 @@ export const enum Engines { | ||
// Optimize the rule body, this also normalizes it making the check constraint check easier | ||
ruleBodyNode[1] = ruleBody = AbstractSQLOptimiser( | ||
ruleBody, | ||
true, | ||
abstractSqlModel, | ||
); | ||
ruleBodyNode[1] = ruleBody = AbstractSQLOptimiser(ruleBody, true); | ||
@@ -70,0 +66,0 @@ const count = countFroms(ruleBody); |
@@ -79,3 +79,3 @@ import * as AbstractSQLCompiler from '../..'; | ||
CONSTRAINT "test$hkEwz3pzAqalNu6crijhhdWJ0ffUvqRGK8rMkQbViPg=" CHECK (0 < "id" | ||
AND \"id\" IS NOT NULL) | ||
AND "id" IS NOT NULL) | ||
);`, | ||
@@ -85,75 +85,2 @@ ]); | ||
it('should optimize null checks for a required field', () => { | ||
expect( | ||
generateSchema({ | ||
synonyms: {}, | ||
relationships: {}, | ||
tables: { | ||
test: { | ||
name: 'test', | ||
resourceName: 'test', | ||
idField: 'id', | ||
fields: [ | ||
{ | ||
fieldName: 'id', | ||
dataType: 'Integer', | ||
required: true, | ||
index: 'PRIMARY KEY', | ||
}, | ||
], | ||
indexes: [], | ||
primitive: false, | ||
}, | ||
}, | ||
rules: [ | ||
[ | ||
'Rule', | ||
[ | ||
'Body', | ||
[ | ||
'Not', | ||
[ | ||
'Exists', | ||
[ | ||
'SelectQuery', | ||
['Select', []], | ||
['From', ['test', 'test.0']], | ||
[ | ||
'Where', | ||
[ | ||
'Not', | ||
[ | ||
'And', | ||
[ | ||
'LessThan', | ||
['Integer', 0], | ||
['ReferencedField', 'test.0', 'id'], | ||
], | ||
['Exists', ['ReferencedField', 'test.0', 'id']], | ||
], | ||
], | ||
], | ||
], | ||
], | ||
], | ||
] as AbstractSQLCompiler.AbstractSqlQuery, | ||
[ | ||
'StructuredEnglish', | ||
'It is necessary that each test has an id that is greater than 0.', | ||
], | ||
], | ||
], | ||
}), | ||
) | ||
.to.have.property('createSchema') | ||
.that.deep.equals([ | ||
`\ | ||
CREATE TABLE IF NOT EXISTS "test" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY | ||
, -- It is necessary that each test has an id that is greater than 0. | ||
CONSTRAINT "test$TIITyGYLwuTGGJjwAk8awbiE/hnw6y8rue+hQ8Pp7as=" CHECK (0 < "id") | ||
);`, | ||
]); | ||
}); | ||
it('should correctly shorten a converted check rule with a long name', () => { | ||
@@ -173,3 +100,2 @@ expect( | ||
dataType: 'Integer', | ||
required: true, | ||
index: 'PRIMARY KEY', | ||
@@ -243,5 +169,6 @@ }, | ||
CREATE TABLE IF NOT EXISTS "test_table_with_very_very_long_name" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY | ||
"id" INTEGER NULL PRIMARY KEY | ||
, -- It is necessary that each test_table_with_very_very_long_name has an id that is greater than 0. | ||
CONSTRAINT "test_table_with_very_very_long$/rDs8gDAB2Zoc7woBPozVMLKpx9jNTNa" CHECK (0 < "id") | ||
CONSTRAINT "test_table_with_very_very_long$9z+XEkP4EI1mhDQ8SiLulo2NLmenGY1C" CHECK (0 < "id" | ||
AND "id" IS NOT NULL) | ||
);`, | ||
@@ -248,0 +175,0 @@ ]); |
@@ -29,4 +29,2 @@ const typeVocab = require('fs').readFileSync( | ||
Concept Type: Short Text (Type) | ||
Term: nickname | ||
Concept Type: Short Text (Type) | ||
Term: years of experience | ||
@@ -42,4 +40,2 @@ Concept Type: Integer (Type) | ||
Necessity: each pilot has exactly one name | ||
Fact Type: pilot has nickname | ||
Necessity: each pilot has at most one nickname | ||
Fact Type: pilot has years of experience | ||
@@ -50,4 +46,2 @@ Necessity: each pilot has exactly one years of experience | ||
Definition: "planeA" or "planeB" or "planeC" | ||
Fact Type: plane has nickname | ||
Necessity: each plane has at most one nickname | ||
Fact Type: pilot can fly plane | ||
@@ -93,3 +87,2 @@ Synonymous Form: plane can be flown by pilot | ||
, "name" VARCHAR(255) NOT NULL CHECK ("name" IN ('planeA', 'planeB', 'planeC')) | ||
, "nickname" VARCHAR(255) NULL | ||
);`, | ||
@@ -119,3 +112,2 @@ modifiedAtTrigger('plane'), | ||
, "name" VARCHAR(255) NOT NULL | ||
, "nickname" VARCHAR(255) NULL | ||
, "years of experience" INTEGER NOT NULL | ||
@@ -231,8 +223,2 @@ , "is experienced" INTEGER DEFAULT 0 NOT NULL | ||
`\ | ||
SELECT 1 AS "result";`, | ||
); | ||
test.rule( | ||
'It is necessary that each plane that at least 3 pilots can fly, has a nickname', | ||
`\ | ||
SELECT NOT EXISTS ( | ||
@@ -246,3 +232,3 @@ SELECT 1 | ||
) >= 3 | ||
AND "plane.0"."nickname" IS NULL | ||
AND "plane.0"."name" IS NULL | ||
) AS "result";`, | ||
@@ -252,3 +238,3 @@ ); | ||
test.rule( | ||
'It is necessary that each plane that at least 3 pilots that are experienced can fly, has a nickname', | ||
'It is necessary that each plane that at least 3 pilots that are experienced can fly, has a name', | ||
`\ | ||
@@ -266,3 +252,3 @@ SELECT NOT EXISTS ( | ||
) >= 3 | ||
AND "plane.0"."nickname" IS NULL | ||
AND "plane.0"."name" IS NULL | ||
) AS "result";`, | ||
@@ -284,10 +270,10 @@ ); | ||
) >= 3 | ||
AND "plane.0"."nickname" IS NULL | ||
AND "plane.0"."name" IS NULL | ||
) AS "result";`; | ||
test.rule( | ||
'It is necessary that each plane that at least 3 pilots that are not experienced can fly, has a nickname', | ||
'It is necessary that each plane that at least 3 pilots that are not experienced can fly, has a name', | ||
sql, | ||
); | ||
test.rule( | ||
"It is necessary that each plane that at least 3 pilots that aren't experienced can fly, has a nickname", | ||
"It is necessary that each plane that at least 3 pilots that aren't experienced can fly, has a name", | ||
sql, | ||
@@ -298,3 +284,3 @@ ); | ||
test.rule( | ||
'It is necessary that each plane that at least 3 pilot that is experienced, can fly, has a nickname.', | ||
'It is necessary that each plane that at least 3 pilot that is experienced, can fly, has a name.', | ||
`\ | ||
@@ -312,3 +298,3 @@ SELECT NOT EXISTS ( | ||
) >= 3 | ||
AND "plane.0"."nickname" IS NULL | ||
AND "plane.0"."name" IS NULL | ||
) AS "result";`, | ||
@@ -318,3 +304,3 @@ ); | ||
test.rule( | ||
'It is necessary that each plane that at least 3 pilots that a name is of can fly, has a nickname', | ||
'It is necessary that each plane that at least 3 pilots that a name is of can fly, has a name', | ||
`\ | ||
@@ -328,6 +314,7 @@ SELECT NOT EXISTS ( | ||
"pilot-can fly-plane" AS "pilot.1-can fly-plane.0" | ||
WHERE "pilot.1-can fly-plane.0"."pilot" = "pilot.1"."id" | ||
WHERE "pilot.1"."name" IS NOT NULL | ||
AND "pilot.1-can fly-plane.0"."pilot" = "pilot.1"."id" | ||
AND "pilot.1-can fly-plane.0"."can fly-plane" = "plane.0"."id" | ||
) >= 3 | ||
AND "plane.0"."nickname" IS NULL | ||
AND "plane.0"."name" IS NULL | ||
) AS "result";`, | ||
@@ -344,2 +331,3 @@ ); | ||
0 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -377,3 +365,4 @@ ) AS "result";`, | ||
) >= 2 | ||
OR 5 < "pilot.0"."years of experience") | ||
OR 5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL) | ||
) | ||
@@ -397,2 +386,3 @@ ) AS "result";`, | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -421,2 +411,3 @@ ) AS "result";`, | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -492,3 +483,3 @@ ) AS "result";`, | ||
test.rule( | ||
'It is necessary that each plane that at least 3 pilots can fly or exactly one pilot can fly, has a nickname', | ||
'It is necessary that each plane that at least 3 pilots can fly or exactly one pilot can fly, has a name', | ||
`\ | ||
@@ -508,3 +499,3 @@ SELECT NOT EXISTS ( | ||
) = 1) | ||
AND "plane.0"."nickname" IS NULL | ||
AND "plane.0"."name" IS NULL | ||
) AS "result";`, | ||
@@ -528,2 +519,3 @@ ); | ||
AND 5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -547,2 +539,3 @@ ) AS "result";`, | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -618,3 +611,3 @@ ) AS "result";`, | ||
test.rule( | ||
'It is necessary that each plane that at least 3 pilots can fly and exactly one pilot can fly, has a nickname', | ||
'It is necessary that each plane that at least 3 pilots can fly and exactly one pilot can fly, has a name', | ||
`\ | ||
@@ -634,3 +627,3 @@ SELECT NOT EXISTS ( | ||
) = 1 | ||
AND "plane.0"."nickname" IS NULL | ||
AND "plane.0"."name" IS NULL | ||
) AS "result";`, | ||
@@ -659,2 +652,3 @@ ); | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -683,2 +677,3 @@ ) AS "result";`, | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -710,2 +705,3 @@ ) AS "result";`, | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -734,2 +730,3 @@ ) AS "result";`, | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -759,5 +756,7 @@ ) AS "result";`, | ||
OR 10 < LENGTH("pilot.0"."name") | ||
AND LENGTH("pilot.0"."name") IS NOT NULL) | ||
AND LENGTH("pilot.0"."name") IS NOT NULL | ||
AND "pilot.0"."name" IS NOT NULL) | ||
AND NOT ( | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -785,5 +784,7 @@ ) AS "result";`, | ||
AND 10 < LENGTH("pilot.0"."name") | ||
AND LENGTH("pilot.0"."name") IS NOT NULL) | ||
AND LENGTH("pilot.0"."name") IS NOT NULL | ||
AND "pilot.0"."name" IS NOT NULL) | ||
AND NOT ( | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -811,5 +812,7 @@ ) AS "result";`, | ||
AND 10 < LENGTH("pilot.0"."name") | ||
AND LENGTH("pilot.0"."name") IS NOT NULL) | ||
AND LENGTH("pilot.0"."name") IS NOT NULL | ||
AND "pilot.0"."name" IS NOT NULL) | ||
AND NOT ( | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -837,5 +840,7 @@ ) AS "result";`, | ||
AND 10 < LENGTH("pilot.0"."name") | ||
AND LENGTH("pilot.0"."name") IS NOT NULL) | ||
AND LENGTH("pilot.0"."name") IS NOT NULL | ||
AND "pilot.0"."name" IS NOT NULL) | ||
AND NOT ( | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -869,2 +874,3 @@ ) AS "result";`, | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -900,2 +906,3 @@ ) AS "result";`, | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -920,3 +927,4 @@ ) AS "result";`, | ||
OR 10 < LENGTH("pilot.0"."name") | ||
AND LENGTH("pilot.0"."name") IS NOT NULL) | ||
AND LENGTH("pilot.0"."name") IS NOT NULL | ||
AND "pilot.0"."name" IS NOT NULL) | ||
AND ( | ||
@@ -929,2 +937,3 @@ SELECT COUNT(*) | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -948,2 +957,3 @@ ) AS "result";`, | ||
AND LENGTH("pilot.0"."name") IS NOT NULL | ||
AND "pilot.0"."name" IS NOT NULL | ||
OR ( | ||
@@ -956,2 +966,3 @@ SELECT COUNT(*) | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -987,2 +998,3 @@ ) AS "result";`, | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -1018,2 +1030,3 @@ ) AS "result";`, | ||
5 < "pilot.0"."years of experience" | ||
AND "pilot.0"."years of experience" IS NOT NULL | ||
) | ||
@@ -1020,0 +1033,0 @@ ) AS "result";`, |
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
608782
58
13357
+ Added@balena/sbvr-types@4.0.0-true-boolean-4d20b304f0092f3c3bbe389588059c11e679e08d(transitive)
+ Added@types/bcrypt@3.0.1(transitive)
+ Added@types/sha.js@2.4.4(transitive)
- Removed@balena/sbvr-types@3.5.0(transitive)
Updated@balena/sbvr-types@4.0.0-true-boolean-4d20b304f0092f3c3bbe389588059c11e679e08d
Updated@types/node@^10.17.59