From d2d16d42d3a54a5a6e220b103eff567564faf382 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 16 Feb 2021 16:15:51 +0100 Subject: [PATCH] Add more flexibility to conservation policy update --- src/data/base_request_handler.rs | 2 +- src/helpers/database.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/data/base_request_handler.rs b/src/data/base_request_handler.rs index daa0f4d..70d7eb9 100644 --- a/src/data/base_request_handler.rs +++ b/src/data/base_request_handler.rs @@ -357,7 +357,7 @@ pub trait BaseRequestHandler { } fn post_positive_u64_opt(&mut self, name: &str) -> Res> { - match self.post_u64(name)? { + match self.post_u64_opt(name, 0)? { 0 => Ok(None), val => Ok(Some(val)) } diff --git a/src/helpers/database.rs b/src/helpers/database.rs index 4e8e3bd..032cbae 100644 --- a/src/helpers/database.rs +++ b/src/helpers/database.rs @@ -944,6 +944,13 @@ pub fn update(u: UpdateInfo) -> ResultBoxError<()> { query_sql = format!("{} {} WHERE {}", query_sql, updates, conditions); + if conf().database.log_all_queries { + watcher::ExecDatabaseQuery::new( + &query_sql, + &values.iter().map(|f| mysql::Value::from(f)).collect(), + ).display(); + } + get_connection()?.exec_drop( query_sql, values,