properly handling patch updates
Some checks failed
CI / Clippy (push) Failing after 3m6s
CI / Rustfmt (push) Failing after 3m9s
CI / Cargo Audit & Deny (push) Successful in 5m2s
CI / Tests (push) Successful in 8m15s
CI / Security Blocking Checks (push) Successful in 10s
CI / Web Advisory Checks (push) Successful in 1m4s
CI / Web Blocking Checks (push) Failing after 4m52s
Publish Images And Chart / Resolve Publish Metadata (push) Successful in 2s
CI / Security Advisory Checks (push) Successful in 1m31s
Publish Images And Chart / Publish init-user (push) Failing after 30s
Publish Images And Chart / Publish init-packs (push) Failing after 1m41s
Publish Images And Chart / Publish migrations (push) Failing after 10s
Publish Images And Chart / Publish web (push) Failing after 11s
Publish Images And Chart / Publish sensor (push) Failing after 32s
Publish Images And Chart / Publish worker (push) Failing after 11s
Publish Images And Chart / Publish executor (push) Failing after 11s
Publish Images And Chart / Publish notifier (push) Failing after 9s
Publish Images And Chart / Publish api (push) Failing after 31s
Publish Images And Chart / Publish Helm Chart (push) Has been skipped
Some checks failed
CI / Clippy (push) Failing after 3m6s
CI / Rustfmt (push) Failing after 3m9s
CI / Cargo Audit & Deny (push) Successful in 5m2s
CI / Tests (push) Successful in 8m15s
CI / Security Blocking Checks (push) Successful in 10s
CI / Web Advisory Checks (push) Successful in 1m4s
CI / Web Blocking Checks (push) Failing after 4m52s
Publish Images And Chart / Resolve Publish Metadata (push) Successful in 2s
CI / Security Advisory Checks (push) Successful in 1m31s
Publish Images And Chart / Publish init-user (push) Failing after 30s
Publish Images And Chart / Publish init-packs (push) Failing after 1m41s
Publish Images And Chart / Publish migrations (push) Failing after 10s
Publish Images And Chart / Publish web (push) Failing after 11s
Publish Images And Chart / Publish sensor (push) Failing after 32s
Publish Images And Chart / Publish worker (push) Failing after 11s
Publish Images And Chart / Publish executor (push) Failing after 11s
Publish Images And Chart / Publish notifier (push) Failing after 9s
Publish Images And Chart / Publish api (push) Failing after 31s
Publish Images And Chart / Publish Helm Chart (push) Has been skipped
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::models::{
|
||||
use crate::Result;
|
||||
use sqlx::{Executor, Postgres, QueryBuilder};
|
||||
|
||||
use super::{Create, Delete, FindById, FindByRef, List, Repository, Update};
|
||||
use super::{Create, Delete, FindById, FindByRef, List, Patch, Repository, Update};
|
||||
|
||||
// ============================================================================
|
||||
// ArtifactRepository
|
||||
@@ -48,12 +48,12 @@ pub struct UpdateArtifactInput {
|
||||
pub visibility: Option<ArtifactVisibility>,
|
||||
pub retention_policy: Option<RetentionPolicyType>,
|
||||
pub retention_limit: Option<i32>,
|
||||
pub name: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub content_type: Option<String>,
|
||||
pub name: Option<Patch<String>>,
|
||||
pub description: Option<Patch<String>>,
|
||||
pub content_type: Option<Patch<String>>,
|
||||
pub size_bytes: Option<i64>,
|
||||
pub execution: Option<Option<i64>>,
|
||||
pub data: Option<serde_json::Value>,
|
||||
pub execution: Option<Patch<i64>>,
|
||||
pub data: Option<Patch<serde_json::Value>>,
|
||||
}
|
||||
|
||||
/// Filters for searching artifacts
|
||||
@@ -186,20 +186,62 @@ impl Update for ArtifactRepository {
|
||||
push_field!(input.visibility, "visibility");
|
||||
push_field!(input.retention_policy, "retention_policy");
|
||||
push_field!(input.retention_limit, "retention_limit");
|
||||
push_field!(&input.name, "name");
|
||||
push_field!(&input.description, "description");
|
||||
push_field!(&input.content_type, "content_type");
|
||||
if let Some(name) = &input.name {
|
||||
if has_updates {
|
||||
query.push(", ");
|
||||
}
|
||||
query.push("name = ");
|
||||
match name {
|
||||
Patch::Set(value) => query.push_bind(value),
|
||||
Patch::Clear => query.push_bind(Option::<String>::None),
|
||||
};
|
||||
has_updates = true;
|
||||
}
|
||||
if let Some(description) = &input.description {
|
||||
if has_updates {
|
||||
query.push(", ");
|
||||
}
|
||||
query.push("description = ");
|
||||
match description {
|
||||
Patch::Set(value) => query.push_bind(value),
|
||||
Patch::Clear => query.push_bind(Option::<String>::None),
|
||||
};
|
||||
has_updates = true;
|
||||
}
|
||||
if let Some(content_type) = &input.content_type {
|
||||
if has_updates {
|
||||
query.push(", ");
|
||||
}
|
||||
query.push("content_type = ");
|
||||
match content_type {
|
||||
Patch::Set(value) => query.push_bind(value),
|
||||
Patch::Clear => query.push_bind(Option::<String>::None),
|
||||
};
|
||||
has_updates = true;
|
||||
}
|
||||
push_field!(input.size_bytes, "size_bytes");
|
||||
// execution is Option<Option<i64>> — outer Option = "was field provided?",
|
||||
// inner Option = nullable column value
|
||||
if let Some(exec_val) = input.execution {
|
||||
if has_updates {
|
||||
query.push(", ");
|
||||
}
|
||||
query.push("execution = ").push_bind(exec_val);
|
||||
query.push("execution = ");
|
||||
match exec_val {
|
||||
Patch::Set(value) => query.push_bind(value),
|
||||
Patch::Clear => query.push_bind(Option::<i64>::None),
|
||||
};
|
||||
has_updates = true;
|
||||
}
|
||||
if let Some(data) = &input.data {
|
||||
if has_updates {
|
||||
query.push(", ");
|
||||
}
|
||||
query.push("data = ");
|
||||
match data {
|
||||
Patch::Set(value) => query.push_bind(value),
|
||||
Patch::Clear => query.push_bind(Option::<serde_json::Value>::None),
|
||||
};
|
||||
has_updates = true;
|
||||
}
|
||||
push_field!(&input.data, "data");
|
||||
|
||||
if !has_updates {
|
||||
return Self::get_by_id(executor, id).await;
|
||||
|
||||
Reference in New Issue
Block a user