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

Expose lock_with_behavior from the QuerySelect #1866

Closed
GrandChaman opened this issue Sep 22, 2023 · 0 comments · Fixed by #1867
Closed

Expose lock_with_behavior from the QuerySelect #1866

GrandChaman opened this issue Sep 22, 2023 · 0 comments · Fixed by #1867

Comments

@GrandChaman
Copy link
Contributor

Motivation

As of now, if one wants to fetch a row using the FOR UPDATE SKIP LOCKED clauses, one need to write something that looks like that:

let mut select = Entity::find_by_id(id);

QuerySelect::query(&mut select) // Many traits have the `query` method, so we need to differentiate here.
    // This returns a `&mut SelectStatement`, which cannot be chained with the implementors of `QuerySelect`.
    // So we have to write it on a separate line.
    .lock_with_behavior(LockType::Update, LockBehavior::SkipLocked);

select
        .one(conn)
        .await

Proposed Solutions

This is a minor issue of course, but could be alleviated fairly easily by exposing the .lock_with_behavior directly from the QuerySelect trait.

A PR will follow to address this issue.

Current Workarounds

The attached example demonstrates the current workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant