Use "marlon-sousa/sea-query"
This commit is contained in:
parent
6a0db92c8b
commit
c5468eb92f
@ -30,7 +30,7 @@ futures-util = { version = "^0.3" }
|
|||||||
log = { version = "^0.4", optional = true }
|
log = { version = "^0.4", optional = true }
|
||||||
rust_decimal = { version = "^1", optional = true }
|
rust_decimal = { version = "^1", optional = true }
|
||||||
sea-orm-macros = { version = "^0.3.1", path = "sea-orm-macros", optional = true }
|
sea-orm-macros = { version = "^0.3.1", path = "sea-orm-macros", optional = true }
|
||||||
sea-query = { version = "^0.18.0", features = ["thread-safe"] }
|
sea-query = { version = "^0.18.0", git = "https://github.com/marlon-sousa/sea-query.git", branch = "extended-returning-support", features = ["thread-safe"] }
|
||||||
sea-strum = { version = "^0.21", features = ["derive", "sea-orm"] }
|
sea-strum = { version = "^0.21", features = ["derive", "sea-orm"] }
|
||||||
serde = { version = "^1.0", features = ["derive"] }
|
serde = { version = "^1.0", features = ["derive"] }
|
||||||
serde_json = { version = "^1", optional = true }
|
serde_json = { version = "^1", optional = true }
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
error::*, ActiveModelTrait, ConnectionTrait, DbBackend, EntityTrait, Insert, PrimaryKeyTrait,
|
error::*, ActiveModelTrait, ConnectionTrait, DbBackend, EntityTrait, Insert, Iterable,
|
||||||
Statement, TryFromU64,
|
PrimaryKeyTrait, Statement, TryFromU64,
|
||||||
};
|
};
|
||||||
use sea_query::{FromValueTuple, InsertStatement, ValueTuple};
|
use sea_query::{FromValueTuple, InsertStatement, IntoColumnRef, Returning, ValueTuple};
|
||||||
use std::{future::Future, marker::PhantomData};
|
use std::{future::Future, marker::PhantomData};
|
||||||
|
|
||||||
/// Defines a structure to perform INSERT operations in an ActiveModel
|
/// Defines a structure to perform INSERT operations in an ActiveModel
|
||||||
@ -39,15 +39,14 @@ where
|
|||||||
{
|
{
|
||||||
// so that self is dropped before entering await
|
// so that self is dropped before entering await
|
||||||
let mut query = self.query;
|
let mut query = self.query;
|
||||||
if db.get_database_backend() == DbBackend::Postgres {
|
if db.get_database_backend() == DbBackend::Postgres
|
||||||
use crate::{sea_query::Query, Iterable};
|
&& <A::Entity as EntityTrait>::PrimaryKey::iter().count() > 0
|
||||||
if <A::Entity as EntityTrait>::PrimaryKey::iter().count() > 0 {
|
{
|
||||||
query.returning(
|
query.returning(Returning::Columns(
|
||||||
Query::select()
|
<A::Entity as EntityTrait>::PrimaryKey::iter()
|
||||||
.columns(<A::Entity as EntityTrait>::PrimaryKey::iter())
|
.map(|c| c.into_column_ref())
|
||||||
.take(),
|
.collect(),
|
||||||
);
|
));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Inserter::<A>::new(self.primary_key, query).exec(db)
|
Inserter::<A>::new(self.primary_key, query).exec(db)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user