You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to lock a row if it matches my search criteria.
(and also prevent such rows from being created while the lock is active).
id is my primary key.
sfdcId is not the primary key but a unique key(varchar).
My code:
let mainProductVersion = await em.findOne(Entities.SfdcProductVersions,
{'sfdcId': artifactInput.metadata.sfdc_version_id},
{lockMode: LockMode.PESSIMISTIC_READ});
Debug trace
select e0.* from sfdc_product_versions as e0 where e0.sfdc_id = 'f5DWWDqwDwd2411' limit 1
To Reproduce
Steps to reproduce the behavior:
Use findOne with lockMode and query by non-primary key
Expected behavior
The query should contain a lock statement depending on the type of lock such as FOR UPDATE or lock in share mode.
Additional notes
I've tried locking the entity after it's returned, but that does not solve my issue - I want to make sure that
such an entity cannot be created in some other transaction. And since it does not exist at that point ->
I can't lock it.
Versions
Dependency
Version
node
12
typescript
4.1.3
mikro-orm
4.3.4
mysql(server)
5.7
The text was updated successfully, but these errors were encountered:
Describe the bug
I want to lock a row if it matches my search criteria.
(and also prevent such rows from being created while the lock is active).
id is my primary key.
sfdcId is not the primary key but a unique key(varchar).
My code:
Debug trace
select
e0
.* fromsfdc_product_versions
ase0
wheree0
.sfdc_id
= 'f5DWWDqwDwd2411' limit 1To Reproduce
Steps to reproduce the behavior:
Expected behavior
The query should contain a lock statement depending on the type of lock such as
FOR UPDATE
orlock in share mode
.Additional notes
I've tried locking the entity after it's returned, but that does not solve my issue - I want to make sure that
such an entity cannot be created in some other transaction. And since it does not exist at that point ->
I can't lock it.
Versions
The text was updated successfully, but these errors were encountered: