@balena/abstract-sql-compiler
Advanced tools
Comparing version 10.1.3-build-renovate-major-22-node-dea0ea26b3a09d058ed74813ccfe01afdef5e5fd-1 to 10.2.0-build-compile-any-node-as-operand-77c25f0bfe74e1d1b8c5c46dddb5c14658c7144c-1
@@ -27,2 +27,3 @@ export declare const enum Engines { | ||
export type EqualsNode = ['Equals', AnyTypeNodes, AnyTypeNodes]; | ||
export type EqualsAnyNode = ['EqualsAny', AnyTypeNodes, BindNode]; | ||
export type NotEqualsNode = ['NotEquals', AnyTypeNodes, AnyTypeNodes]; | ||
@@ -69,3 +70,3 @@ export type IsDistinctFromNode = ['IsDistinctFrom', AnyTypeNodes, AnyTypeNodes]; | ||
export type ContainsNode = ['Contains', TextTypeNodes, TextTypeNodes]; | ||
export type StrictBooleanTypeNodes = BooleanNode | EqualsNode | NotEqualsNode | IsDistinctFromNode | IsNotDistinctFromNode | GreaterThanNode | GreaterThanOrEqualNode | LessThanNode | LessThanOrEqualNode | BetweenNode | LikeNode | InNode | NotInNode | ExistsNode | NotExistsNode | NotNode | AndNode | OrNode | StartsWithNode | EndsWithNode | ContainsNode; | ||
export type StrictBooleanTypeNodes = BooleanNode | EqualsNode | EqualsAnyNode | NotEqualsNode | IsDistinctFromNode | IsNotDistinctFromNode | GreaterThanNode | GreaterThanOrEqualNode | LessThanNode | LessThanOrEqualNode | BetweenNode | LikeNode | InNode | NotInNode | ExistsNode | NotExistsNode | NotNode | AndNode | OrNode | StartsWithNode | EndsWithNode | ContainsNode; | ||
export type BooleanTypeNodes = StrictBooleanTypeNodes | UnknownTypeNodes; | ||
@@ -151,3 +152,3 @@ export type YearNode = ['Year', DateTypeNodes]; | ||
export type AnyNode = ['Any', AnyTypeNodes, string]; | ||
export type UnknownTypeNodes = SelectQueryNode | UnionQueryNode | NullNode | FieldNode | ReferencedFieldNode | BindNode | CastNode | CaseNode | CoalesceNode | AnyNode; | ||
export type UnknownTypeNodes = SelectQueryNode | UnionQueryNode | NullNode | FieldNode | ReferencedFieldNode | EqualsAnyNode | BindNode | CastNode | CaseNode | CoalesceNode | AnyNode; | ||
export type ToJSONNode = ['ToJSON', AnyTypeNodes]; | ||
@@ -154,0 +155,0 @@ export type AggregateJSONNode = [ |
@@ -120,2 +120,3 @@ "use strict"; | ||
case 'ReferencedField': | ||
case 'EqualsAny': | ||
case 'Bind': | ||
@@ -489,2 +490,3 @@ case 'Cast': | ||
}), Comparison('Equals')), | ||
EqualsAny: matchArgs('EqualsAny', AnyValue, AnyValue), | ||
NotEquals: tryMatches(Helper((args) => { | ||
@@ -491,0 +493,0 @@ checkArgs('NotEquals', args, 2); |
@@ -50,2 +50,3 @@ "use strict"; | ||
case 'ReferencedField': | ||
case 'EqualsAny': | ||
case 'Bind': | ||
@@ -198,2 +199,3 @@ case 'Cast': | ||
case 'IsNotDistinctFrom': | ||
case 'EqualsAny': | ||
case 'Exists': | ||
@@ -833,2 +835,6 @@ case 'NotExists': | ||
Equals: Comparison('Equals'), | ||
EqualsAny: (args, indent) => { | ||
(0, exports.checkArgs)('EqualsAny', args, 2); | ||
return `${AnyValue((0, exports.getAbstractSqlQuery)(args, 0), indent)} = ANY(${AnyValue((0, exports.getAbstractSqlQuery)(args, 1), indent)})`; | ||
}, | ||
GreaterThan: Comparison('GreaterThan'), | ||
@@ -835,0 +841,0 @@ GreaterThanOrEqual: Comparison('GreaterThanOrEqual'), |
{ | ||
"name": "@balena/abstract-sql-compiler", | ||
"version": "10.1.3-build-renovate-major-22-node-dea0ea26b3a09d058ed74813ccfe01afdef5e5fd-1", | ||
"version": "10.2.0-build-compile-any-node-as-operand-77c25f0bfe74e1d1b8c5c46dddb5c14658c7144c-1", | ||
"description": "A translator for abstract sql into sql.", | ||
@@ -35,3 +35,3 @@ "type": "commonjs", | ||
"@types/mocha": "^10.0.8", | ||
"@types/node": "^22.0.0", | ||
"@types/node": "^20.16.10", | ||
"chai": "^4.3.7", | ||
@@ -68,4 +68,4 @@ "common-tags": "^1.8.2", | ||
"versionist": { | ||
"publishedAt": "2025-01-06T23:49:14.779Z" | ||
"publishedAt": "2025-01-20T17:23:06.108Z" | ||
} | ||
} |
@@ -48,2 +48,3 @@ export const enum Engines { | ||
export type EqualsNode = ['Equals', AnyTypeNodes, AnyTypeNodes]; | ||
export type EqualsAnyNode = ['EqualsAny', AnyTypeNodes, BindNode]; | ||
export type NotEqualsNode = ['NotEquals', AnyTypeNodes, AnyTypeNodes]; | ||
@@ -93,2 +94,3 @@ export type IsDistinctFromNode = ['IsDistinctFrom', AnyTypeNodes, AnyTypeNodes]; | ||
| EqualsNode | ||
| EqualsAnyNode | ||
| NotEqualsNode | ||
@@ -251,2 +253,3 @@ | IsDistinctFromNode | ||
| ReferencedFieldNode | ||
| EqualsAnyNode | ||
| BindNode | ||
@@ -253,0 +256,0 @@ | CastNode |
@@ -109,2 +109,3 @@ import _ from 'lodash'; | ||
EscapeForLikeNode, | ||
EqualsAnyNode, | ||
} from './AbstractSQLCompiler'; | ||
@@ -223,2 +224,3 @@ import * as AbstractSQLRules2SQL from './AbstractSQLRules2SQL'; | ||
case 'ReferencedField': | ||
case 'EqualsAny': | ||
case 'Bind': | ||
@@ -744,2 +746,3 @@ case 'Cast': | ||
), | ||
EqualsAny: matchArgs<EqualsAnyNode>('EqualsAny', AnyValue, AnyValue), | ||
NotEquals: tryMatches<NotEqualsNode | ExistsNode>( | ||
@@ -746,0 +749,0 @@ Helper<OptimisationMatchFn<ExistsNode>>((args) => { |
@@ -85,2 +85,3 @@ import _ from 'lodash'; | ||
case 'ReferencedField': | ||
case 'EqualsAny': | ||
case 'Bind': | ||
@@ -250,2 +251,3 @@ case 'Cast': | ||
case 'IsNotDistinctFrom': | ||
case 'EqualsAny': | ||
case 'Exists': | ||
@@ -1005,2 +1007,6 @@ case 'NotExists': | ||
Equals: Comparison('Equals'), | ||
EqualsAny: (args, indent) => { | ||
checkArgs('EqualsAny', args, 2); | ||
return `${AnyValue(getAbstractSqlQuery(args, 0), indent)} = ANY(${AnyValue(getAbstractSqlQuery(args, 1), indent)})`; | ||
}, | ||
GreaterThan: Comparison('GreaterThan'), | ||
@@ -1007,0 +1013,0 @@ GreaterThanOrEqual: Comparison('GreaterThanOrEqual'), |
@@ -29,2 +29,15 @@ import { stripIndent } from 'common-tags'; | ||
describe('Equals Any', () => { | ||
test( | ||
['SelectQuery', ['Select', [['EqualsAny', ['Number', 5], ['Bind', 0]]]]], | ||
[['Bind', 0]], | ||
(result, sqlEquals) => { | ||
it('should produce a valid EqualsAny statement', () => { | ||
console.log('out', result, sqlEquals); | ||
sqlEquals(result.query, 'SELECT 5 = ANY($1)'); | ||
}); | ||
}, | ||
); | ||
}); | ||
describe('Comparison Operator Precedence', () => { | ||
@@ -31,0 +44,0 @@ // Different precedence |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1207821
18387