@balena/abstract-sql-compiler
Advanced tools
Comparing version 7.8.0 to 7.8.1-lodash-to-native-400937fd3b220dccd557d67ff33d83d51ff0b939
@@ -7,2 +7,6 @@ # Change Log | ||
## 7.8.1 - 2021-01-04 | ||
* Convert some lodash usage to native equivalents [Pagan Gazzard] | ||
## 7.8.0 - 2021-01-01 | ||
@@ -9,0 +13,0 @@ |
@@ -241,3 +241,3 @@ export declare const enum Engines { | ||
optimizeSchema: (abstractSqlModel: AbstractSqlModel) => AbstractSqlModel; | ||
compileSchema: _.Function1<AbstractSqlModel, SqlModel>; | ||
compileSchema: (abstractSqlModel: AbstractSqlModel) => SqlModel; | ||
compileRule: (abstractSQL: AbstractSqlQuery) => SqlResult | [SqlResult, SqlResult]; | ||
@@ -250,3 +250,3 @@ dataTypeValidate: (value: any, field: Pick<AbstractSqlField, 'dataType' | 'required'>) => Promise<any>; | ||
optimizeSchema: (abstractSqlModel: AbstractSqlModel) => AbstractSqlModel; | ||
compileSchema: _.Function1<AbstractSqlModel, SqlModel>; | ||
compileSchema: (abstractSqlModel: AbstractSqlModel) => SqlModel; | ||
compileRule: (abstractSQL: AbstractSqlQuery) => SqlResult | [SqlResult, SqlResult]; | ||
@@ -259,3 +259,3 @@ dataTypeValidate: (value: any, field: Pick<AbstractSqlField, 'dataType' | 'required'>) => Promise<any>; | ||
optimizeSchema: (abstractSqlModel: AbstractSqlModel) => AbstractSqlModel; | ||
compileSchema: _.Function1<AbstractSqlModel, SqlModel>; | ||
compileSchema: (abstractSqlModel: AbstractSqlModel) => SqlModel; | ||
compileRule: (abstractSQL: AbstractSqlQuery) => SqlResult | [SqlResult, SqlResult]; | ||
@@ -262,0 +262,0 @@ dataTypeValidate: (value: any, field: Pick<AbstractSqlField, 'dataType' | 'required'>) => Promise<any>; |
@@ -207,3 +207,4 @@ "use strict"; | ||
if (abstractSqlModel.functions) { | ||
_.forEach(abstractSqlModel.functions, (fnDefinition, fnName) => { | ||
for (const fnName of Object.keys(abstractSqlModel.functions)) { | ||
const fnDefinition = abstractSqlModel.functions[fnName]; | ||
if (engine !== "postgres") { | ||
@@ -233,7 +234,8 @@ throw new Error('Functions are only supported on postgres currently'); | ||
dropSchemaStatements.push(`DROP FUNCTION "${fnName}"();`); | ||
}); | ||
} | ||
} | ||
const hasDependants = {}; | ||
const schemaDependencyMap = {}; | ||
_.forOwn(abstractSqlModel.tables, (table, resourceName) => { | ||
Object.keys(abstractSqlModel.tables).forEach((resourceName) => { | ||
const table = abstractSqlModel.tables[resourceName]; | ||
if (typeof table === 'string') { | ||
@@ -403,3 +405,3 @@ return; | ||
} | ||
if (_.size(schemaDependencyMap) > 0) { | ||
if (Object.keys(schemaDependencyMap).length > 0) { | ||
console.error('Failed to resolve all schema dependencies', schemaDependencyMap); | ||
@@ -454,3 +456,3 @@ throw new Error('Failed to resolve all schema dependencies'); | ||
optimizeSchema: AbstractSQLSchemaOptimiser_1.optimizeSchema, | ||
compileSchema: _.partial(compileSchema, _, engine, ifNotExists), | ||
compileSchema: (abstractSqlModel) => compileSchema(abstractSqlModel, engine, ifNotExists), | ||
compileRule: (abstractSQL) => compileRule(abstractSQL, engine, false), | ||
@@ -457,0 +459,0 @@ dataTypeValidate, |
@@ -662,3 +662,4 @@ "use strict"; | ||
} | ||
const fields = _.map(fieldBuckets, (fieldBucket) => { | ||
const fields = Object.keys(fieldBuckets).map((fieldRef) => { | ||
const fieldBucket = fieldBuckets[fieldRef]; | ||
if (fieldBucket.length === 1) { | ||
@@ -772,3 +773,4 @@ return fieldBucket[0]; | ||
} | ||
const fields = _.map(fieldBuckets, (fieldBucket) => { | ||
const fields = Object.keys(fieldBuckets).map((fieldRef) => { | ||
const fieldBucket = fieldBuckets[fieldRef]; | ||
if (fieldBucket.length === 1) { | ||
@@ -813,3 +815,3 @@ return fieldBucket[0]; | ||
let duration = args[0]; | ||
if (!_.isObject(duration)) { | ||
if (duration == null || typeof duration !== 'object') { | ||
throw new SyntaxError(`Duration must be an object, got ${typeof duration}`); | ||
@@ -816,0 +818,0 @@ } |
@@ -929,3 +929,3 @@ "use strict"; | ||
let duration = args[0]; | ||
if (!_.isObject(duration)) { | ||
if (duration == null || typeof duration !== 'object') { | ||
throw new SyntaxError(`Duration must be an object, got ${typeof duration}`); | ||
@@ -932,0 +932,0 @@ } |
{ | ||
"name": "@balena/abstract-sql-compiler", | ||
"version": "7.8.0", | ||
"version": "7.8.1-lodash-to-native-400937fd3b220dccd557d67ff33d83d51ff0b939", | ||
"description": "A translator for abstract sql into sql.", | ||
@@ -5,0 +5,0 @@ "main": "out/AbstractSQLCompiler.js", |
@@ -632,3 +632,4 @@ export const enum Engines { | ||
if (abstractSqlModel.functions) { | ||
_.forEach(abstractSqlModel.functions, (fnDefinition, fnName) => { | ||
for (const fnName of Object.keys(abstractSqlModel.functions)) { | ||
const fnDefinition = abstractSqlModel.functions[fnName]; | ||
if (engine !== Engines.postgres) { | ||
@@ -658,3 +659,3 @@ throw new Error('Functions are only supported on postgres currently'); | ||
dropSchemaStatements.push(`DROP FUNCTION "${fnName}"();`); | ||
}); | ||
} | ||
} | ||
@@ -674,3 +675,4 @@ | ||
} = {}; | ||
_.forOwn(abstractSqlModel.tables, (table, resourceName) => { | ||
Object.keys(abstractSqlModel.tables).forEach((resourceName) => { | ||
const table = abstractSqlModel.tables[resourceName]; | ||
if (typeof table === 'string') { | ||
@@ -879,3 +881,3 @@ return; | ||
} | ||
if (_.size(schemaDependencyMap) > 0) { | ||
if (Object.keys(schemaDependencyMap).length > 0) { | ||
console.error( | ||
@@ -947,3 +949,4 @@ 'Failed to resolve all schema dependencies', | ||
optimizeSchema, | ||
compileSchema: _.partial(compileSchema, _, engine, ifNotExists), | ||
compileSchema: (abstractSqlModel: AbstractSqlModel) => | ||
compileSchema(abstractSqlModel, engine, ifNotExists), | ||
compileRule: (abstractSQL: AbstractSqlQuery) => | ||
@@ -950,0 +953,0 @@ compileRule(abstractSQL, engine, false), |
@@ -774,3 +774,4 @@ import * as _ from 'lodash'; | ||
} | ||
const fields = _.map(fieldBuckets, (fieldBucket) => { | ||
const fields = Object.keys(fieldBuckets).map((fieldRef) => { | ||
const fieldBucket = fieldBuckets[fieldRef]; | ||
if (fieldBucket.length === 1) { | ||
@@ -899,3 +900,4 @@ return fieldBucket[0]; | ||
} | ||
const fields = _.map(fieldBuckets, (fieldBucket) => { | ||
const fields = Object.keys(fieldBuckets).map((fieldRef) => { | ||
const fieldBucket = fieldBuckets[fieldRef]; | ||
if (fieldBucket.length === 1) { | ||
@@ -944,3 +946,3 @@ return fieldBucket[0]; | ||
let duration = args[0] as DurationNode[1]; | ||
if (!_.isObject(duration)) { | ||
if (duration == null || typeof duration !== 'object') { | ||
throw new SyntaxError( | ||
@@ -947,0 +949,0 @@ `Duration must be an object, got ${typeof duration}`, |
@@ -1047,3 +1047,3 @@ import * as _ from 'lodash'; | ||
let duration = (args[0] as any) as Dictionary<string>; | ||
if (!_.isObject(duration)) { | ||
if (duration == null || typeof duration !== 'object') { | ||
throw new SyntaxError( | ||
@@ -1050,0 +1050,0 @@ `Duration must be an object, got ${typeof duration}`, |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
581596
12812
2