发布前依赖以及几个测试出来的bug
This commit is contained in:
parent
3ecaa41221
commit
2ca7ff9736
|
|
@ -270,7 +270,7 @@ var MysqlStore = /** @class */ (function (_super) {
|
|||
return [4 /*yield*/, this.connector.exec(sql, context.getCurrentTxnId())];
|
||||
case 1:
|
||||
result = _a.sent();
|
||||
return [2 /*return*/, result.count];
|
||||
return [2 /*return*/, result[0].cnt];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -549,7 +549,8 @@ var MySqlTranslator = /** @class */ (function (_super) {
|
|||
// todo using index
|
||||
var alias = aliasDict['./'];
|
||||
var now = luxon_1.DateTime.now().toFormat('yyyy-LL-dd HH:mm:ss');
|
||||
var sql = "update ".concat(fromText, " set ").concat(updateText ? "".concat(updateText, ",") : '', " `").concat(alias, "`.`$$updateAt$$` = '").concat(now, "'");
|
||||
(0, assert_1.default)(updateText);
|
||||
var sql = "update ".concat(fromText, " set ").concat(updateText);
|
||||
if (filterText) {
|
||||
sql += " where ".concat(filterText);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,11 @@ var SqlTranslator = /** @class */ (function () {
|
|||
var schema = this.schema;
|
||||
var _a = schema[entity], attributes = _a.attributes, _b = _a.storageName, storageName = _b === void 0 ? entity : _b;
|
||||
var sql = "insert into `".concat(storageName, "`(");
|
||||
var attrs = Object.keys(data[0]).filter(function (ele) { return attributes.hasOwnProperty(ele); });
|
||||
/**
|
||||
* 这里的attrs要用所有行的union集合
|
||||
*/
|
||||
var dataFull = data.reduce(function (prev, cur) { return Object.assign({}, cur, prev); }, {});
|
||||
var attrs = Object.keys(dataFull).filter(function (ele) { return attributes.hasOwnProperty(ele); });
|
||||
attrs.forEach(function (attr, idx) {
|
||||
sql += " `".concat(attr, "`");
|
||||
if (idx < attrs.length - 1) {
|
||||
|
|
@ -685,11 +689,11 @@ var SqlTranslator = /** @class */ (function () {
|
|||
var _a = this.analyzeJoin(entity, {
|
||||
filter: filter,
|
||||
}), fromText = _a.from, aliasDict = _a.aliasDict, extraWhere = _a.extraWhere, filterRefAlias = _a.filterRefAlias, currentNumber = _a.currentNumber;
|
||||
var projText = 'count(1)';
|
||||
var projText = 'count(1) cnt';
|
||||
var filterText = this.translateFilter(entity, selection, aliasDict, filterRefAlias, currentNumber, extraWhere, option).stmt;
|
||||
if (count) {
|
||||
var subQuerySql = this.populateSelectStmt('1', fromText, Object.assign({}, selection, { indexFrom: 0 }), aliasDict, filterText, undefined, undefined, undefined, option);
|
||||
return "select count(1) from (".concat(subQuerySql, ")");
|
||||
var subQuerySql = this.populateSelectStmt('1', fromText, Object.assign({}, selection, { indexFrom: 0, count: count }), aliasDict, filterText, undefined, undefined, undefined, option);
|
||||
return "select count(1) cnt from (".concat(subQuerySql, ") __tmp");
|
||||
}
|
||||
return this.populateSelectStmt(projText, fromText, selection, aliasDict, filterText, undefined, undefined, undefined, option);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
"luxon": "^2.4.0",
|
||||
"mysql": "^2.18.1",
|
||||
"mysql2": "^2.3.3",
|
||||
"oak-domain": "file:../oak-domain",
|
||||
"oak-domain": "1.1.10",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"license": "ISC",
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
"@types/node": "^17.0.42",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"mocha": "^10.0.0",
|
||||
"oak-general-business": "file:../oak-general-business",
|
||||
"oak-general-business": "1.0.13",
|
||||
"ts-node": "~10.9.1",
|
||||
"tslib": "^2.4.0",
|
||||
"typescript": "~4.7.4"
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ export class MysqlStore<ED extends EntityDict & BaseEntityDict, Cxt extends Cont
|
|||
const sql = this.translator.translateCount(entity, selection, option);
|
||||
|
||||
const result = await this.connector.exec(sql, context.getCurrentTxnId());
|
||||
return result.count as number;
|
||||
return result[0].cnt as number;
|
||||
}
|
||||
async begin(option?: TxnOption): Promise<string> {
|
||||
const txn = await this.connector.startTransaction(option);
|
||||
|
|
|
|||
|
|
@ -765,7 +765,8 @@ export class MySqlTranslator<ED extends EntityDict> extends SqlTranslator<ED> {
|
|||
// todo using index
|
||||
const alias = aliasDict['./'];
|
||||
const now = DateTime.now().toFormat('yyyy-LL-dd HH:mm:ss');
|
||||
let sql = `update ${fromText} set ${updateText ? `${updateText},` : ''} \`${alias}\`.\`$$updateAt$$\` = '${now}'`;
|
||||
assert(updateText);
|
||||
let sql = `update ${fromText} set ${updateText}`;
|
||||
if (filterText) {
|
||||
sql += ` where ${filterText}`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,11 @@ export abstract class SqlTranslator<ED extends EntityDict> {
|
|||
|
||||
let sql = `insert into \`${storageName as string}\`(`;
|
||||
|
||||
const attrs = Object.keys(data[0]).filter(
|
||||
/**
|
||||
* 这里的attrs要用所有行的union集合
|
||||
*/
|
||||
const dataFull = data.reduce((prev, cur) => Object.assign({}, cur, prev), {});
|
||||
const attrs = Object.keys(dataFull).filter(
|
||||
ele => attributes.hasOwnProperty(ele)
|
||||
);
|
||||
attrs.forEach(
|
||||
|
|
@ -851,13 +855,13 @@ export abstract class SqlTranslator<ED extends EntityDict> {
|
|||
filter,
|
||||
});
|
||||
|
||||
const projText = 'count(1)';
|
||||
const projText = 'count(1) cnt';
|
||||
|
||||
const { stmt: filterText } = this.translateFilter(entity, selection as ED[T]['Selection'], aliasDict, filterRefAlias, currentNumber, extraWhere, option);
|
||||
|
||||
if (count) {
|
||||
const subQuerySql = this.populateSelectStmt('1', fromText, Object.assign({}, selection, { indexFrom: 0 }) as ED[T]['Selection'], aliasDict, filterText, undefined, undefined, undefined, option);
|
||||
return `select count(1) from (${subQuerySql})`;
|
||||
const subQuerySql = this.populateSelectStmt('1', fromText, Object.assign({}, selection, { indexFrom: 0, count }) as ED[T]['Selection'], aliasDict, filterText, undefined, undefined, undefined, option);
|
||||
return `select count(1) cnt from (${subQuerySql}) __tmp`;
|
||||
}
|
||||
return this.populateSelectStmt(projText, fromText, selection as ED[T]['Selection'], aliasDict, filterText, undefined, undefined, undefined, option);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue