I try to trace code, and finally find the issue would be here. When query parameter is object type, function makeVisitor uses specialSubFields ['equals', 'set'] to handle it, which does not contain not operator.
const makeVisitor = (
models: DMMFModels,
visitor: TargetFieldVisitorFn,
specialSubFields: string[],
debug: Debugger
) =>
function visitNode(state: VisitorState, { key, type, node, path }: Item) {
const model = models[state.currentModel]
if (!model || !key) {
return state
}
if (type === 'string' && key in model.fields) {
...
}
// Special cases: {field}.set for updates, {field}.equals for queries
for (const specialSubField of specialSubFields) {
if (
type === 'object' &&
key in model.fields &&
typeof (node as any)?.[specialSubField] === 'string'
) {
const value: string = (node as any)[specialSubField]
const targetField: TargetField = {
field: key,
model: state.currentModel,
fieldConfig: model.fields[key],
path: [...path, specialSubField].join('.'),
value
}
debug('Visiting %O', targetField)
visitor(targetField)
return state
}
}
...
return state
}
export function visitInputTargetFields<
Models extends string,
Actions extends string
>(
params: MiddlewareParams<Models, Actions>,
models: DMMFModels,
visitor: TargetFieldVisitorFn
) {
traverseTree(
params.args,
makeVisitor(models, visitor, ['equals', 'set'], debug.encryption), // <---- here
{
currentModel: params.model!
}
)
}
Solve
Should add other filters like not into specialSubField?
This is my prisma schema, and for each patient, they have 0 - N cases.
If I query entries with empty caseNumber, it works correctly. However, when I query entries with non-empty caseNumber, it does not work.
I still get empty chartNumber in the response
I try to trace code, and finally find the issue would be here. When query parameter is object type, function
makeVisitor
uses specialSubFields ['equals', 'set'] to handle it, which does not containnot
operator.Solve
Should add other filters like
not
into specialSubField?