@balena/odata-to-abstract-sql
Advanced tools
Comparing version 6.1.0-build-fisehara-optimize-computed-fields-b06efaec9f3e4ebc2e658fe2122a6d4fe4c3da7c-1 to 6.1.0-build-fisehara-optimize-computed-fields-c49228243e373623eba9f8d63e2f2b391e3517b1-1
@@ -7,6 +7,33 @@ # Change Log | ||
## 6.1.0 - 2023-04-26 | ||
## 6.1.0 - 2023-04-27 | ||
* Optimize Duplications of `ComputedField` queries [fisehara] | ||
## 6.0.1 - 2023-04-27 | ||
<details> | ||
<summary> Update dependencies [Pagan Gazzard] </summary> | ||
> ### odata-parser-3.0.0 - 2023-04-26 | ||
> | ||
> * Use optional chaining operator [Pagan Gazzard] | ||
> * Set minimum supported nodejs version to 16.13.0 [Pagan Gazzard] | ||
> | ||
> ### odata-parser-2.5.0 - 2023-04-26 | ||
> | ||
> * Update to peggy 3 and make us of the repetition operator [Pagan Gazzard] | ||
> | ||
> ### sbvr-types-4.0.0 - 2023-04-26 | ||
> | ||
> * Add test cases for Objects in JSON validate [fisehara] | ||
> * Drop `require-npm4-to-publish` devDependency [fisehara] | ||
> * Set minimum supported nodejs version to 16.13.0 and tsconfig to es2021 [Pagan Gazzard] | ||
> * Switch `JSON` to use `JSON` db type instead of `TEXT` [Pagan Gazzard] | ||
> * Switch `Boolean` to use `BOOLEAN` db type instead of `INTEGER` [Pagan Gazzard] | ||
> * Assert that JSON input typeof is object [Josh Bowling] | ||
> | ||
</details> | ||
## 6.0.0 - 2023-04-26 | ||
@@ -13,0 +40,0 @@ |
@@ -121,6 +121,5 @@ "use strict"; | ||
exports.isBindReference = isBindReference; | ||
const isDynamicResource = (resource, modelName, alreadyComputedFields) => { | ||
const isDynamicResource = (resource) => { | ||
return (resource.definition != null || | ||
resource.fields.some((f) => f.computed != null && | ||
!alreadyComputedFields[modelName + resource.name + f.fieldName])); | ||
resource.fields.some((f) => f.computed != null)); | ||
}; | ||
@@ -313,5 +312,3 @@ const addBodyKey = (resourceName, fieldName, bind, bodyKeys, extraBodyVars) => { | ||
query.extras.push(['Fields', bindVars.map((b) => b[0])]); | ||
if ((hasQueryOpts || | ||
isDynamicResource(resource, this.modelName, this.alreadyComputedFields) || | ||
pathKeyWhere != null) && | ||
if ((hasQueryOpts || isDynamicResource(resource) || pathKeyWhere != null) && | ||
(method === 'POST' || method === 'PUT-INSERT')) { | ||
@@ -330,3 +327,5 @@ const subQuery = new Query(); | ||
'Select', | ||
(resource.modifyFields ?? resource.fields).map((field) => { | ||
(resource.modifyFields ?? resource.fields) | ||
.filter((field) => field.computed == null) | ||
.map((field) => { | ||
const alias = field.fieldName; | ||
@@ -429,4 +428,3 @@ const bindVar = bindVars?.find((v) => v[0] === alias); | ||
} | ||
if ((hasQueryOpts || | ||
isDynamicResource(resource, this.modelName, this.alreadyComputedFields)) && | ||
if ((hasQueryOpts || isDynamicResource(resource)) && | ||
(method === 'PUT' || | ||
@@ -677,2 +675,3 @@ method === 'PATCH' || | ||
} | ||
this.alreadyComputedFields[key] = true; | ||
return ['Alias', computed, alias]; | ||
@@ -1175,2 +1174,3 @@ } | ||
this.extraBindVars = []; | ||
this.alreadyComputedFields = {}; | ||
} | ||
@@ -1221,7 +1221,3 @@ putReset() { | ||
['Field', '*'], | ||
...computedFields.map((field) => { | ||
const returnField = this.AliasSelectField(resource, (0, exports.sqlNameToODataName)(field.fieldName), field.computed, field.fieldName); | ||
this.alreadyComputedFields[this.modelName + resource.name + field.fieldName] = true; | ||
return returnField; | ||
}), | ||
...computedFields.map((field) => this.AliasSelectField(resource, (0, exports.sqlNameToODataName)(field.fieldName), field.computed, field.fieldName)), | ||
]; | ||
@@ -1228,0 +1224,0 @@ computedFieldQuery.fromResource(this, { |
{ | ||
"name": "@balena/odata-to-abstract-sql", | ||
"version": "6.1.0-build-fisehara-optimize-computed-fields-b06efaec9f3e4ebc2e658fe2122a6d4fe4c3da7c-1", | ||
"version": "6.1.0-build-fisehara-optimize-computed-fields-c49228243e373623eba9f8d63e2f2b391e3517b1-1", | ||
"description": "A consumer of the OData parser, written in OMeta", | ||
@@ -18,4 +18,4 @@ "main": "out/odata-to-abstract-sql.js", | ||
"dependencies": { | ||
"@balena/odata-parser": "^3.0.0", | ||
"@balena/abstract-sql-compiler": "8.5.0-build-fisehara-add-model-name-de7bf8742e600a58df7b5a8339b8f8c6b0eab1db-1", | ||
"@balena/odata-parser": "^2.4.6", | ||
"@types/lodash": "^4.14.194", | ||
@@ -32,3 +32,3 @@ "@types/memoizee": "^0.4.8", | ||
"@balena/sbvr-parser": "^1.4.3", | ||
"@balena/sbvr-types": "^3.5.0", | ||
"@balena/sbvr-types": "^4.0.0", | ||
"@types/chai": "^4.3.4", | ||
@@ -40,3 +40,3 @@ "@types/chai-things": "0.0.35", | ||
"husky": "^8.0.3", | ||
"lint-staged": "^13.2.1", | ||
"lint-staged": "^13.2.2", | ||
"mocha": "^10.2.0", | ||
@@ -59,4 +59,4 @@ "require-npm4-to-publish": "^1.0.0", | ||
"versionist": { | ||
"publishedAt": "2023-04-26T15:09:57.408Z" | ||
"publishedAt": "2023-04-27T10:21:57.874Z" | ||
} | ||
} |
@@ -303,14 +303,6 @@ import * as _ from 'lodash'; | ||
const isDynamicResource = ( | ||
resource: Resource, | ||
modelName: string, | ||
alreadyComputedFields: AlreadyComputedFieldsLookup, | ||
): boolean => { | ||
const isDynamicResource = (resource: Resource): boolean => { | ||
return ( | ||
resource.definition != null || | ||
resource.fields.some( | ||
(f) => | ||
f.computed != null && | ||
!alreadyComputedFields[modelName + resource.name + f.fieldName], | ||
) | ||
resource.fields.some((f) => f.computed != null) | ||
); | ||
@@ -560,9 +552,3 @@ }; | ||
if ( | ||
(hasQueryOpts || | ||
isDynamicResource( | ||
resource, | ||
this.modelName, | ||
this.alreadyComputedFields, | ||
) || | ||
pathKeyWhere != null) && | ||
(hasQueryOpts || isDynamicResource(resource) || pathKeyWhere != null) && | ||
(method === 'POST' || method === 'PUT-INSERT') | ||
@@ -586,4 +572,5 @@ ) { | ||
'Select', | ||
(resource.modifyFields ?? resource.fields).map( | ||
(field): AliasNode<CastNode> => { | ||
(resource.modifyFields ?? resource.fields) | ||
.filter((field) => field.computed == null) | ||
.map((field): AliasNode<CastNode> => { | ||
const alias = field.fieldName; | ||
@@ -598,4 +585,3 @@ const bindVar = bindVars?.find((v) => v[0] === alias); | ||
return ['Alias', ['Cast', value, field.dataType], alias]; | ||
}, | ||
), | ||
}), | ||
], | ||
@@ -713,8 +699,3 @@ ], | ||
if ( | ||
(hasQueryOpts || | ||
isDynamicResource( | ||
resource, | ||
this.modelName, | ||
this.alreadyComputedFields, | ||
)) && | ||
(hasQueryOpts || isDynamicResource(resource)) && | ||
(method === 'PUT' || | ||
@@ -1039,2 +1020,3 @@ method === 'PATCH' || | ||
} | ||
this.alreadyComputedFields[key] = true; | ||
return ['Alias', computed, alias]; | ||
@@ -1666,2 +1648,3 @@ } | ||
this.extraBindVars = [] as unknown as ODataBinds; | ||
this.alreadyComputedFields = {}; | ||
} | ||
@@ -1724,4 +1707,4 @@ | ||
['Field', '*'], | ||
...computedFields.map((field) => { | ||
const returnField = this.AliasSelectField( | ||
...computedFields.map((field) => | ||
this.AliasSelectField( | ||
resource, | ||
@@ -1731,8 +1714,4 @@ sqlNameToODataName(field.fieldName), | ||
field.fieldName, | ||
); | ||
this.alreadyComputedFields[ | ||
this.modelName + resource.name + field.fieldName | ||
] = true; | ||
return returnField; | ||
}), | ||
), | ||
), | ||
]; | ||
@@ -1739,0 +1718,0 @@ computedFieldQuery.fromResource( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
508023
6674
228
2
4
2
32
+ Added@balena/odata-parser@3.1.2(transitive)
- Removed@balena/odata-parser@2.5.0(transitive)
Updated@balena/odata-parser@^3.0.0