Initial lock support (#118)

* Initial lock support

* Move methods to QuerySelect trait

Co-authored-by: Marco Napetti <nappa85@therocktrading.com>
This commit is contained in:
Marco Napetti 2021-09-10 10:35:57 +02:00 committed by GitHub
parent 889e9df923
commit c3084e425f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
@ -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