Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typesql-cli

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typesql-cli - npm Package Compare versions

Comparing version 0.4.3 to 0.4.4

7

code-generator.js

@@ -75,3 +75,4 @@ "use strict";

const queryParams = allParameters.length > 0 ? ', [' + allParameters.join(', ') + ']' : '';
const processedSql = replaceOrderByParam(tsDescriptor.sql);
const escapedBackstick = scapeBackStick(tsDescriptor.sql);
const processedSql = replaceOrderByParam(escapedBackstick);
const sqlSplit = processedSql.split('\n');

@@ -202,2 +203,6 @@ writer.write(`export async function ${camelCaseName}(${functionArguments}) : Promise<${functionReturnType}>`).block(() => {

exports.renameInvalidNames = renameInvalidNames;
function scapeBackStick(sql) {
const pattern = /`/g;
return sql.replace(pattern, "\\`");
}
function escapeInvalidTsField(columnName) {

@@ -204,0 +209,0 @@ const validPattern = /^[a-zA-Z0-9_$]+$/g;

@@ -585,2 +585,14 @@ "use strict";

}
if (runtimeFunctionCall.REPLACE_SYMBOL()) {
const exprList = runtimeFunctionCall.expr();
exprList.forEach(expr => {
const exprType = walkExpr(context, expr);
context.constraints.push({
expression: expr.text,
type1: exprType,
type2: freshVar('varchar', 'varchar')
});
});
return freshVar('varchar', 'varchar');
}
if (runtimeFunctionCall.YEAR_SYMBOL() || runtimeFunctionCall.MONTH_SYMBOL() || runtimeFunctionCall.DAY_SYMBOL()) {

@@ -817,3 +829,3 @@ const expr = (_a = runtimeFunctionCall.exprWithParentheses()) === null || _a === void 0 ? void 0 : _a.expr();

}
if (functionIdentifier === 'length') {
if (functionIdentifier === 'length' || functionIdentifier == 'char_length') {
const varcharParam = freshVar('varchar', 'varchar');

@@ -820,0 +832,0 @@ const params = {

@@ -143,2 +143,6 @@ "use strict";

}
if (simpleExpr instanceof ts_mysql_parser_1.SimpleExprListContext) {
const exprList = simpleExpr.exprList().expr();
return exprList.every(expr => inferNotNullExpr(expr, dbSchema, fromColumns));
}
if (simpleExpr instanceof ts_mysql_parser_1.SimpleExprSubQueryContext) {

@@ -170,2 +174,6 @@ return false;

}
if (functionCall.REPLACE_SYMBOL()) {
const exprList = functionCall.expr();
return exprList.every(expr => inferNotNullExpr(expr, dbSchema, fromColumns));
}
const trimFunction = functionCall.trimFunction();

@@ -172,0 +180,0 @@ if (trimFunction) {

@@ -232,5 +232,13 @@ "use strict";

};
return result;
const withoutStick = {
name: removeBackStick(result.name),
prefix: result.prefix
};
return withoutStick;
}
exports.splitName = splitName;
function removeBackStick(name) {
const withoutBackStick = name.startsWith("`") && name.endsWith("`") ? name.slice(1, -1) : name;
return withoutBackStick;
}
const functionAlias = [

@@ -237,0 +245,0 @@ {

2

package.json
{
"name": "typesql-cli",
"version": "0.4.3",
"version": "0.4.4",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -20,3 +20,3 @@ "use strict";

});
writer.write(`FROM ${tableName}`);
writer.write(`FROM ${escapeTableName(tableName)}`);
return writer.toString();

@@ -28,3 +28,3 @@ }

const writer = new code_block_writer_1.default();
writer.writeLine(`INSERT INTO ${tableName}`);
writer.writeLine(`INSERT INTO ${escapeTableName(tableName)}`);
writer.writeLine("(");

@@ -55,3 +55,3 @@ columns.forEach((col, columnIndex) => {

const writer = new code_block_writer_1.default();
writer.writeLine(`UPDATE ${tableName}`);
writer.writeLine(`UPDATE ${escapeTableName(tableName)}`);
writer.writeLine("SET");

@@ -76,3 +76,3 @@ columns.forEach((col, columnIndex) => {

const writer = new code_block_writer_1.default();
writer.writeLine(`DELETE FROM ${tableName}`);
writer.writeLine(`DELETE FROM ${escapeTableName(tableName)}`);
writer.write('WHERE ');

@@ -85,2 +85,10 @@ if (keys.length > 0) {

exports.generateDeleteStatment = generateDeleteStatment;
//Permitted characters in unquoted identifiers: ASCII: [0-9,a-z,A-Z$_]
function escapeTableName(tableName) {
const validPattern = /^[a-zA-Z0-9_$]+$/g;
if (!validPattern.test(tableName)) {
return `\`${tableName}\``;
}
return tableName;
}
//# sourceMappingURL=sql-generator.js.map

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

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