From be617e74d731e1e67012c5998a078ba62e10e003 Mon Sep 17 00:00:00 2001 From: driftluo Date: Tue, 12 Nov 2024 22:50:11 +0800 Subject: [PATCH] fix: fix pg sqlite inconsistent types --- deny.toml | 2 ++ util/rich-indexer/src/indexer/remove.rs | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/deny.toml b/deny.toml index 6965c57f0b..09466e1a7f 100644 --- a/deny.toml +++ b/deny.toml @@ -73,6 +73,8 @@ ignore = [ # Advisory: https://rustsec.org/advisories/RUSTSEC-2024-0370 # proc-macro-error's maintainer seems to be unreachable, with no commits for 2 years, no releases pushed for 4 years, and no activity on the GitLab repo or response to email. "RUSTSEC-2024-0370", + # instant's maintainer no longer maintained, use web-time instead + "RUSTSEC-2024-0384", #"RUSTSEC-0000-0000", #{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" }, #"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish diff --git a/util/rich-indexer/src/indexer/remove.rs b/util/rich-indexer/src/indexer/remove.rs index 5b4d2266d1..740634d179 100644 --- a/util/rich-indexer/src/indexer/remove.rs +++ b/util/rich-indexer/src/indexer/remove.rs @@ -219,8 +219,19 @@ async fn script_exists_in_output( .await .map_err(|err| Error::DB(err.to_string()))?; - if row_lock.get::(0) == 1 { - return Ok(true); + // pg type is BOOLEAN + match row_lock.try_get::(0) { + Ok(r) => { + if r { + return Ok(true); + } + } + Err(_) => { + // sqlite type is BIGINT + if row_lock.get::(0) == 1 { + return Ok(true); + } + } } let row_type = sqlx::query( @@ -237,7 +248,12 @@ async fn script_exists_in_output( .await .map_err(|err| Error::DB(err.to_string()))?; - Ok(row_type.get::(0) == 1) + // pg type is BOOLEAN + match row_lock.try_get::(0) { + Ok(r) => Ok(r), + // sqlite type is BIGINT + Err(_) => Ok(row_type.get::(0) == 1), + } } fn sqlx_param_placeholders(range: std::ops::Range) -> Result, Error> {