typesql-cli
Advanced tools
Comparing version 0.8.18 to 0.8.19
@@ -205,3 +205,3 @@ "use strict"; | ||
if (!found) { | ||
throw Error('column not found:' + JSON.stringify(fieldName)); | ||
throw Error('no such column: ' + formatField(fieldName)); | ||
} | ||
@@ -211,2 +211,5 @@ return found; | ||
exports.findColumn = findColumn; | ||
function formatField(fieldName) { | ||
return fieldName.prefix == '' ? fieldName.name : `${fieldName.prefix}.${fieldName.name}`; | ||
} | ||
function findColumnOrNull(fieldName, columns) { | ||
@@ -213,0 +216,0 @@ const found = columns.find(col => col.columnName.toLowerCase() == fieldName.name.toLowerCase() && |
{ | ||
"name": "typesql-cli", | ||
"version": "0.8.18", | ||
"version": "0.8.19", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -39,3 +39,7 @@ "use strict"; | ||
}; | ||
const queryResult = (0, traverse_1.traverse_Sql_stmtContext)(sql_stmtContext, traverseContext); | ||
const queryResultResult = (0, traverse_1.tryTraverse_Sql_stmtContext)(sql_stmtContext, traverseContext); | ||
if ((0, Either_1.isLeft)(queryResultResult)) { | ||
return queryResultResult; | ||
} | ||
const queryResult = queryResultResult.right; | ||
traverseContext.parameters.sort((param1, param2) => param1.paramIndex - param2.paramIndex); | ||
@@ -196,4 +200,7 @@ const groupedByName = (0, util_1.indexGroupBy)(namedParameters, p => p); | ||
} | ||
throw Error('query not supported: ' + sql_stmtContext.getText()); | ||
return (0, Either_1.left)({ | ||
name: 'parse error', | ||
description: 'query not supported: ' + sql_stmtContext.getText() | ||
}); | ||
} | ||
//# sourceMappingURL=parser.js.map |
import { Select_stmtContext, Sql_stmtContext, ExprContext } from "@wsporto/ts-mysql-parser/dist/sqlite"; | ||
import { ColumnDef, TraverseContext } from "../mysql-query-analyzer/types"; | ||
import { TraverseResult2 } from "../mysql-query-analyzer/traverse"; | ||
export declare function traverse_Sql_stmtContext(sql_stmt: Sql_stmtContext, traverseContext: TraverseContext): TraverseResult2; | ||
import { Either } from 'fp-ts/lib/Either'; | ||
import { TypeSqlError } from '../types'; | ||
export declare function tryTraverse_Sql_stmtContext(sql_stmt: Sql_stmtContext, traverseContext: TraverseContext): Either<TypeSqlError, TraverseResult2>; | ||
export declare function isNotNull(columnName: string, where: ExprContext | null): boolean; | ||
export declare function isMultipleRowResult(select_stmt: Select_stmtContext, fromColumns: ColumnDef[]): boolean; | ||
//# sourceMappingURL=traverse.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isMultipleRowResult = exports.isNotNull = exports.traverse_Sql_stmtContext = void 0; | ||
exports.isMultipleRowResult = exports.isNotNull = exports.tryTraverse_Sql_stmtContext = void 0; | ||
const sqlite_1 = require("@wsporto/ts-mysql-parser/dist/sqlite"); | ||
@@ -8,2 +8,3 @@ const select_columns_1 = require("../mysql-query-analyzer/select-columns"); | ||
const traverse_1 = require("../mysql-query-analyzer/traverse"); | ||
const Either_1 = require("fp-ts/lib/Either"); | ||
function traverse_Sql_stmtContext(sql_stmt, traverseContext) { | ||
@@ -32,3 +33,16 @@ const select_stmt = sql_stmt.select_stmt(); | ||
} | ||
exports.traverse_Sql_stmtContext = traverse_Sql_stmtContext; | ||
function tryTraverse_Sql_stmtContext(sql_stmt, traverseContext) { | ||
try { | ||
const traverseResult = traverse_Sql_stmtContext(sql_stmt, traverseContext); | ||
return (0, Either_1.right)(traverseResult); | ||
} | ||
catch (err) { | ||
const error = err; | ||
return (0, Either_1.left)({ | ||
name: 'parser error', | ||
description: error.message | ||
}); | ||
} | ||
} | ||
exports.tryTraverse_Sql_stmtContext = tryTraverse_Sql_stmtContext; | ||
function traverse_select_stmt(select_stmt, traverseContext, subQuery = false) { | ||
@@ -783,2 +797,11 @@ const common_table_stmt = select_stmt.common_table_stmt(); | ||
} | ||
if (inExpr instanceof sqlite_1.Select_stmtContext) { | ||
const select_stmt_type = traverse_select_stmt(inExpr, traverseContext, true); | ||
const selectType = select_stmt_type.columns[0]; | ||
traverseContext.constraints.push({ | ||
expression: expr.getText(), | ||
type1: typeLeft.type, | ||
type2: Object.assign(Object.assign({}, selectType.type), { list: true }) | ||
}); | ||
} | ||
}); | ||
@@ -927,4 +950,4 @@ const type = (0, collect_constraints_1.freshVar)(expr.getText(), '?'); | ||
if (expr.ASSIGN() | ||
|| expr.GT() | ||
|| expr.LT() | ||
|| expr.GT() || expr.GT_EQ() | ||
|| expr.LT() || expr.LT_EQ() | ||
|| (expr.IS_() && expr.expr_list().length == 2 && expr.expr(1).getText() == 'notnull')) { | ||
@@ -931,0 +954,0 @@ const exprLeft = expr.expr(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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
711964
8765