Skip to content

Enhancement: separate RepositoryService method for SELECT FOR UPDATE #488

@funkindy

Description

@funkindy

Summary

In have some default transactions with steps:

  1. Get row from database and lock it with FOR UPDATE
  2. Check/validate row data
  3. Update row

I cant find a good way for step 1 except providing the statement like this:

await repo.get(
    item_id=item_id,
    id_attribute='id',
    statement=select(Item).with_for_update(),
)

This is inconsistent with update/upsert/... RepositoryService API, which provide convenient with_for_update argument.

Maybe consider adding this argument for get* RepositoryService API?

Pure SA Session.get method includes this argument as well: https://docs.sqlalchemy.org/en/20/orm/session_api.html#sqlalchemy.orm.Session.get

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions