From 718b1c14617d126e42de2922c8a247444049e351 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 29 Jan 2024 18:10:38 -0500 Subject: [PATCH] Switch to failable coversion of numeric types to usize for SQL values --- packages/fuel-indexer-plugin/src/find.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/fuel-indexer-plugin/src/find.rs b/packages/fuel-indexer-plugin/src/find.rs index 51d0ef784..e69a399e2 100644 --- a/packages/fuel-indexer-plugin/src/find.rs +++ b/packages/fuel-indexer-plugin/src/find.rs @@ -306,7 +306,11 @@ impl ToSQLValue for UID { impl ToSQLValue for BlockHeight { fn to_sql_value(self) -> sql::Value { - sqlparser::test_utils::number(&self.to_string()) + sqlparser::test_utils::number( + &usize::try_from(u32::from(self)) + .expect("Could not convert BlockHeight into SQL value") + .to_string(), + ) } } @@ -336,7 +340,11 @@ macro_rules! impl_number_to_sql_value { ($T:ident) => { impl ToSQLValue for fuel_indexer_types::scalar::$T { fn to_sql_value(self) -> sql::Value { - sqlparser::test_utils::number(&self.to_string()) + sqlparser::test_utils::number( + &usize::try_from(self) + .expect("Could not convert scalar into usize") + .to_string(), + ) } } };