Major version update. Major bugfixes. Security vulnerabilites fixed
This commit is contained in:
+17
-23
@@ -1,3 +1,4 @@
|
||||
import { sqlIdent, sqlOperator, sqlRawEquality } from "./sql-safe";
|
||||
export default function sqlGenGenJoinStr({ join, mtch, table_name }) {
|
||||
let values = [];
|
||||
if (mtch.__batch) {
|
||||
@@ -13,7 +14,7 @@ export default function sqlGenGenJoinStr({ join, mtch, table_name }) {
|
||||
btch_mtch += str;
|
||||
values.push(...batch_values);
|
||||
if (i < mtch.__batch.matches.length - 1) {
|
||||
btch_mtch += ` ${mtch.__batch.operator || "OR"} `;
|
||||
btch_mtch += ` ${sqlOperator(mtch.__batch.operator, "OR")} `;
|
||||
}
|
||||
}
|
||||
btch_mtch += `)`;
|
||||
@@ -22,28 +23,8 @@ export default function sqlGenGenJoinStr({ join, mtch, table_name }) {
|
||||
values,
|
||||
};
|
||||
}
|
||||
const equality = mtch.raw_equality || "=";
|
||||
const lhs = `${typeof mtch.source == "object" ? mtch.source.tableName : table_name}.${typeof mtch.source == "object" ? mtch.source.fieldName : mtch.source}`;
|
||||
const rhs = `${(() => {
|
||||
if (mtch.targetLiteral) {
|
||||
values.push(mtch.targetLiteral);
|
||||
// if (typeof mtch.targetLiteral == "number") {
|
||||
// return `${mtch.targetLiteral}`;
|
||||
// }
|
||||
// return `'${mtch.targetLiteral}'`;
|
||||
return `?`;
|
||||
}
|
||||
if (join.alias) {
|
||||
return `${typeof mtch.target == "object"
|
||||
? mtch.target.tableName
|
||||
: join.alias}.${typeof mtch.target == "object"
|
||||
? mtch.target.fieldName
|
||||
: mtch.target}`;
|
||||
}
|
||||
return `${typeof mtch.target == "object"
|
||||
? mtch.target.tableName
|
||||
: join.tableName}.${typeof mtch.target == "object" ? mtch.target.fieldName : mtch.target}`;
|
||||
})()}`;
|
||||
const equality = mtch.raw_equality ? sqlRawEquality(mtch.raw_equality) : "=";
|
||||
const lhs = `${sqlIdent(typeof mtch.source == "object" ? mtch.source.tableName : table_name, "table name")}.${sqlIdent(typeof mtch.source == "object" ? mtch.source.fieldName : mtch.source, "field name")}`;
|
||||
if (mtch.between) {
|
||||
values.push(mtch.between.min, mtch.between.max);
|
||||
return {
|
||||
@@ -58,6 +39,19 @@ export default function sqlGenGenJoinStr({ join, mtch, table_name }) {
|
||||
values,
|
||||
};
|
||||
}
|
||||
const rhs = (() => {
|
||||
if (mtch.targetLiteral !== undefined && mtch.targetLiteral !== null) {
|
||||
values.push(mtch.targetLiteral);
|
||||
return `?`;
|
||||
}
|
||||
const targetTable = typeof mtch.target == "object"
|
||||
? mtch.target.tableName
|
||||
: join.alias || join.tableName;
|
||||
const targetField = typeof mtch.target == "object"
|
||||
? mtch.target.fieldName
|
||||
: mtch.target;
|
||||
return `${sqlIdent(targetTable, "table name")}.${sqlIdent(targetField, "field name")}`;
|
||||
})();
|
||||
return {
|
||||
str: `${lhs} ${equality} ${rhs}`,
|
||||
values,
|
||||
|
||||
Reference in New Issue
Block a user