@balena/odata-to-abstract-sql
Advanced tools
Comparing version 7.1.0-build-parse-in-as-eq-any-bf91c58d8f32d7f407e1a82ad667bd318acc2195-1 to 7.1.0-build-parse-in-as-eq-any-ede1d0fa541f53ca2ae55cd443490ac2cd0e1c11-1
import memoize from 'memoizee'; | ||
import type { AbstractSqlQuery, AbstractSqlModel, AbstractSqlTable, DurationNode, SelectNode, FromNode, WhereNode, OrderByNode, LimitNode, OffsetNode, NumberTypeNodes, FieldsNode, ValuesNode, ReferencedFieldNode, AliasNode, BooleanTypeNodes, SelectQueryNode, BindNode, TableNode, Definition as ModernDefinition, ResourceNode, UnionQueryNode, FromTypeNodes, FieldNode, CountNode, AddNode, InsertQueryNode, DeleteQueryNode, UpdateQueryNode, DurationTypeNodes, SubtractNode, MultiplyNode, DivideNode, NullNode, TextTypeNodes, AnyTypeNodes, StrictDateTypeNodes, AnyNode } from '@balena/abstract-sql-compiler'; | ||
import type { AbstractSqlQuery, AbstractSqlModel, AbstractSqlTable, DurationNode, SelectNode, FromNode, WhereNode, OrderByNode, LimitNode, OffsetNode, NumberTypeNodes, FieldsNode, ValuesNode, ReferencedFieldNode, AliasNode, BooleanTypeNodes, SelectQueryNode, BindNode, TableNode, Definition as ModernDefinition, ResourceNode, UnionQueryNode, FromTypeNodes, FieldNode, CountNode, AddNode, InsertQueryNode, DeleteQueryNode, UpdateQueryNode, DurationTypeNodes, SubtractNode, MultiplyNode, DivideNode, NullNode, TextTypeNodes, AnyTypeNodes, StrictDateTypeNodes, EqualsAnyNode } from '@balena/abstract-sql-compiler'; | ||
import type { ODataBinds, ODataQuery, SupportedMethod, ExpandPropertyPath, ResourceOptions, OrderByOption, OrderByPropertyPath, FilterOption, BindReference } from '@balena/odata-parser'; | ||
@@ -95,3 +95,3 @@ export type { ODataBinds, ODataQuery, SupportedMethod }; | ||
Operand(match: any): BindNode | NullNode | BooleanTypeNodes | NumberTypeNodes | TextTypeNodes | StrictDateTypeNodes | DurationTypeNodes; | ||
Any(match: any): AnyNode | undefined; | ||
EqualsAny(match: any): EqualsAnyNode | undefined; | ||
Math(match: any): AddNode | SubtractNode | MultiplyNode | DivideNode | undefined; | ||
@@ -98,0 +98,0 @@ Lambda(resourceName: string, lambda: any): BooleanTypeNodes; |
@@ -22,2 +22,3 @@ "use strict"; | ||
eq: 'IsNotDistinctFrom', | ||
eqany: 'EqualsAny', | ||
ne: 'IsDistinctFrom', | ||
@@ -761,2 +762,3 @@ gt: 'GreaterThan', | ||
case 'eq': | ||
case 'eqany': | ||
case 'ne': | ||
@@ -782,6 +784,9 @@ case 'gt': | ||
case 'in': { | ||
if (!Object.hasOwn(rest[1], 'bind')) { | ||
throw new SyntaxError('IN must have a bind as the second argument'); | ||
} | ||
return [ | ||
'In', | ||
'EqualsAny', | ||
this.Operand(rest[0]), | ||
...rest[1].map((v) => this.Operand(v)), | ||
this.Operand(rest[1]), | ||
]; | ||
@@ -849,3 +854,3 @@ } | ||
this.Math, | ||
this.Any, | ||
this.EqualsAny, | ||
]) { | ||
@@ -859,7 +864,14 @@ const result = matcher.call(this, match, true); | ||
} | ||
Any(match) { | ||
const [type, rest] = match; | ||
if (type === 'any') { | ||
return ['Any', this.Operand(rest), '']; | ||
EqualsAny(match) { | ||
if (match[0] !== 'eqany') { | ||
return; | ||
} | ||
if (match[1][0] !== 'Bind') { | ||
throw new SyntaxError('Equals any must have a bind as the second argument'); | ||
} | ||
return [ | ||
'EqualsAny', | ||
this.Operand(match[0]), | ||
this.Operand(match[1]), | ||
]; | ||
} | ||
@@ -866,0 +878,0 @@ Math(match) { |
{ | ||
"name": "@balena/odata-to-abstract-sql", | ||
"version": "7.1.0-build-parse-in-as-eq-any-bf91c58d8f32d7f407e1a82ad667bd318acc2195-1", | ||
"version": "7.1.0-build-parse-in-as-eq-any-ede1d0fa541f53ca2ae55cd443490ac2cd0e1c11-1", | ||
"description": "A consumer of the OData parser, written in OMeta", | ||
@@ -19,4 +19,4 @@ "type": "commonjs", | ||
"dependencies": { | ||
"@balena/abstract-sql-compiler": "^10.0.1", | ||
"@balena/odata-parser": "4.0.0-build-compile-in-as-eq-any-26f07fff3659a9a21fca2a20a392ee956861a0bc-1", | ||
"@balena/abstract-sql-compiler": "10.2.0-build-compile-any-node-as-operand-77c25f0bfe74e1d1b8c5c46dddb5c14658c7144c-1", | ||
"@balena/odata-parser": "4.0.0-build-compile-in-as-eq-any-920795378e7f3a4c819d178be879570f48ebc3cb-1", | ||
"@types/lodash": "^4.17.10", | ||
@@ -58,4 +58,4 @@ "@types/memoizee": "^0.4.11", | ||
"versionist": { | ||
"publishedAt": "2025-01-20T13:41:17.155Z" | ||
"publishedAt": "2025-01-20T17:34:46.274Z" | ||
} | ||
} |
@@ -32,3 +32,2 @@ import _ from 'lodash'; | ||
SelectQueryNode, | ||
InNode, | ||
BindNode, | ||
@@ -76,3 +75,3 @@ CastNode, | ||
FromTypeNode, | ||
AnyNode, | ||
EqualsAnyNode, | ||
} from '@balena/abstract-sql-compiler'; | ||
@@ -142,2 +141,3 @@ import type { | ||
eq: 'IsNotDistinctFrom', | ||
eqany: 'EqualsAny', | ||
ne: 'IsDistinctFrom', | ||
@@ -1149,2 +1149,3 @@ gt: 'GreaterThan', | ||
case 'eq': | ||
case 'eqany': | ||
case 'ne': | ||
@@ -1163,3 +1164,4 @@ case 'gt': | ||
| LessThanNode | ||
| LessThanOrEqualNode; | ||
| LessThanOrEqualNode | ||
| EqualsAnyNode; | ||
} | ||
@@ -1177,7 +1179,12 @@ case 'and': | ||
case 'in': { | ||
if (!Object.hasOwn(rest[1], 'bind')) { | ||
throw new SyntaxError( | ||
'IN must have a bind as the second argument', | ||
); | ||
} | ||
return [ | ||
'In', | ||
'EqualsAny', | ||
this.Operand(rest[0]), | ||
...rest[1].map((v: any) => this.Operand(v)), | ||
] as InNode; | ||
this.Operand(rest[1]) as BindNode, | ||
] as EqualsAnyNode; | ||
} | ||
@@ -1266,3 +1273,3 @@ case 'call': { | ||
this.Math, | ||
this.Any, | ||
this.EqualsAny, | ||
]) { | ||
@@ -1287,7 +1294,17 @@ const result = matcher.call< | ||
} | ||
Any(match: any): AnyNode | undefined { | ||
const [type, rest] = match; | ||
if (type === 'any') { | ||
return ['Any', this.Operand(rest), '']; | ||
EqualsAny(match: any): EqualsAnyNode | undefined { | ||
if (match[0] !== 'eqany') { | ||
return; | ||
} | ||
if (match[1][0] !== 'Bind') { | ||
throw new SyntaxError( | ||
'Equals any must have a bind as the second argument', | ||
); | ||
} | ||
return [ | ||
'EqualsAny', | ||
this.Operand(match[0]), | ||
this.Operand(match[1]) as BindNode, | ||
]; | ||
} | ||
@@ -1294,0 +1311,0 @@ Math( |
@@ -53,4 +53,3 @@ import { expect } from 'chai'; | ||
in: 'In', | ||
// eslint-disable-next-line id-denylist | ||
any: 'Any', | ||
eqany: 'EqualsAny', | ||
}; | ||
@@ -79,7 +78,3 @@ | ||
odata: operandToOData(lhs) + ' ' + op + ' ' + operandToOData(rhs), | ||
abstractsql: [ | ||
sqlOps['eq'], | ||
operandToAbstractSQL(lhs), | ||
[sqlOps['any'], ['Bind', 0], ''], | ||
], | ||
abstractsql: [sqlOps['eqany'], operandToAbstractSQL(lhs), ['Bind', 0]], | ||
}; | ||
@@ -86,0 +81,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
798091
7154
+ Added@balena/abstract-sql-compiler@10.2.0-build-compile-any-node-as-operand-77c25f0bfe74e1d1b8c5c46dddb5c14658c7144c-1(transitive)
+ Added@balena/odata-parser@4.0.0-build-compile-in-as-eq-any-920795378e7f3a4c819d178be879570f48ebc3cb-1(transitive)
- Removed@balena/abstract-sql-compiler@10.2.2(transitive)
- Removed@balena/odata-parser@4.0.0-build-compile-in-as-eq-any-26f07fff3659a9a21fca2a20a392ee956861a0bc-1(transitive)
Updated@balena/odata-parser@4.0.0-build-compile-in-as-eq-any-920795378e7f3a4c819d178be879570f48ebc3cb-1