Update docs

This commit is contained in:
Billy Chan 2021-11-08 15:24:51 +08:00
parent 2f7cffa74d
commit 732d080020
No known key found for this signature in database
GPG Key ID: A2D690CAC7DF3CC7
2 changed files with 4 additions and 5 deletions

View File

@ -2,7 +2,7 @@ use crate::{
error::*, ActiveModelTrait, ConnectionTrait, DbBackend, EntityTrait, Insert, IntoActiveModel, error::*, ActiveModelTrait, ConnectionTrait, DbBackend, EntityTrait, Insert, IntoActiveModel,
Iterable, PrimaryKeyTrait, SelectModel, SelectorRaw, Statement, TryFromU64, Iterable, PrimaryKeyTrait, SelectModel, SelectorRaw, Statement, TryFromU64,
}; };
use sea_query::{FromValueTuple, InsertStatement, IntoColumnRef, Returning, ValueTuple}; use sea_query::{FromValueTuple, Iden, 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
@ -51,7 +51,7 @@ where
Inserter::<A>::new(self.primary_key, query).exec(db) Inserter::<A>::new(self.primary_key, query).exec(db)
} }
/// Execute an insert operation and return the inserted model /// Execute an insert operation and return the inserted model (use `RETURNING` syntax if database supported)
pub fn exec_with_returning<'a, C>( pub fn exec_with_returning<'a, C>(
self, self,
db: &'a C, db: &'a C,
@ -88,7 +88,7 @@ where
exec_insert(self.primary_key, builder.build(&self.query), db) exec_insert(self.primary_key, builder.build(&self.query), db)
} }
/// Execute an insert operation and return the inserted model /// Execute an insert operation and return the inserted model (use `RETURNING` syntax if database supported)
pub fn exec_with_returning<'a, C>( pub fn exec_with_returning<'a, C>(
self, self,
db: &'a C, db: &'a C,
@ -115,7 +115,6 @@ where
type ValueTypeOf<A> = <PrimaryKey<A> as PrimaryKeyTrait>::ValueType; type ValueTypeOf<A> = <PrimaryKey<A> as PrimaryKeyTrait>::ValueType;
let last_insert_id_opt = match db.get_database_backend() { let last_insert_id_opt = match db.get_database_backend() {
DbBackend::Postgres => { DbBackend::Postgres => {
use crate::sea_query::Iden;
let cols = PrimaryKey::<A>::iter() let cols = PrimaryKey::<A>::iter()
.map(|col| col.to_string()) .map(|col| col.to_string())
.collect::<Vec<_>>(); .collect::<Vec<_>>();

View File

@ -113,7 +113,7 @@ where
} }
} }
_ => { _ => {
// If we updating a row that does not exist, error will be thrown here. // If we updating a row that does not exist then an error will be thrown here.
Updater::new(query).check_record_exists().exec(db).await?; Updater::new(query).check_record_exists().exec(db).await?;
let primary_key_value = match model.get_primary_key_value() { let primary_key_value = match model.get_primary_key_value() {
Some(val) => FromValueTuple::from_value_tuple(val), Some(val) => FromValueTuple::from_value_tuple(val),