File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
adminforth/dataConnectors Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 7
7
8
8
9
9
import { suggestIfTypo } from "../modules/utils.js" ;
10
- import { AdminForthFilterOperators , AdminForthSortDirections } from "../types/Common.js" ;
10
+ import { AdminForthDataTypes , AdminForthFilterOperators , AdminForthSortDirections } from "../types/Common.js" ;
11
+ import { randomUUID } from "crypto" ;
11
12
12
13
13
14
export default class AdminForthBaseConnector implements IAdminForthDataSourceConnectorBase {
@@ -121,8 +122,14 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
121
122
return { ok : false , error : `Value for operator '${ filters . operator } ' should be an array, in filter object: ${ JSON . stringify ( filters ) } ` } ;
122
123
}
123
124
if ( filters . value . length === 0 ) {
124
- // nonsense
125
- return { ok : false , error : `Filter has IN operator but empty value: ${ JSON . stringify ( filters ) } ` } ;
125
+ // nonsense, and some databases might not accept IN []
126
+ const colType = resource . dataSourceColumns . find ( ( col ) => col . name == ( filters as IAdminForthSingleFilter ) . field ) ?. type ;
127
+ if ( colType === AdminForthDataTypes . STRING || colType === AdminForthDataTypes . TEXT ) {
128
+ filters . value = [ randomUUID ( ) ] ;
129
+ return { ok : true , error : `` } ;
130
+ } else {
131
+ return { ok : false , error : `Value for operator '${ filters . operator } ' should not be empty array, in filter object: ${ JSON . stringify ( filters ) } ` } ;
132
+ }
126
133
}
127
134
filters . value = filters . value . map ( ( val : any ) => this . setFieldValue ( fieldObj , val ) ) ;
128
135
} else {
You can’t perform that action at this time.
0 commit comments