1
- import { PlainObject , isObject } from "deverything" ;
1
+ import { PlainObject , isObject , setObjectPath } from "deverything" ;
2
2
import { GetListRequest , GetManyReferenceRequest } from "./Http" ;
3
3
import { isNotField } from "./lib/isNotField" ;
4
- import setObjectProp from "set-value" ;
5
4
6
5
const prismaOperators = [
7
6
"contains" ,
@@ -42,7 +41,7 @@ export const extractWhere = (
42
41
const hasOperator = prismaOperators . some ( ( operator ) => {
43
42
if ( colName . endsWith ( `_${ operator } ` ) ) {
44
43
[ colName ] = colName . split ( `_${ operator } ` ) ;
45
- setObjectProp ( where , colName , { [ operator ] : value } , { merge : true } ) ;
44
+ setObjectPath ( where , colName , { [ operator ] : value } ) ;
46
45
return true ;
47
46
}
48
47
} ) ;
@@ -55,9 +54,10 @@ export const extractWhere = (
55
54
colName . endsWith ( `_eq` )
56
55
) {
57
56
const [ cleanColName ] = colName . split ( / ( _ e n u m | _ e x a c t | _ e q ) $ / ) ;
58
- setObjectProp ( where , cleanColName , value ) ;
57
+ setObjectPath ( where , cleanColName , value ) ;
59
58
} else if ( colName === "q" ) {
60
- // i.e. full-text search, not sure why this has come as a column name?
59
+ // i.e. when filterToQuery is not set on AutoCompleteInput, but we don't know all the fields to search against
60
+ console . info ( "Filter not handled:" , colName , value ) ;
61
61
} else if (
62
62
colName === "id" ||
63
63
colName === "uuid" ||
@@ -68,11 +68,11 @@ export const extractWhere = (
68
68
typeof value === "boolean" ||
69
69
value === null // if the client sends null, than that is also a valid (exact) filter!
70
70
) {
71
- setObjectProp ( where , colName , value ) ;
71
+ setObjectPath ( where , colName , value ) ;
72
72
} else if ( Array . isArray ( value ) ) {
73
- setObjectProp ( where , colName , { in : value } ) ;
73
+ setObjectPath ( where , colName , { in : value } ) ;
74
74
} else if ( typeof value === "string" ) {
75
- setObjectProp ( where , colName , {
75
+ setObjectPath ( where , colName , {
76
76
contains : value ,
77
77
mode : options ?. filterMode ,
78
78
} ) ;
@@ -81,7 +81,7 @@ export const extractWhere = (
81
81
// https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filter-on-object-property
82
82
const { path, equals } = formatPrismaPostgresNestedJsonFilter ( value ) ;
83
83
if ( path . length && equals ) {
84
- setObjectProp ( where , colName , { path, equals } ) ;
84
+ setObjectPath ( where , colName , { path, equals } ) ;
85
85
}
86
86
} else {
87
87
console . info ( "Filter not handled:" , colName , value ) ;
0 commit comments