Major version update. Refactor sql generator function. Add core select directives like SUM, MIN, MAX, etc

This commit is contained in:
2026-04-18 07:24:01 +01:00
parent 0a3320ff83
commit f3f1c42699
23 changed files with 1275 additions and 662 deletions
+33
View File
@@ -0,0 +1,33 @@
export default function sqlGenGenJoinStr({ join, mtch, table_name }) {
if (mtch.__batch) {
let btch_mtch = ``;
btch_mtch += `(`;
for (let i = 0; i < mtch.__batch.matches.length; i++) {
const __mtch = mtch.__batch.matches[i];
btch_mtch += `${sqlGenGenJoinStr({ join, mtch: __mtch, table_name })}`;
if (i < mtch.__batch.matches.length - 1) {
btch_mtch += ` ${mtch.__batch.operator || "OR"} `;
}
}
btch_mtch += `)`;
return btch_mtch;
}
return `${typeof mtch.source == "object" ? mtch.source.tableName : table_name}.${typeof mtch.source == "object" ? mtch.source.fieldName : mtch.source}=${(() => {
if (mtch.targetLiteral) {
if (typeof mtch.targetLiteral == "number") {
return `${mtch.targetLiteral}`;
}
return `'${mtch.targetLiteral}'`;
}
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}`;
})()}`;
}