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

@balena/odata-to-abstract-sql

Package Overview
Dependencies
Maintainers
4
Versions
234
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@balena/odata-to-abstract-sql - npm Package Compare versions

Comparing version 5.2.0-named-keys-1aa78f8bcec04b0434bf381e3beb7e4558ce2e3a to 5.2.0-named-keys-2ad74da6c0cbff45907e54fc25bccb0d954c166f

2

CHANGELOG.md

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

## 5.2.0 - 2020-07-17
## 5.2.0 - 2020-07-20

@@ -10,0 +10,0 @@ * Add support for specifying named keys [Pagan Gazzard]

@@ -411,9 +411,10 @@ "use strict";

PathKey(method, path, resource, bodyKeys) {
if (path.key != null) {
const { key } = path;
if (key != null) {
if (method === 'PUT' || method === 'PUT-INSERT' || method === 'POST') {
if (isBindReference(path.key)) {
addBodyKey(resource.resourceName, resource.idField, path.key, bodyKeys, this.extraBodyVars);
if (isBindReference(key)) {
addBodyKey(resource.resourceName, resource.idField, key, bodyKeys, this.extraBodyVars);
}
else {
for (const [fieldName, bind] of Object.entries(path.key)) {
for (const [fieldName, bind] of Object.entries(key)) {
addBodyKey(resource.resourceName, fieldName, bind, bodyKeys, this.extraBodyVars);

@@ -423,4 +424,4 @@ }

}
if (isBindReference(path.key)) {
const key = this.Bind(path.key);
if (isBindReference(key)) {
const bind = this.Bind(key);
const referencedField = [

@@ -431,13 +432,27 @@ 'ReferencedField',

];
return [comparison.eq, referencedField, key];
return [comparison.eq, referencedField, bind];
}
const namedKeys = Object.entries(path.key).map(([fieldName, bind]) => {
const key = this.Bind(bind);
const referencedField = [
'ReferencedField',
resource.tableAlias,
fieldName,
];
return [comparison.eq, referencedField, key];
const fieldNames = Object.keys(key);
const sqlFieldNames = fieldNames.map(exports.odataNameToSqlName).sort();
const fields = sqlFieldNames.map((fieldName) => {
const resourceField = resource.fields.find((f) => f.fieldName === fieldName);
if (resourceField == null) {
throw new SyntaxError('Specified non-existent field for path key');
}
return resourceField;
});
if (!(fields.length === 1 &&
(fields[0].index === 'UNIQUE' || fields[0].index === 'PRIMARY KEY')) &&
!resource.indexes.some((index) => {
return ((index.type === 'UNIQUE' || index.type === 'PRIMARY KEY') &&
sqlFieldNames.length === index.fields.length &&
_.isEqual(index.fields.slice().sort(), sqlFieldNames));
})) {
throw new SyntaxError('Specified fields for path key that are not directly unique');
}
const namedKeys = fieldNames.map((fieldName) => {
const bind = this.Bind(key[fieldName]);
const referencedField = this.ReferencedField(resource, fieldName);
return [comparison.eq, referencedField, bind];
});
if (namedKeys.length === 1) {

@@ -444,0 +459,0 @@ return namedKeys[0];

{
"name": "@balena/odata-to-abstract-sql",
"version": "5.2.0-named-keys-1aa78f8bcec04b0434bf381e3beb7e4558ce2e3a",
"version": "5.2.0-named-keys-2ad74da6c0cbff45907e54fc25bccb0d954c166f",
"description": "A consumer of the OData parser, written in OMeta",

@@ -5,0 +5,0 @@ "main": "out/odata-to-abstract-sql.js",

@@ -600,9 +600,10 @@ import * as _ from 'lodash';

): BooleanTypeNodes | void {
if (path.key != null) {
const { key } = path;
if (key != null) {
if (method === 'PUT' || method === 'PUT-INSERT' || method === 'POST') {
if (isBindReference(path.key)) {
if (isBindReference(key)) {
addBodyKey(
resource.resourceName,
resource.idField,
path.key,
key,
bodyKeys,

@@ -612,3 +613,3 @@ this.extraBodyVars,

} else {
for (const [fieldName, bind] of Object.entries(path.key)) {
for (const [fieldName, bind] of Object.entries(key)) {
addBodyKey(

@@ -624,4 +625,4 @@ resource.resourceName,

}
if (isBindReference(path.key)) {
const key = this.Bind(path.key);
if (isBindReference(key)) {
const bind = this.Bind(key);
const referencedField: ReferencedFieldNode = [

@@ -632,13 +633,42 @@ 'ReferencedField',

];
return [comparison.eq, referencedField, key];
return [comparison.eq, referencedField, bind];
}
const namedKeys = Object.entries(path.key).map(
([fieldName, bind]): BooleanTypeNodes => {
const key = this.Bind(bind);
const referencedField: ReferencedFieldNode = [
'ReferencedField',
resource.tableAlias!,
const fieldNames = Object.keys(key);
const sqlFieldNames = fieldNames.map(odataNameToSqlName).sort();
const fields = sqlFieldNames.map((fieldName) => {
const resourceField = resource.fields.find(
(f) => f.fieldName === fieldName,
);
if (resourceField == null) {
throw new SyntaxError('Specified non-existent field for path key');
}
return resourceField;
});
if (
!(
fields.length === 1 &&
(fields[0].index === 'UNIQUE' || fields[0].index === 'PRIMARY KEY')
) &&
!resource.indexes.some((index) => {
return (
(index.type === 'UNIQUE' || index.type === 'PRIMARY KEY') &&
sqlFieldNames.length === index.fields.length &&
_.isEqual(index.fields.slice().sort(), sqlFieldNames)
);
})
) {
throw new SyntaxError(
'Specified fields for path key that are not directly unique',
);
}
const namedKeys = fieldNames.map(
(fieldName): BooleanTypeNodes => {
const bind = this.Bind(key[fieldName]);
const referencedField: ReferencedFieldNode = this.ReferencedField(
resource,
fieldName,
];
return [comparison.eq, referencedField, key];
);
return [comparison.eq, referencedField, bind];
},

@@ -645,0 +675,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc