refs #5595 VnModel.rawSql() bugfix
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2023-06-19 14:54:32 +02:00
parent 63888e2d64
commit 9fa6e2df71
2 changed files with 14 additions and 18 deletions

View File

@ -200,22 +200,20 @@ module.exports = function(Self) {
const connector = this.dataSource.connector;
let conn;
let res;
const opts = Object.assign({}, options);
try {
if (userId) {
conn = await new Promise((resolve, reject) => {
connector.client.getConnection(function(err, conn) {
if (err)
reject(err);
else
resolve(conn);
if (!options.transaction) {
options = Object.assign({}, options);
conn = await new Promise((resolve, reject) => {
connector.client.getConnection(function(err, conn) {
if (err)
reject(err);
else
resolve(conn);
});
});
});
const opts = Object.assign({}, options);
if (!opts.transaction) {
opts.transaction = {
options.transaction = {
connection: conn,
connector
};
@ -223,15 +221,14 @@ module.exports = function(Self) {
await connector.executeP(
'CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?))',
[userId], opts
[userId], options
);
}
res = await connector.executeP(query, params, opts);
res = await connector.executeP(query, params, options);
if (userId) {
await connector.executeP('CALL account.myUser_logout()', null, opts);
}
if (userId)
await connector.executeP('CALL account.myUser_logout()', null, options);
} finally {
if (conn) conn.release();
}

View File

@ -21,7 +21,6 @@ module.exports = Self => {
Self.confirm = async(ctx, orderFk) => {
const userId = ctx.req.accessToken.userId;
console.log(orderFk, userId);
const query = `CALL hedera.order_confirmWithUser(?, ?)`;
const response = await Self.rawSql(query, [orderFk, userId], {userId});