oak-db 1.0.5 → 1.0.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.
@@ -56,10 +56,12 @@ var MysqlStore = /** @class */ (function (_super) {
56
56
  }
57
57
  else {
58
58
  (0, assert_1.default)(typeof rel === 'string');
59
- if (!r[attrHead]) {
60
- r[attrHead] = {};
59
+ if (typeof r["".concat(attrHead, "Id")] === 'string') {
60
+ if (!r[attrHead]) {
61
+ r[attrHead] = {};
62
+ }
63
+ resolveAttribute(rel, r[attrHead], attrTail, value);
61
64
  }
62
- resolveAttribute(rel, r[attrHead], attrTail, value);
63
65
  }
64
66
  }
65
67
  else if (attributes[attr]) {
@@ -5,7 +5,6 @@ var tslib_1 = require("tslib");
5
5
  var assert_1 = tslib_1.__importDefault(require("assert"));
6
6
  var util_1 = require("util");
7
7
  var lodash_1 = require("lodash");
8
- var luxon_1 = require("luxon");
9
8
  var sqlTranslator_1 = require("../sqlTranslator");
10
9
  var GeoTypes = [
11
10
  {
@@ -471,14 +470,14 @@ var MySqlTranslator = /** @class */ (function (_super) {
471
470
  var _this = this;
472
471
  var translateConstant = function (constant) {
473
472
  if (typeof constant === 'string') {
474
- return "'".concat(constant, "'");
473
+ return " ".concat(new Date(constant).valueOf());
475
474
  }
476
475
  else if (constant instanceof Date) {
477
- return "'".concat(luxon_1.DateTime.fromJSDate(constant).toFormat('yyyy-LL-dd HH:mm:ss'), "'");
476
+ return " ".concat(constant.valueOf());
478
477
  }
479
478
  else {
480
479
  (0, assert_1.default)(typeof constant === 'number');
481
- return "".concat(constant);
480
+ return " ".concat(constant);
482
481
  }
483
482
  };
484
483
  var translateInner = function (expr) {
@@ -547,8 +546,6 @@ var MySqlTranslator = /** @class */ (function (_super) {
547
546
  };
548
547
  MySqlTranslator.prototype.populateUpdateStmt = function (updateText, fromText, aliasDict, filterText, sorterText, indexFrom, count, option) {
549
548
  // todo using index
550
- var alias = aliasDict['./'];
551
- var now = luxon_1.DateTime.now().toFormat('yyyy-LL-dd HH:mm:ss');
552
549
  (0, assert_1.default)(updateText);
553
550
  var sql = "update ".concat(fromText, " set ").concat(updateText);
554
551
  if (filterText) {
@@ -566,7 +563,7 @@ var MySqlTranslator = /** @class */ (function (_super) {
566
563
  MySqlTranslator.prototype.populateRemoveStmt = function (removeText, fromText, aliasDict, filterText, sorterText, indexFrom, count, option) {
567
564
  // todo using index
568
565
  var alias = aliasDict['./'];
569
- var now = luxon_1.DateTime.now().toFormat('yyyy-LL-dd HH:mm:ss');
566
+ var now = Date.now();
570
567
  var sql = "update ".concat(fromText, " set `").concat(alias, "`.`$$deleteAt$$` = '").concat(now, "'");
571
568
  if (filterText) {
572
569
  sql += " where ".concat(filterText);
@@ -704,15 +704,17 @@ var SqlTranslator = /** @class */ (function () {
704
704
  };
705
705
  SqlTranslator.prototype.translateRemove = function (entity, operation, option) {
706
706
  var filter = operation.filter, sorter = operation.sorter, indexFrom = operation.indexFrom, count = operation.count;
707
+ (0, assert_1.default)(!sorter, '当前remove不支持sorter行为');
707
708
  var _a = this.analyzeJoin(entity, { filter: filter, sorter: sorter }), aliasDict = _a.aliasDict, filterRefAlias = _a.filterRefAlias, extraWhere = _a.extraWhere, fromText = _a.from, currentNumber = _a.currentNumber;
708
709
  var alias = aliasDict['./'];
709
- var filterText = this.translateFilter(entity, operation, aliasDict, filterRefAlias, currentNumber, extraWhere).stmt;
710
- var sorterText = sorter && sorter.length > 0 ? this.translateSorter(entity, sorter, aliasDict) : undefined;
711
- return this.populateRemoveStmt(alias, fromText, aliasDict, filterText, sorterText, indexFrom, count, option);
710
+ var filterText = this.translateFilter(entity, operation, aliasDict, filterRefAlias, currentNumber, extraWhere, { includedDeleted: true }).stmt;
711
+ // const sorterText = sorter && sorter.length > 0 ? this.translateSorter(entity, sorter, aliasDict) : undefined;
712
+ return this.populateRemoveStmt(alias, fromText, aliasDict, filterText, /* sorterText */ undefined, indexFrom, count, option);
712
713
  };
713
714
  SqlTranslator.prototype.translateUpdate = function (entity, operation, option) {
714
715
  var attributes = this.schema[entity].attributes;
715
716
  var filter = operation.filter, sorter = operation.sorter, indexFrom = operation.indexFrom, count = operation.count, data = operation.data;
717
+ (0, assert_1.default)(!sorter, '当前update不支持sorter行为');
716
718
  var _a = this.analyzeJoin(entity, { filter: filter, sorter: sorter }), aliasDict = _a.aliasDict, filterRefAlias = _a.filterRefAlias, extraWhere = _a.extraWhere, fromText = _a.from, currentNumber = _a.currentNumber;
717
719
  var alias = aliasDict['./'];
718
720
  var updateText = '';
@@ -725,8 +727,8 @@ var SqlTranslator = /** @class */ (function () {
725
727
  updateText += "`".concat(alias, "`.`").concat(attr, "` = ").concat(value);
726
728
  }
727
729
  var filterText = this.translateFilter(entity, operation, aliasDict, filterRefAlias, currentNumber, extraWhere).stmt;
728
- var sorterText = sorter && this.translateSorter(entity, sorter, aliasDict);
729
- return this.populateUpdateStmt(updateText, fromText, aliasDict, filterText, sorterText, indexFrom, count, option);
730
+ // const sorterText = sorter && this.translateSorter(entity, sorter, aliasDict);
731
+ return this.populateUpdateStmt(updateText, fromText, aliasDict, filterText, /* sorterText */ undefined, indexFrom, count, option);
730
732
  };
731
733
  SqlTranslator.prototype.translateDestroyEntity = function (entity, truncate) {
732
734
  var schema = this.schema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-db",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "oak-db",
5
5
  "main": "lib/index",
6
6
  "author": {
@@ -16,10 +16,9 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "lodash": "^4.17.21",
19
- "luxon": "^2.4.0",
20
19
  "mysql": "^2.18.1",
21
20
  "mysql2": "^2.3.3",
22
- "oak-domain": "^1.1.12",
21
+ "oak-domain": "^1.1.13",
23
22
  "uuid": "^8.3.2"
24
23
  },
25
24
  "license": "ISC",
@@ -30,7 +29,7 @@
30
29
  "@types/node": "^17.0.42",
31
30
  "@types/uuid": "^8.3.4",
32
31
  "mocha": "^10.0.0",
33
- "oak-general-business": "^1.0.13",
32
+ "oak-general-business": "file:../oak-general-business",
34
33
  "ts-node": "~10.9.1",
35
34
  "tslib": "^2.4.0",
36
35
  "typescript": "~4.7.4"