@@ -4,8 +4,8 @@ use async_graphql::dynamic::{InputObject, InputValue, ObjectAccessor, TypeRef};
44use sea_orm:: { ColumnTrait , ColumnType , Condition , EntityTrait , ExprTrait } ;
55
66use crate :: {
7- prepare_enumeration_condition, ActiveEnumFilterInputBuilder , BuilderContext ,
8- EntityObjectBuilder , SeaResult , TypesMapConfig , TypesMapHelper ,
7+ prepare_enumeration_condition, ActiveEnumFilterInputBuilder , BuilderContext , EntityColumnId ,
8+ EntityObjectBuilder , SeaResult , SeaographyError , TypesMapConfig , TypesMapHelper ,
99} ;
1010
1111type FnFilterCondition =
@@ -14,9 +14,9 @@ type FnFilterCondition =
1414/// The configuration for FilterTypesMapHelper
1515pub struct FilterTypesMapConfig {
1616 /// used to map entity_name.column_name to a custom filter type
17- pub overwrites : BTreeMap < String , Option < FilterType > > ,
17+ pub overwrites : BTreeMap < EntityColumnId , Option < FilterType > > ,
1818 /// used to map entity_name.column_name to a custom condition function
19- pub condition_functions : BTreeMap < String , FnFilterCondition > ,
19+ pub condition_functions : BTreeMap < EntityColumnId , FnFilterCondition > ,
2020
2121 // basic filters
2222 pub string_filter_info : FilterInfo ,
@@ -235,20 +235,9 @@ impl FilterTypesMapHelper {
235235 where
236236 T : EntityTrait ,
237237 {
238- let entity_object_builder = EntityObjectBuilder {
239- context : self . context ,
240- } ;
241-
242- let entity_name = entity_object_builder. type_name :: < T > ( ) ;
243- let column_name = entity_object_builder. column_name :: < T > ( column) ;
238+ let entity_column_id = EntityColumnId :: of :: < T > ( column) ;
244239
245- // used to honor overwrites
246- if let Some ( ty) = self
247- . context
248- . filter_types
249- . overwrites
250- . get ( & format ! ( "{entity_name}.{column_name}" ) )
251- {
240+ if let Some ( ty) = self . context . filter_types . overwrites . get ( & entity_column_id) {
252241 return ty. clone ( ) ;
253242 }
254243
@@ -572,23 +561,19 @@ impl FilterTypesMapHelper {
572561 return prepare_enumeration_condition :: < T > ( filter, column, condition)
573562 }
574563 FilterType :: Custom ( _) => {
575- let entity_object_builder = EntityObjectBuilder {
576- context : self . context ,
577- } ;
578-
579- let entity_name = entity_object_builder. type_name :: < T > ( ) ;
580- let column_name = entity_object_builder. column_name :: < T > ( column) ;
564+ let entity_column_id = EntityColumnId :: of :: < T > ( column) ;
581565
582566 if let Some ( filter_condition_fn) = self
583567 . context
584568 . filter_types
585569 . condition_functions
586- . get ( & format ! ( "{entity_name}.{column_name}" ) )
570+ . get ( & entity_column_id )
587571 {
588572 return filter_condition_fn ( condition, filter) ;
589573 } else {
590- // FIXME: add log warning to console
591- return Ok ( condition) ;
574+ return Err ( SeaographyError :: CustomFilterError (
575+ entity_column_id. to_string ( ) ,
576+ ) ) ;
592577 }
593578 }
594579 FilterType :: Array ( Some ( filter_type) ) => match * filter_type {
0 commit comments