File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
Deveel.Filter.Model.Web/Filters
Deveel.Filter.Model/Filters
test/Deveel.Filter.Model.Web.XUnit/Filters Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -146,8 +146,12 @@ public virtual IFilter BuildFilter() {
146146 throw new FilterException ( "The model is invalid - no type was set" ) ;
147147
148148 switch ( filterType ) {
149- case FilterType . Constant :
150- return new ConstantFilter ( value ) ;
149+ case FilterType . Constant : {
150+ if ( value is JsonElement json )
151+ value = JsonElementUtil . InferValue ( json ) ;
152+
153+ return new ConstantFilter ( value ) ;
154+ }
151155 case FilterType . Not :
152156 if ( not == null )
153157 throw new FilterException ( "The model is invalid - no unary filter was set" ) ;
File renamed without changes.
Original file line number Diff line number Diff line change @@ -105,6 +105,20 @@ public static void BuildConstant() {
105105 Assert . Equal ( 42 , constant . Value ) ;
106106 }
107107
108+ [ Fact ]
109+ public static void BuildConstantWithJson ( ) {
110+ var filter = new FilterModel {
111+ Value = JsonDocument . Parse ( "42" ) . RootElement
112+ } ;
113+
114+ var result = filter . BuildFilter ( ) ;
115+ Assert . NotNull ( result ) ;
116+ Assert . IsType < ConstantFilter > ( result ) ;
117+ Assert . Equal ( FilterType . Constant , result . FilterType ) ;
118+ var constant = ( ConstantFilter ) result ;
119+ Assert . Equal ( 42 , constant . Value ) ;
120+ }
121+
108122 [ Fact ]
109123 public static void BuildFunction ( ) {
110124 var function = new FilterModel {
You can’t perform that action at this time.
0 commit comments