From 2cd0a861751fe9336ad03e847cc43dedf593e0eb Mon Sep 17 00:00:00 2001 From: Nicolas80 <nicolas.pmail@protonmail.com> Date: Wed, 26 Mar 2025 10:50:54 +0100 Subject: [PATCH] * Kind of ugly; but needed to adapt fn find_direct_children_accounts to also match lines that have extra double quotes inside the parent column ** For that; since it seems sea-orm does the `eq` part on string values; the only way I could find is to allow any of those checks *** original "parent" eq address as DbAccountId (sea-orm converts address' DbAccountId to a clean string that doesn't have the extra double quotes) *** extra "parent" eq `format!("\"{}\"",current_account.address.to_string())` for the cases where the DB got incorrect values --- src/entities/vault_account.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/entities/vault_account.rs b/src/entities/vault_account.rs index 4c219e6..80586cf 100644 --- a/src/entities/vault_account.rs +++ b/src/entities/vault_account.rs @@ -6,7 +6,6 @@ use sea_orm::entity::prelude::*; use sea_orm::prelude::async_trait::async_trait; use sea_orm::prelude::StringLen; use sea_orm::ActiveValue::Set; -use sea_orm::PaginatorTrait; use sea_orm::QueryFilter; use sea_orm::TryGetError; use sea_orm::{ @@ -14,6 +13,7 @@ use sea_orm::{ ModelTrait, QueryOrder, RelationDef, RelationTrait, TryFromU64, }; use sea_orm::{ActiveModelTrait, ConnectionTrait, PrimaryKeyTrait}; +use sea_orm::{Condition, PaginatorTrait}; use sea_orm::{DeriveActiveEnum, EntityTrait}; use std::cell::RefCell; use std::collections::HashMap; @@ -768,6 +768,9 @@ where Ok(Some(base_parent_account)) } +/// Fetches all the children accounts of current_account +/// +/// Due to a hard to reproduce issue (!48) had to adapt the filter on Parent to also match if the Parent value has those extra double quotes around the value async fn find_direct_children_accounts<C>( db: &C, current_account: &Model, @@ -776,7 +779,11 @@ where C: ConnectionTrait, { Entity::find() - .filter(Column::Parent.eq(current_account.address.clone())) + .filter( + Condition::any() + .add(Column::Parent.eq(current_account.address.clone())) + .add(Column::Parent.eq(format!("\"{}\"",current_account.address.to_string()))), + ) .order_by_asc(Column::Address) .all(db) .await -- GitLab