Upgrade sea-orm

This commit is contained in:
Antonio Scandurra 2022-12-05 14:56:01 +01:00
parent d3c411677a
commit eec3df09be
2 changed files with 13 additions and 19 deletions

12
Cargo.lock generated
View File

@ -3204,9 +3204,9 @@ dependencies = [
[[package]]
name = "libsqlite3-sys"
version = "0.25.1"
version = "0.25.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f0455f2c1bc9a7caa792907026e469c1d91761fb0ea37cbb16427c77280cf35"
checksum = "29f835d03d717946d28b1d1ed632eb6f0e24a299388ee623d0c23118d3e8a7fa"
dependencies = [
"cc",
"pkg-config",
@ -5328,9 +5328,9 @@ dependencies = [
[[package]]
name = "sea-orm"
version = "0.10.4"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3120bc435b8640963ffda698f877610e07e077157e216eb99408d819c344034d"
checksum = "28fc9dad132e450d6320bd5953e70fb88b42785080b591e9be804da69bd8a170"
dependencies = [
"async-stream",
"async-trait",
@ -5356,9 +5356,9 @@ dependencies = [
[[package]]
name = "sea-orm-macros"
version = "0.10.4"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c54bacfeb842813c16821e21f9456c358861a448294075184ea1d6307e386d08"
checksum = "66af5d33e04e56dafb2c700f9b1201a39e6c2c77b53ed9ee93244f21f8de6041"
dependencies = [
"bae",
"heck 0.3.3",

View File

@ -23,9 +23,9 @@ use hyper::StatusCode;
use rpc::{proto, ConnectionId};
pub use sea_orm::ConnectOptions;
use sea_orm::{
entity::prelude::*, ActiveValue, ConnectionTrait, DatabaseBackend, DatabaseConnection,
DatabaseTransaction, DbErr, FromQueryResult, IntoActiveModel, JoinType, QueryOrder,
QuerySelect, Statement, TransactionTrait,
entity::prelude::*, ActiveValue, ConnectionTrait, DatabaseConnection, DatabaseTransaction,
DbErr, FromQueryResult, IntoActiveModel, IsolationLevel, JoinType, QueryOrder, QuerySelect,
Statement, TransactionTrait,
};
use sea_query::{Alias, Expr, OnConflict, Query};
use serde::{Deserialize, Serialize};
@ -2211,16 +2211,10 @@ impl Database {
F: Send + Fn(TransactionHandle) -> Fut,
Fut: Send + Future<Output = Result<T>>,
{
let tx = self.pool.begin().await?;
// In Postgres, serializable transactions are opt-in
if let DatabaseBackend::Postgres = self.pool.get_database_backend() {
tx.execute(Statement::from_string(
DatabaseBackend::Postgres,
"SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;".into(),
))
let tx = self
.pool
.begin_with_config(Some(IsolationLevel::Serializable), None)
.await?;
}
let mut tx = Arc::new(Some(tx));
let result = f(TransactionHandle(tx.clone())).await;
@ -2584,7 +2578,7 @@ mod test {
impl Drop for TestDb {
fn drop(&mut self) {
let db = self.db.take().unwrap();
if let DatabaseBackend::Postgres = db.pool.get_database_backend() {
if let sea_orm::DatabaseBackend::Postgres = db.pool.get_database_backend() {
db.runtime.as_ref().unwrap().block_on(async {
use util::ResultExt;
let query = "