3 Commits

Author SHA1 Message Date
davidskrundz 302612281f Update sea-orm to 2.0.0-rc.10 2025-10-13 23:18:16 -06:00
davidskrundz 96f260d02d std -> core 2025-10-13 21:30:39 -06:00
davidskrundz 2bd654249d Add upsert conflict capability 2025-09-20 20:40:00 -06:00
10 changed files with 87 additions and 19 deletions
Generated
+37 -9
View File
@@ -268,6 +268,27 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "derive_more"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678"
dependencies = [
"derive_more-impl",
]
[[package]]
name = "derive_more-impl"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3"
dependencies = [
"proc-macro2",
"quote",
"syn",
"unicode-xid",
]
[[package]] [[package]]
name = "digest" name = "digest"
version = "0.10.7" version = "0.10.7"
@@ -1084,12 +1105,13 @@ dependencies = [
[[package]] [[package]]
name = "sea-orm" name = "sea-orm"
version = "2.0.0-rc.7" version = "2.0.0-rc.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ddcd2f974a1e5ecf9fed287dd939d4801d78fea4f68b9870498fa867e12e589" checksum = "d10d776a4086bc1dea156d52f4d52f61617b5d074b4c026304b9d7aef7d0117a"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",
"derive_more",
"futures-util", "futures-util",
"log", "log",
"ouroboros", "ouroboros",
@@ -1106,9 +1128,9 @@ dependencies = [
[[package]] [[package]]
name = "sea-orm-cli" name = "sea-orm-cli"
version = "2.0.0-rc.7" version = "2.0.0-rc.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8b63ef6eedd012d359b947b5bb283549ceae56ea44b92d0da884c3e8d605439" checksum = "bd68cd7fffcfd5262a2d5ae8f425305c0fccaf1354b9dd9159a4d316efff6ca7"
dependencies = [ dependencies = [
"chrono", "chrono",
"glob", "glob",
@@ -1123,9 +1145,9 @@ dependencies = [
[[package]] [[package]]
name = "sea-orm-macros" name = "sea-orm-macros"
version = "2.0.0-rc.7" version = "2.0.0-rc.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3019198b9202bbc96c389d5dfe33f0ba98032ff8ad293fe9c2e11b7c6d992830" checksum = "bd736f392dbe4b5bdbae5b57068c3c206fd3d50c2437c14303e1e2d626def5a8"
dependencies = [ dependencies = [
"heck 0.5.0", "heck 0.5.0",
"proc-macro2", "proc-macro2",
@@ -1137,9 +1159,9 @@ dependencies = [
[[package]] [[package]]
name = "sea-orm-migration" name = "sea-orm-migration"
version = "2.0.0-rc.7" version = "2.0.0-rc.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ed01c2f512034f765fb90ffccdf82af8cd948b327c60559ac55d3fb79a119c" checksum = "f963e814a7a2605f1dc30372301d06150d9b447ca19f2365662121fbd612056d"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"sea-orm", "sea-orm",
@@ -1211,7 +1233,7 @@ dependencies = [
[[package]] [[package]]
name = "seamantic" name = "seamantic"
version = "0.0.5" version = "0.0.7"
dependencies = [ dependencies = [
"sea-orm", "sea-orm",
"sea-orm-migration", "sea-orm-migration",
@@ -1631,6 +1653,12 @@ version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
[[package]]
name = "unicode-xid"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]] [[package]]
name = "untrusted" name = "untrusted"
version = "0.9.0" version = "0.9.0"
+2 -2
View File
@@ -35,8 +35,8 @@ overflow-checks = true
strip = "debuginfo" strip = "debuginfo"
[workspace.dependencies] [workspace.dependencies]
sea-orm = { version = "2.0.0-rc.7", default-features = false } sea-orm = { version = "2.0.0-rc.10", default-features = false }
sea-orm-migration = { version = "2.0.0-rc.7", default-features = false } sea-orm-migration = { version = "2.0.0-rc.10", default-features = false }
serde = { version = "^1", default-features = false } serde = { version = "^1", default-features = false }
serde_test = { version = "^1", default-features = false } serde_test = { version = "^1", default-features = false }
+1
View File
@@ -13,4 +13,5 @@ A library to enhance SeaORM
- example: `cargo run --example=migrations --features=sqlite` - example: `cargo run --example=migrations --features=sqlite`
- fmt: `cargo fmt --check` - fmt: `cargo fmt --check`
- docs: `RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features` - docs: `RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features`
- semver: `cargo semver-checks --all-features`
- publish: `cargo publish --dry-run -p seamantic` - publish: `cargo publish --dry-run -p seamantic`
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "seamantic" name = "seamantic"
version = "0.0.5" version = "0.0.7"
categories = [] categories = []
description = "A library to enhance SeaORM" description = "A library to enhance SeaORM"
+1
View File
@@ -6,6 +6,7 @@ pub use sea_orm;
pub use sea_orm_migration; pub use sea_orm_migration;
pub mod model; pub mod model;
pub mod orm;
pub mod schema; pub mod schema;
/// A macro for defining a Migrator with a custom migration table while /// A macro for defining a Migrator with a custom migration table while
+2 -2
View File
@@ -76,8 +76,8 @@ impl Nullable for Seconds {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use sea_orm::{ use sea_orm::{
ActiveModelBehavior, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EnumIter, ActiveModelBehavior, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EntityTrait,
PrimaryKeyTrait, EnumIter, PrimaryKeyTrait,
}; };
use super::Seconds; use super::Seconds;
+3 -3
View File
@@ -78,7 +78,7 @@ impl<T> Id<T> {
} }
impl<T> fmt::Debug for Id<T> { impl<T> fmt::Debug for Id<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Id") f.debug_struct("Id")
.field("T", &core::any::type_name::<T>()) .field("T", &core::any::type_name::<T>())
.field("id", &self.id) .field("id", &self.id)
@@ -140,8 +140,8 @@ impl<T> Nullable for Id<T> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use sea_orm::{ use sea_orm::{
ActiveModelBehavior, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EnumIter, ActiveModelBehavior, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EntityTrait,
PrimaryKeyTrait, EnumIter, PrimaryKeyTrait,
}; };
use super::Id; use super::Id;
+2 -2
View File
@@ -83,8 +83,8 @@ impl Nullable for PathBytes {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use sea_orm::{ use sea_orm::{
ActiveModelBehavior, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EnumIter, ActiveModelBehavior, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EntityTrait,
PrimaryKeyTrait, EnumIter, PrimaryKeyTrait,
}; };
use super::PathBytes; use super::PathBytes;
+4
View File
@@ -0,0 +1,4 @@
//! Helpers for working with SeaORM
mod upsert;
pub use upsert::UpsertTrait;
+34
View File
@@ -0,0 +1,34 @@
use sea_orm::sea_query::{IntoColumnRef, OnConflict};
use sea_orm::{ActiveModelTrait, EntityTrait, Insert, Iterable};
/// This trait add a method on [Insert] to allow for upsert behavior
pub trait UpsertTrait: private::Sealed {
/// Set ON CONFLICT on primary key to update all other columns
fn on_conflict_upsert(self) -> Self;
}
fn primary_key_iter<A: ActiveModelTrait>()
-> impl Iterator<Item = <A::Entity as EntityTrait>::PrimaryKey> {
<A::Entity as EntityTrait>::PrimaryKey::iter()
}
fn column_iter<A: ActiveModelTrait>() -> impl Iterator<Item = <A::Entity as EntityTrait>::Column> {
<<A as ActiveModelTrait>::Entity as EntityTrait>::Column::iter()
}
impl<A: ActiveModelTrait> UpsertTrait for Insert<A> {
fn on_conflict_upsert(self) -> Self {
self.on_conflict(
OnConflict::columns(primary_key_iter::<A>())
.update_columns(column_iter::<A>().filter(|col| {
!primary_key_iter::<A>().any(|pk| pk.into_column_ref() == col.into_column_ref())
}))
.to_owned(),
)
}
}
mod private {
pub trait Sealed {}
impl<A: ::sea_orm::ActiveModelTrait> Sealed for ::sea_orm::Insert<A> {}
}