@@ -186,9 +186,14 @@ class MysqlConnector extends AdminForthBaseConnector implements IAdminForthDataS
186186 return `${ field } ${ operator } ${ placeholder } ` ;
187187 }
188188
189+ // filter is a single insecure raw sql
190+ if ( ( filter as IAdminForthSingleFilter ) . insecureRawSQL ) {
191+ return ( filter as IAdminForthSingleFilter ) . insecureRawSQL ;
192+ }
193+
189194 // filter is a AndOr filter
190195 return ( filter as IAdminForthAndOrFilter ) . subFilters . map ( ( f ) => {
191- if ( ( f as IAdminForthSingleFilter ) . field ) {
196+ if ( ( f as IAdminForthSingleFilter ) . field || ( f as IAdminForthSingleFilter ) . insecureRawSQL ) {
192197 // subFilter is a Single filter
193198 return this . getFilterString ( f ) ;
194199 }
@@ -209,6 +214,11 @@ class MysqlConnector extends AdminForthBaseConnector implements IAdminForthDataS
209214 }
210215 }
211216
217+ // filter is a Single insecure raw sql
218+ if ( ( filter as IAdminForthSingleFilter ) . insecureRawSQL ) {
219+ return [ ] ;
220+ }
221+
212222 // filter is a AndOrFilter
213223 return ( filter as IAdminForthAndOrFilter ) . subFilters . reduce ( ( params : any [ ] , f : IAdminForthSingleFilter | IAdminForthAndOrFilter ) => {
214224 return params . concat ( this . getFilterParams ( f ) ) ;
@@ -252,6 +262,11 @@ class MysqlConnector extends AdminForthBaseConnector implements IAdminForthDataS
252262
253263 async getCount ( { resource, filters } : { resource : AdminForthResource ; filters : IAdminForthAndOrFilter ; } ) : Promise < number > {
254264 const tableName = resource . table ;
265+ // validate and normalize in case this method is called from dataAPI
266+ const filterValidation = this . validateAndNormalizeFilters ( filters , resource ) ;
267+ if ( ! filterValidation . ok ) {
268+ throw new Error ( filterValidation . error ) ;
269+ }
255270 const { sql : where , values : filterValues } = this . whereClauseAndValues ( filters ) ;
256271 const q = `SELECT COUNT(*) FROM ${ tableName } ${ where } ` ;
257272 if ( process . env . HEAVY_DEBUG_QUERY ) {
0 commit comments