mm_sqlite 1.5.6 → 1.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/sql.js +15 -11
- package/package.json +1 -1
- package/test_db/test_core_methods.db +0 -0
package/lib/sql.js
CHANGED
|
@@ -1382,25 +1382,29 @@ Sql.prototype.tplQuery = function (param_dt, sql_dt) {
|
|
|
1382
1382
|
* @returns {string} 返回拼接的查询参数
|
|
1383
1383
|
*/
|
|
1384
1384
|
Sql.prototype.tplBody = function (param_dt, sql_dt) {
|
|
1385
|
-
|
|
1386
|
-
|
|
1385
|
+
if (!param_dt) {
|
|
1386
|
+
return '';
|
|
1387
|
+
}
|
|
1388
|
+
var parts = [];
|
|
1389
|
+
if (!sql_dt || Object.keys(sql_dt).length === 0) {
|
|
1387
1390
|
for (var key in param_dt) {
|
|
1388
|
-
|
|
1391
|
+
parts.push(this.escapeId(key) + ' = ' + this.escape(param_dt[key]));
|
|
1389
1392
|
}
|
|
1390
1393
|
} else {
|
|
1391
|
-
for (var
|
|
1392
|
-
var value = this.escape(param_dt[
|
|
1393
|
-
|
|
1394
|
-
|
|
1394
|
+
for (var k in param_dt) {
|
|
1395
|
+
var value = this.escape(param_dt[k]);
|
|
1396
|
+
// 不能再用 sql 作局部变量名,否则会遮蔽累加结果,SET 子句恒为空
|
|
1397
|
+
var tpl = sql_dt[k];
|
|
1398
|
+
if (tpl) {
|
|
1395
1399
|
// 使用直接替换方式,避免模板替换错误
|
|
1396
|
-
|
|
1397
|
-
|
|
1400
|
+
var replaced = tpl.replaceAll('{0}', value.trim("'"));
|
|
1401
|
+
parts.push(replaced.replace(/\+ -/g, '- ').replace(/- -/g, '+ '));
|
|
1398
1402
|
} else {
|
|
1399
|
-
|
|
1403
|
+
parts.push(this.escapeId(k) + ' = ' + value);
|
|
1400
1404
|
}
|
|
1401
1405
|
}
|
|
1402
1406
|
}
|
|
1403
|
-
return
|
|
1407
|
+
return parts.join(', ');
|
|
1404
1408
|
};
|
|
1405
1409
|
|
|
1406
1410
|
/**
|
package/package.json
CHANGED
|
Binary file
|