Merged PR 667: ロックが効かなくなる
## 概要 [Task3420: ロックが効かなくなる](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3420) - 「タスク 3400: テスト修正」対応の影響で正しくlockが行われなくなっていた事象を修正 ## レビューポイント - 特になし ## UIの変更 - 無し ## 動作確認状況 - ユニットテスト実施、ローカル動作確認時、sqlにfor updateが付与されることを確認 ## 補足 - 相談、参考資料などがあれば
This commit is contained in:
parent
4a73d5f8c4
commit
7f8e2d5411
@ -301,10 +301,3 @@ export const USER_AUDIO_FORMAT = 'DS2(QP)';
|
||||
* @const {string[]}
|
||||
*/
|
||||
export const NODE_ENV_TEST = 'test';
|
||||
|
||||
/**
|
||||
* SQLのlockOptionの種類
|
||||
*/
|
||||
export const DB_LOCK_MODE = {
|
||||
PESSIMISTIC_WRITE: 'pessimistic_write',
|
||||
};
|
||||
|
||||
@ -9,7 +9,6 @@ import {
|
||||
} from './entity/license.entity';
|
||||
import {
|
||||
CARD_LICENSE_LENGTH,
|
||||
DB_LOCK_MODE,
|
||||
LICENSE_ALLOCATED_STATUS,
|
||||
LICENSE_ISSUE_STATUS,
|
||||
LICENSE_TYPE,
|
||||
@ -417,20 +416,16 @@ export class LicensesRepositoryService {
|
||||
const licenseOrderRepo = entityManager.getRepository(LicenseOrder);
|
||||
const licenseRepo = entityManager.getRepository(License);
|
||||
|
||||
let lockOption = {};
|
||||
// テスト環境の場合は悲観的ロックを行わない
|
||||
if (process.env.NODE_ENV !== NODE_ENV_TEST) {
|
||||
lockOption = { mode: DB_LOCK_MODE.PESSIMISTIC_WRITE };
|
||||
}
|
||||
|
||||
const issuingOrder = await licenseOrderRepo.findOne({
|
||||
where: {
|
||||
from_account_id: orderedAccountId,
|
||||
po_number: poNumber,
|
||||
},
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
|
||||
...lockOption,
|
||||
// テスト環境の場合はロックを行わない(sqliteがlockに対応していないため)
|
||||
...(process.env.NODE_ENV !== NODE_ENV_TEST
|
||||
? { lock: { mode: 'pessimistic_write' } }
|
||||
: {}),
|
||||
});
|
||||
if (!issuingOrder) {
|
||||
// 注文が存在しない場合、エラー
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user