Skip to content

Commit

Permalink
Initial lock support (#118)
Browse files Browse the repository at this point in the history
* Initial lock support

* Move methods to QuerySelect trait

Co-authored-by: Marco Napetti <nappa85@therocktrading.com>
  • Loading branch information
nappa85 and Marco Napetti authored Sep 10, 2021
1 parent 889e9df commit c3084e4
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/query/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
PrimaryKeyToColumn, RelationDef,
};
pub use sea_query::{Condition, ConditionalStatement, DynIden, JoinType, Order, OrderedStatement};
use sea_query::{Expr, IntoCondition, SeaRc, SelectExpr, SelectStatement, SimpleExpr, TableRef};
use sea_query::{Expr, IntoCondition, LockType, SeaRc, SelectExpr, SelectStatement, SimpleExpr, TableRef};

// LINT: when the column does not appear in tables selected from
// LINT: when there is a group by clause, but some columns don't have aggregate functions
Expand Down Expand Up @@ -140,6 +140,24 @@ pub trait QuerySelect: Sized {
.join(join, rel.from_tbl.clone(), join_condition(rel));
self
}

/// Select lock
fn lock(mut self, lock_type: LockType) -> Self {
self.query().lock(lock_type);
self
}

/// Select lock shared
fn lock_shared(mut self) -> Self {
self.query().lock_shared();
self
}

/// Select lock exclusive
fn lock_exclusive(mut self) -> Self {
self.query().lock_exclusive();
self
}
}

// LINT: when the column does not appear in tables selected from
Expand Down

0 comments on commit c3084e4

Please sign in to comment.