@balena/abstract-sql-compiler
Advanced tools
Comparing version 7.0.3 to 7.0.4-update-deps-9613dfff39b35e6b33f7fd6eb042ab5c98d8414e
@@ -7,2 +7,18 @@ # Change Log | ||
## 7.0.4 - 2020-11-25 | ||
<details> | ||
<summary> Update sbvr-types and make use of `castType` [Pagan Gazzard] </summary> | ||
> ### sbvr-types-3.1.2 - 2020-11-25 | ||
> | ||
> * Add a `castType` property to type functions [Pagan Gazzard] | ||
> | ||
> ### sbvr-types-3.1.1 - 2020-11-25 | ||
> | ||
> * Update dependencies [Pagan Gazzard] | ||
> | ||
</details> | ||
## 7.0.3 - 2020-10-02 | ||
@@ -9,0 +25,0 @@ |
@@ -11,9 +11,12 @@ export declare const enum Engines { | ||
export declare type DateNode = ['Date', Date]; | ||
export declare type DurationNode = ['Duration', { | ||
negative?: boolean; | ||
day?: number; | ||
hour?: number; | ||
minute?: number; | ||
second?: number; | ||
}]; | ||
export declare type DurationNode = [ | ||
'Duration', | ||
{ | ||
negative?: boolean; | ||
day?: number; | ||
hour?: number; | ||
minute?: number; | ||
second?: number; | ||
} | ||
]; | ||
export declare type BooleanNode = ['Boolean', boolean]; | ||
@@ -23,6 +26,19 @@ export declare type EqualsNode = ['Equals', AbstractSqlType, AbstractSqlType]; | ||
export declare type GreaterThanNode = ['GreaterThan', AbstractSqlType, AbstractSqlType]; | ||
export declare type GreaterThanOrEqualNode = ['GreaterThanOrEqual', AbstractSqlType, AbstractSqlType]; | ||
export declare type GreaterThanOrEqualNode = [ | ||
'GreaterThanOrEqual', | ||
AbstractSqlType, | ||
AbstractSqlType | ||
]; | ||
export declare type LessThanNode = ['LessThan', AbstractSqlType, AbstractSqlType]; | ||
export declare type LessThanOrEqualNode = ['LessThanOrEqual', AbstractSqlType, AbstractSqlType]; | ||
export declare type InNode = ['In', FieldNode | ReferencedFieldNode, AbstractSqlType, ...AbstractSqlType[]]; | ||
export declare type LessThanOrEqualNode = [ | ||
'LessThanOrEqual', | ||
AbstractSqlType, | ||
AbstractSqlType | ||
]; | ||
export declare type InNode = [ | ||
'In', | ||
FieldNode | ReferencedFieldNode, | ||
AbstractSqlType, | ||
...AbstractSqlType[] | ||
]; | ||
export declare type ExistsNode = ['Exists', AbstractSqlType]; | ||
@@ -42,3 +58,8 @@ export declare type NotNode = ['Not', BooleanTypeNodes]; | ||
export declare type CastNode = ['Cast', AbstractSqlType, string]; | ||
export declare type CoalesceNode = ['Cast', UnknownTypeNodes, UnknownTypeNodes, ...UnknownTypeNodes[]]; | ||
export declare type CoalesceNode = [ | ||
'Cast', | ||
UnknownTypeNodes, | ||
UnknownTypeNodes, | ||
...UnknownTypeNodes[] | ||
]; | ||
export declare type UnknownTypeNodes = FieldNode | ReferencedFieldNode | BindNode | CastNode | CoalesceNode | UnknownNode; | ||
@@ -48,6 +69,17 @@ export declare type TextNode = ['Text', string]; | ||
export declare type LikeNode = ['Like', '*']; | ||
export declare type ReplaceNode = ['Replace', TextTypeNodes, TextTypeNodes, TextTypeNodes]; | ||
export declare type ReplaceNode = [ | ||
'Replace', | ||
TextTypeNodes, | ||
TextTypeNodes, | ||
TextTypeNodes | ||
]; | ||
export declare type TextTypeNodes = ConcatenateNode | LikeNode | ReplaceNode | UnknownTypeNodes; | ||
export declare type SelectQueryNode = ['SelectQuery', ...Array<SelectNode | FromNode | InnerJoinNode | LeftJoinNode | RightJoinNode | FullJoinNode | CrossJoinNode | WhereNode | GroupByNode | OrderByNode | LimitNode | OffsetNode>]; | ||
export declare type UnionQueryNode = ['UnionQuery', ...Array<UnionQueryNode | SelectQueryNode>]; | ||
export declare type SelectQueryNode = [ | ||
'SelectQuery', | ||
...Array<SelectNode | FromNode | InnerJoinNode | LeftJoinNode | RightJoinNode | FullJoinNode | CrossJoinNode | WhereNode | GroupByNode | OrderByNode | LimitNode | OffsetNode> | ||
]; | ||
export declare type UnionQueryNode = [ | ||
'UnionQuery', | ||
...(UnionQueryNode | SelectQueryNode)[] | ||
]; | ||
export interface FromTypeNode { | ||
@@ -69,8 +101,17 @@ SelectQueryNode: SelectQueryNode; | ||
export declare type WhereNode = ['Where', BooleanTypeNodes]; | ||
export declare type GroupByNode = ['GroupBy', Array<['ASC' | 'DESC', FieldNode | ReferencedFieldNode]>]; | ||
export declare type OrderByNode = ['OrderBy', ...Array<['ASC' | 'DESC', FieldNode | ReferencedFieldNode]>]; | ||
export declare type GroupByNode = [ | ||
'GroupBy', | ||
Array<['ASC' | 'DESC', FieldNode | ReferencedFieldNode]> | ||
]; | ||
export declare type OrderByNode = [ | ||
'OrderBy', | ||
...Array<['ASC' | 'DESC', FieldNode | ReferencedFieldNode]> | ||
]; | ||
export declare type LimitNode = ['Limit', NumberTypeNodes]; | ||
export declare type OffsetNode = ['Offset', NumberTypeNodes]; | ||
export declare type FieldsNode = ['Fields', string[]]; | ||
export declare type ValuesNode = ['Values', SelectQueryNode | UnionQueryNode | ValuesNodeTypes[]]; | ||
export declare type ValuesNode = [ | ||
'Values', | ||
SelectQueryNode | UnionQueryNode | ValuesNodeTypes[] | ||
]; | ||
export declare type ValuesNodeTypes = 'Default' | NullNode | BindNode | TextNode | NumberNode; | ||
@@ -77,0 +118,0 @@ export declare type AliasNode<T> = ['Alias', T, string]; |
@@ -1008,3 +1008,3 @@ "use strict"; | ||
}; | ||
exports.AbstractSQLOptimiser = (abstractSQL, $noBinds = false) => { | ||
const AbstractSQLOptimiser = (abstractSQL, $noBinds = false) => { | ||
noBinds = $noBinds; | ||
@@ -1042,2 +1042,3 @@ do { | ||
}; | ||
exports.AbstractSQLOptimiser = AbstractSQLOptimiser; | ||
//# sourceMappingURL=AbstractSQLOptimiser.js.map |
@@ -66,3 +66,3 @@ "use strict"; | ||
}; | ||
exports.isTextValue = (type) => { | ||
const isTextValue = (type) => { | ||
return (type === 'Value' || | ||
@@ -79,4 +79,5 @@ type === 'Text' || | ||
}; | ||
exports.isTextValue = isTextValue; | ||
const TextValue = MatchValue(exports.isTextValue); | ||
exports.isNumericValue = (type) => { | ||
const isNumericValue = (type) => { | ||
return (type === 'Number' || | ||
@@ -108,4 +109,5 @@ type === 'Real' || | ||
}; | ||
exports.isNumericValue = isNumericValue; | ||
const NumericValue = MatchValue(exports.isNumericValue); | ||
exports.isBooleanValue = (type) => { | ||
const isBooleanValue = (type) => { | ||
return (type === 'Boolean' || | ||
@@ -130,17 +132,22 @@ type === 'Not' || | ||
}; | ||
exports.isBooleanValue = isBooleanValue; | ||
const BooleanValue = MatchValue(exports.isBooleanValue); | ||
exports.isDateValue = (type) => { | ||
const isDateValue = (type) => { | ||
return (type === 'Date' || type === 'ToDate' || type === 'ToTime' || type === 'Now'); | ||
}; | ||
exports.isDateValue = isDateValue; | ||
const DateValue = MatchValue(exports.isDateValue); | ||
exports.isJSONValue = (type) => { | ||
const isJSONValue = (type) => { | ||
return type === 'AggregateJSON'; | ||
}; | ||
exports.isDurationValue = (type) => { | ||
exports.isJSONValue = isJSONValue; | ||
const isDurationValue = (type) => { | ||
return type === 'Duration'; | ||
}; | ||
exports.isDurationValue = isDurationValue; | ||
const DurationValue = MatchValue(exports.isDurationValue); | ||
exports.isFieldValue = (type) => { | ||
const isFieldValue = (type) => { | ||
return type === 'Field' || type === 'ReferencedField'; | ||
}; | ||
exports.isFieldValue = isFieldValue; | ||
const Field = (args, indent) => { | ||
@@ -189,6 +196,7 @@ const [type, ...rest] = args; | ||
}; | ||
exports.isAbstractSqlQuery = (x) => { | ||
const isAbstractSqlQuery = (x) => { | ||
return Array.isArray(x); | ||
}; | ||
exports.getAbstractSqlQuery = (args, index) => { | ||
exports.isAbstractSqlQuery = isAbstractSqlQuery; | ||
const getAbstractSqlQuery = (args, index) => { | ||
const abstractSqlQuery = args[index]; | ||
@@ -200,2 +208,3 @@ if (!exports.isAbstractSqlQuery(abstractSqlQuery)) { | ||
}; | ||
exports.getAbstractSqlQuery = getAbstractSqlQuery; | ||
const Comparison = (comparison) => { | ||
@@ -323,3 +332,3 @@ return (args, indent) => { | ||
}; | ||
exports.checkArgs = (matchName, args, num) => { | ||
const checkArgs = (matchName, args, num) => { | ||
if (args.length !== num) { | ||
@@ -329,3 +338,4 @@ throw new SyntaxError(`"${matchName}" requires ${num} arg(s)`); | ||
}; | ||
exports.checkMinArgs = (matchName, args, num) => { | ||
exports.checkArgs = checkArgs; | ||
const checkMinArgs = (matchName, args, num) => { | ||
if (args.length < num) { | ||
@@ -335,2 +345,3 @@ throw new SyntaxError(`"${matchName}" requires at least ${num} arg(s)`); | ||
}; | ||
exports.checkMinArgs = checkMinArgs; | ||
const Value = (arg, indent) => { | ||
@@ -614,3 +625,6 @@ switch (arg) { | ||
const dbType = sbvrTypes[typeName].types[engine]; | ||
if (typeof dbType === 'function' || dbType.toUpperCase() === 'SERIAL') { | ||
if (typeof dbType === 'function') { | ||
type = dbType.castType; | ||
} | ||
else if (dbType.toUpperCase() === 'SERIAL') { | ||
type = 'INTEGER'; | ||
@@ -617,0 +631,0 @@ } |
{ | ||
"name": "@balena/abstract-sql-compiler", | ||
"version": "7.0.3", | ||
"version": "7.0.4-update-deps-9613dfff39b35e6b33f7fd6eb042ab5c98d8414e", | ||
"description": "A translator for abstract sql into sql.", | ||
@@ -19,25 +19,25 @@ "main": "out/AbstractSQLCompiler.js", | ||
"dependencies": { | ||
"@balena/sbvr-types": "^3.1.0", | ||
"@types/lodash": "^4.14.157", | ||
"@types/node": "^10.17.27", | ||
"lodash": "^4.17.19" | ||
"@balena/sbvr-types": "^3.1.2", | ||
"@types/lodash": "^4.14.165", | ||
"@types/node": "^10.17.47", | ||
"lodash": "^4.17.20" | ||
}, | ||
"devDependencies": { | ||
"@balena/lf-to-abstract-sql": "^4.0.0", | ||
"@balena/lint": "^5.1.0", | ||
"@balena/odata-parser": "^2.0.0", | ||
"@balena/sbvr-parser": "^1.0.1", | ||
"@balena/lf-to-abstract-sql": "^4.1.1", | ||
"@balena/lint": "^5.3.0", | ||
"@balena/odata-parser": "^2.2.1", | ||
"@balena/sbvr-parser": "^1.1.1", | ||
"@resin/odata-to-abstract-sql": "^3.3.0", | ||
"@types/chai": "^4.2.11", | ||
"@types/chai": "^4.2.14", | ||
"@types/common-tags": "^1.8.0", | ||
"@types/mocha": "^5.2.7", | ||
"@types/mocha": "^8.0.4", | ||
"chai": "^4.2.0", | ||
"coffeescript": "^1.12.7", | ||
"common-tags": "^1.8.0", | ||
"husky": "^4.2.5", | ||
"lint-staged": "^10.2.11", | ||
"mocha": "^6.2.3", | ||
"husky": "^4.3.0", | ||
"lint-staged": "^10.5.2", | ||
"mocha": "^8.2.1", | ||
"require-npm4-to-publish": "^1.0.0", | ||
"ts-node": "^7.0.1", | ||
"typescript": "^3.9.6" | ||
"ts-node": "^9.0.0", | ||
"typescript": "^4.1.2" | ||
}, | ||
@@ -48,3 +48,16 @@ "husky": { | ||
} | ||
}, | ||
"mocha": { | ||
"reporter": "spec", | ||
"recursive": true, | ||
"require": [ | ||
"coffeescript/register", | ||
"ts-node/register/transpile-only" | ||
], | ||
"bail": true, | ||
"_": [ | ||
"test/**/*.coffee", | ||
"test/**/*.ts" | ||
] | ||
} | ||
} |
@@ -1,1 +0,1 @@ | ||
Convert the abstract SQL in dialect-specific SQL. | ||
Convert abstract SQL into dialect-specific SQL. |
@@ -133,3 +133,4 @@ export const enum Engines { | ||
'UnionQuery', | ||
...Array<UnionQueryNode | SelectQueryNode> | ||
// tslint:disable-next-line:array-type typescript fails on a circular reference when `Array<T>` form | ||
...(UnionQueryNode | SelectQueryNode)[] | ||
]; | ||
@@ -136,0 +137,0 @@ |
@@ -713,6 +713,7 @@ import * as _ from 'lodash'; | ||
const dbType = sbvrTypes[typeName].types[engine]; | ||
if (typeof dbType === 'function' || dbType.toUpperCase() === 'SERIAL') { | ||
if (typeof dbType === 'function') { | ||
type = dbType.castType; | ||
} else if (dbType.toUpperCase() === 'SERIAL') { | ||
// HACK: SERIAL type in postgres is really an INTEGER with automatic sequence, | ||
// so it's not actually possible to cast to SERIAL, instead you have to cast to INTEGER. | ||
// For mysql/websql it's a function since it needs to generate an INTEGER ... AUTOINCREMENT/AUTO_INCREMENT | ||
type = 'INTEGER'; | ||
@@ -719,0 +720,0 @@ } else { |
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
521108
7292
42
2
Updated@balena/sbvr-types@^3.1.2
Updated@types/lodash@^4.14.165
Updated@types/node@^10.17.47
Updatedlodash@^4.17.20