Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): allow disabling transactions #4260

Merged
merged 1 commit into from Apr 23, 2023
Merged

Conversation

B4nan
Copy link
Member

@B4nan B4nan commented Apr 23, 2023

Is it now possible to disable transactions, either globally via disableTransactions config option, or locally when using em.transactional().

// only the outer transaction will be opened
await orm.em.transactional(async em => {
  // but the inner calls to both em.transactional and em.begin will be no-op
  await em.transactional(...);
}, { disableTransactions: true });

Alternatively, you can disable transactions when creating new forks:

const em = await orm.em.fork({ disableTransactions: true });
await em.transactional(...); // no-op
await em.begin(...); // no-op
await em.commit(...); // commit still calls `flush`

Closes #3747
Closes #3992

@codecov
Copy link

codecov bot commented Apr 23, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (0693029) 99.65% compared to head (cd443cc) 99.65%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4260   +/-   ##
=======================================
  Coverage   99.65%   99.65%           
=======================================
  Files         214      214           
  Lines       14036    14047   +11     
  Branches     3300     3305    +5     
=======================================
+ Hits        13988    13999   +11     
  Misses         47       47           
  Partials        1        1           
Impacted Files Coverage Δ
packages/core/src/enums.ts 100.00% <ø> (ø)
packages/core/src/utils/Configuration.ts 100.00% <ø> (ø)
packages/core/src/EntityManager.ts 98.11% <100.00%> (+0.03%) ⬆️
packages/core/src/platforms/Platform.ts 99.56% <100.00%> (ø)
packages/mongodb/src/MongoEntityManager.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Is it now possible to disable transactions, either globally via `disableTransactions` config option, or locally when using `em.transactional()`.

```ts
// only the outer transaction will be opened
await orm.em.transactional(async em => {
  // but the inner calls to both em.transactional and em.begin will be no-op
  await em.transactional(...);
}, { disableTransactions: true });
```

Alternatively, you can disable transactions when creating new forks:

```ts
const em = await orm.em.fork({ disableTransactions: true });
await em.transactional(...); // no-op
await em.begin(...); // no-op
await em.commit(...); // commit still calls `flush`
```

Closes #3747
Closes #3992
@B4nan B4nan merged commit 8e8bc38 into master Apr 23, 2023
7 of 8 checks passed
@B4nan B4nan deleted the disable-transactions branch April 23, 2023 19:38
jsprw pushed a commit to jsprw/mikro-orm-full-text-operators that referenced this pull request May 7, 2023
Is it now possible to disable transactions, either globally via
`disableTransactions` config option, or locally when using
`em.transactional()`.

```ts
// only the outer transaction will be opened
await orm.em.transactional(async em => {
  // but the inner calls to both em.transactional and em.begin will be no-op
  await em.transactional(...);
}, { disableTransactions: true });
```

Alternatively, you can disable transactions when creating new forks:

```ts
const em = await orm.em.fork({ disableTransactions: true });
await em.transactional(...); // no-op
await em.begin(...); // no-op
await em.commit(...); // commit still calls `flush`
```

Closes mikro-orm#3747
Closes mikro-orm#3992
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant