Skip to content

Commit be617e7

Browse files
committed
fix: fix pg sqlite inconsistent types
1 parent 8cb49e4 commit be617e7

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

deny.toml

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ ignore = [
7373
# Advisory: https://rustsec.org/advisories/RUSTSEC-2024-0370
7474
# 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.
7575
"RUSTSEC-2024-0370",
76+
# instant's maintainer no longer maintained, use web-time instead
77+
"RUSTSEC-2024-0384",
7678
#"RUSTSEC-0000-0000",
7779
#{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" },
7880
#"[email protected]", # you can also ignore yanked crate versions if you wish

util/rich-indexer/src/indexer/remove.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,19 @@ async fn script_exists_in_output(
219219
.await
220220
.map_err(|err| Error::DB(err.to_string()))?;
221221

222-
if row_lock.get::<i64, _>(0) == 1 {
223-
return Ok(true);
222+
// pg type is BOOLEAN
223+
match row_lock.try_get::<bool, _>(0) {
224+
Ok(r) => {
225+
if r {
226+
return Ok(true);
227+
}
228+
}
229+
Err(_) => {
230+
// sqlite type is BIGINT
231+
if row_lock.get::<i64, _>(0) == 1 {
232+
return Ok(true);
233+
}
234+
}
224235
}
225236

226237
let row_type = sqlx::query(
@@ -237,7 +248,12 @@ async fn script_exists_in_output(
237248
.await
238249
.map_err(|err| Error::DB(err.to_string()))?;
239250

240-
Ok(row_type.get::<i64, _>(0) == 1)
251+
// pg type is BOOLEAN
252+
match row_lock.try_get::<bool, _>(0) {
253+
Ok(r) => Ok(r),
254+
// sqlite type is BIGINT
255+
Err(_) => Ok(row_type.get::<i64, _>(0) == 1),
256+
}
241257
}
242258

243259
fn sqlx_param_placeholders(range: std::ops::Range<usize>) -> Result<Vec<String>, Error> {

0 commit comments

Comments
 (0)