Skip to content
Snippets Groups Projects
Commit 098ef40d authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

fix(1448): Should not start a SQL transaction that will not be committed - close #1448

parent ad15e965
No related branches found
No related tags found
No related merge requests found
Pipeline #32380 waiting for manual action
...@@ -219,11 +219,12 @@ export class MetaDAL extends AbstractSQLite<DBMeta> { ...@@ -219,11 +219,12 @@ export class MetaDAL extends AbstractSQLite<DBMeta> {
// Add new columns 'issuer' and 'recipient' // Add new columns 'issuer' and 'recipient'
try { try {
await txsDAL.exec( await txsDAL.exec(
"BEGIN;" +
"ALTER TABLE txs ADD COLUMN issuer VARCHAR(50) NULL;" + "ALTER TABLE txs ADD COLUMN issuer VARCHAR(50) NULL;" +
"ALTER TABLE txs ADD COLUMN recipient VARCHAR(50) NULL;" + "ALTER TABLE txs ADD COLUMN recipient VARCHAR(50) NULL;" +
"UOPDATE txs SET issuer = SUBSTR(issuers, 2, LENGTH(issuers) - 4) WHERE issuer IS NULL AND issuers NOT LIKE '%,%';" + // SHOULD start transaction after ALTER TABLE, to avoid leaving a not closed transaction, if failed - close #1448
"UOPDATE txs SET recipient = SUBSTR(recipients, 2, LENGTH(recipients) - 4) WHERE recipient IS NULL AND recipients NOT LIKE '%,%';" + "BEGIN;" +
"UPDATE txs SET issuer = SUBSTR(issuers, 2, LENGTH(issuers) - 4) WHERE issuer IS NULL AND issuers NOT LIKE '%,%';" +
"UPDATE txs SET recipient = SUBSTR(recipients, 2, LENGTH(recipients) - 4) WHERE recipient IS NULL AND recipients NOT LIKE '%,%';" +
"COMMIT;" "COMMIT;"
); );
} catch (err) { } catch (err) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment