@rdyl/node-mysql 0.3.3 → 0.3.4

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/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ## 0.3.2 (2025-12-31)
1
+ ## 0.3.4 (2025-12-31)
2
2
 
3
3
 
4
4
 
package/dist/helper.js CHANGED
@@ -99,17 +99,17 @@ var BaseHelper = /** @class */ (function () {
99
99
  var item = _this.related[n];
100
100
  // @ts-ignore
101
101
  var _a = (global.$MysqlTable[item.table] || {}).fields, fields = _a === void 0 ? [] : _a;
102
- var fieldsSql = "\n".concat(fields.map(function (e) { return "".concat(e, ", ").concat(item.table, ".").concat(e); }).join(",\n"), "\n");
102
+ var fieldsSql = "\n".concat(fields.map(function (e) { return "'".concat(e, "', ").concat(item.table, ".").concat(e); }).join(",\n"), "\n");
103
103
  if (item.isArray) {
104
104
  sqlList.push("COALESCE(\n (\n SELECT JSON_ARRAYAGG(\n JSON_OBJECT(".concat(fieldsSql, ")\n )\n FROM ").concat(item.relatedTable, "\n JOIN ").concat(item.table, " ON ").concat(item.table, ".id = ").concat(item.relatedTable, ".").concat(item.table, "_id\n WHERE ").concat(item.relatedTable, ".").concat(_this.table, "_id = ").concat(_this.table, ".id\n ),\n JSON_ARRAY()\n) AS ").concat(item.table));
105
105
  }
106
106
  else {
107
- sqlList.push("COALESCE(\n (\n SELECT JSON_OBJECT(".concat(fieldsSql, ")\n FROM ").concat(item.relatedTable, "\n JOIN ").concat(item.table, " ON ").concat(item.table, ".id = ").concat(item.relatedTable, ".").concat(item.table, "_id\n WHERE ").concat(item.relatedTable, ".").concat(_this.table, "_id = ").concat(_this.table, ".id\n LIMIT 1\n ),\n JSON_OBJECT()\n) AS ").concat(item.table, ",\n"));
107
+ sqlList.push("COALESCE(\n (\n SELECT JSON_OBJECT(".concat(fieldsSql, ")\n FROM ").concat(item.relatedTable, "\n JOIN ").concat(item.table, " ON ").concat(item.table, ".id = ").concat(item.relatedTable, ".").concat(item.table, "_id\n WHERE ").concat(item.relatedTable, ".").concat(_this.table, "_id = ").concat(_this.table, ".id\n LIMIT 1\n ),\n JSON_OBJECT()\n) AS ").concat(item.table, "\n"));
108
108
  }
109
109
  });
110
110
  }
111
111
  return {
112
- sql: (sqlList.length > 0 ? "\n" : "") + sqlList.join("\n"),
112
+ sql: (sqlList.length > 0 ? ",\n" : " ") + sqlList.join("\n"),
113
113
  };
114
114
  },
115
115
  enumerable: false,
@@ -195,8 +195,8 @@ var MysqlSelector = /** @class */ (function (_super) {
195
195
  }
196
196
  Object.defineProperty(MysqlSelector.prototype, "sql", {
197
197
  get: function () {
198
- var _a = this, selectStat = _a.selectStat, optionStat = _a.optionStat, relatedStat = _a.relatedStat;
199
- var target = "SELECT * ".concat(relatedStat.sql, "FROM ").concat(this.table);
198
+ var _a = this, selectStat = _a.selectStat, optionStat = _a.optionStat, relatedStat = _a.relatedStat, table = _a.table;
199
+ var target = "SELECT ".concat(table, ".*").concat(relatedStat.sql, " FROM ").concat(this.table);
200
200
  if (selectStat.sql) {
201
201
  target += selectStat.sql;
202
202
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdyl/node-mysql",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",