Skip to content
Snippets Groups Projects
Commit 2cd0a861 authored by Nicolas80's avatar Nicolas80
Browse files

* Kind of ugly; but needed to adapt fn find_direct_children_accounts to also...

* 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
parent 54e82c1b
No related branches found
No related tags found
1 merge request!43Draft: Resolve "Error: Base 58 requirement is violated"
Pipeline #40213 passed
...@@ -6,7 +6,6 @@ use sea_orm::entity::prelude::*; ...@@ -6,7 +6,6 @@ use sea_orm::entity::prelude::*;
use sea_orm::prelude::async_trait::async_trait; use sea_orm::prelude::async_trait::async_trait;
use sea_orm::prelude::StringLen; use sea_orm::prelude::StringLen;
use sea_orm::ActiveValue::Set; use sea_orm::ActiveValue::Set;
use sea_orm::PaginatorTrait;
use sea_orm::QueryFilter; use sea_orm::QueryFilter;
use sea_orm::TryGetError; use sea_orm::TryGetError;
use sea_orm::{ use sea_orm::{
...@@ -14,6 +13,7 @@ use sea_orm::{ ...@@ -14,6 +13,7 @@ use sea_orm::{
ModelTrait, QueryOrder, RelationDef, RelationTrait, TryFromU64, ModelTrait, QueryOrder, RelationDef, RelationTrait, TryFromU64,
}; };
use sea_orm::{ActiveModelTrait, ConnectionTrait, PrimaryKeyTrait}; use sea_orm::{ActiveModelTrait, ConnectionTrait, PrimaryKeyTrait};
use sea_orm::{Condition, PaginatorTrait};
use sea_orm::{DeriveActiveEnum, EntityTrait}; use sea_orm::{DeriveActiveEnum, EntityTrait};
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
...@@ -768,6 +768,9 @@ where ...@@ -768,6 +768,9 @@ where
Ok(Some(base_parent_account)) 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>( async fn find_direct_children_accounts<C>(
db: &C, db: &C,
current_account: &Model, current_account: &Model,
...@@ -776,7 +779,11 @@ where ...@@ -776,7 +779,11 @@ where
C: ConnectionTrait, C: ConnectionTrait,
{ {
Entity::find() 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) .order_by_asc(Column::Address)
.all(db) .all(db)
.await .await
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment