Skip to content

refactor: add transaction handling in auto CRUD controller#312

Merged
mini-bomba merged 2 commits into
mainfrom
add_transactions
Jun 20, 2026
Merged

refactor: add transaction handling in auto CRUD controller#312
mini-bomba merged 2 commits into
mainfrom
add_transactions

Conversation

@krzys13

@krzys13 krzys13 commented May 29, 2026

Copy link
Copy Markdown
Contributor

#277
Add transaction usage in all methods of auto crud controlle.
There is need to add transactions in 'user managment API'
Should I apply trnsactions in seeders, and scrappers also?

@krzys13 krzys13 requested a review from a team as a code owner May 29, 2026 18:45
@github-actions

Copy link
Copy Markdown
Contributor

Looks like you did not link an issue to this PR. If this PR completes a task, consider linking it.

@czaja307 czaja307 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i found one more place that could use transactions - otherwise seems good 🔥

i don't thing we need transactions on seeders or scrappers as they are only used once without much concurrency risc

Comment thread app/controllers/auto_crud_controller.ts Outdated
@krzys13 krzys13 enabled auto-merge June 1, 2026 10:38
@krzys13 krzys13 disabled auto-merge June 1, 2026 10:38
@mini-bomba mini-bomba changed the title refactor: add transaction handling in auto CRUD controller #277 refactor: add transaction handling in auto CRUD controller Jun 1, 2026
@mini-bomba mini-bomba linked an issue Jun 1, 2026 that may be closed by this pull request
Comment thread app/controllers/auto_crud_controller.ts
Comment thread app/controllers/auto_crud_controller.ts
Comment thread app/controllers/auto_crud_controller.ts
Comment thread app/controllers/auto_crud_controller.ts Outdated
@krzys13 krzys13 force-pushed the add_transactions branch from 62fe484 to 4911b12 Compare June 1, 2026 19:54
@pull-request-size pull-request-size Bot added size/XL and removed size/L labels Jun 1, 2026
@krzys13 krzys13 force-pushed the add_transactions branch 2 times, most recently from 8f1bfec to 1d46284 Compare June 1, 2026 20:27
@krzys13

krzys13 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

We need to discuss

  1. Isolations levels fot querries
  2. How to implement transactions in validators, Validators operate on http body{request} not on specific model instance.

@mini-bomba

Copy link
Copy Markdown
Member

for isolation levels, i'd suggest repeatable read

to implement transactions in the foreign key validator, i'd suggest passing in the trx object via validation metadata

@krzys13 krzys13 enabled auto-merge June 1, 2026 21:45
@krzys13 krzys13 disabled auto-merge June 1, 2026 21:45
@krzys13 krzys13 force-pushed the add_transactions branch from 1d46284 to 422dd08 Compare June 2, 2026 14:41
@krzys13

krzys13 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

for isolation levels, i'd suggest repeatable read

to implement transactions in the foreign key validator, i'd suggest passing in the trx object via validation metadata

Isolations are done
Validation still not

@krzys13

krzys13 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

I don't think this validator should exist here, because it only validates the existence of a foreign key.

This seems to already be handled by the oneToOneRelationStore method:

/**
 * Create a related object for 1:1 relations
 *
 * Return type set to Promise<unknown> to allow for method overrides
 */
async oneToOneRelationStore(httpCtx: HttpContext): Promise<unknown>

which handles creating the related object during the store flow.

@mini-bomba

@krzys13 krzys13 enabled auto-merge June 3, 2026 14:27
@krzys13 krzys13 requested a review from czaja307 June 3, 2026 14:28
@mini-bomba

mini-bomba commented Jun 3, 2026

Copy link
Copy Markdown
Member

I'm pretty sure I've made the validators for related-store operations omit the foreign key field on the related object to be created, so it shouldn't matter whether the field has a foreign key validator or not

the foreign key validator is actually executed in two scenarios:

  • for direct store ops of objects with foreign keys
  • for related-store ops of related objects with multiple foreign keys (validators for foreign key fields for other relations are still used)

(oh and i guess for updates too)

@krzys13

krzys13 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

I'm pretty sure I've made the validators for related-store operations omit the foreign key field on the related object to be created, so it shouldn't matter whether the field has a foreign key validator or not

the foreign key validator is actually executed in two scenarios:

  • for direct store ops of objects with foreign keys
  • for related-store ops of related objects with multiple foreign keys (validators for foreign key fields for other relations are still used)

(oh and i guess for updates too)

I think we can close that issue and start another about validator refactor. Should checking fk be only in crud controller for better arch.

@krzys13 krzys13 disabled auto-merge June 5, 2026 11:54
@krzys13 krzys13 enabled auto-merge June 5, 2026 11:54
@krzys13 krzys13 force-pushed the add_transactions branch from 422dd08 to 106195b Compare June 6, 2026 09:22
@krzys13 krzys13 force-pushed the add_transactions branch 2 times, most recently from 83a7870 to 2369447 Compare June 7, 2026 19:32
@krzys13 krzys13 added the help wanted Extra attention is needed label Jun 7, 2026
@krzys13 krzys13 disabled auto-merge June 7, 2026 21:16
@krzys13 krzys13 closed this Jun 11, 2026
@krzys13 krzys13 force-pushed the add_transactions branch from 2369447 to 238ab16 Compare June 11, 2026 15:16
@krzys13 krzys13 reopened this Jun 11, 2026
@krzys13 krzys13 force-pushed the add_transactions branch 2 times, most recently from b33f4ab to 1095170 Compare June 11, 2026 17:09
@krzys13 krzys13 force-pushed the add_transactions branch from 1095170 to 8cb13c4 Compare June 11, 2026 17:12
@krzys13 krzys13 enabled auto-merge June 11, 2026 17:17
@krzys13 krzys13 force-pushed the add_transactions branch from 8cb13c4 to 2e4771d Compare June 11, 2026 19:08
Add transaction usage in all methods of auto crud controller
Add transaction usage in v1/drafts controler
Add transaction usage in validators exactly in foreign key validator
@krzys13 krzys13 force-pushed the add_transactions branch from 2e4771d to ee0dd09 Compare June 11, 2026 19:14
@krzys13 krzys13 requested a review from mini-bomba June 14, 2026 13:32
@krzys13 krzys13 disabled auto-merge June 14, 2026 13:32

@mini-bomba mini-bomba left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@mini-bomba mini-bomba enabled auto-merge June 20, 2026 11:44
@mini-bomba mini-bomba added this pull request to the merge queue Jun 20, 2026
Merged via the queue into main with commit b0df0ac Jun 20, 2026
12 checks passed
@mini-bomba mini-bomba deleted the add_transactions branch June 20, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: add transactions, everywhere

3 participants