Ignore Empty Conditions

Override Prisma's default behavior when the OR block is empty.

Project Toolchain Usage

This feature makes use of these Project Toolchain APIs: Middleware, Extensions. Because of this usage, it defines the following modules:

ignoreEmptyConditions

This module defines the following middleware and extensions identifiers that can be imported via Project Toolchain, along with their descriptions:

  • removeEmptyOrBlock - Remove empty OR blocks from queries.

To enable this optional feature, add the ignoreEmptyConditions element to your optionalFeatures array, then use the generated middleware or extension inside of your code.

Feature Effect

Query Input

For this example, we'll pass the following input to an operation on a model:

Test Input
{
    where: {
        id: 2,
        OR: [],
        posts: {
            every: {
                OR: [{ id: 2 }, { id: 3 }]
            }
        }
    }
}

Query Result

The input above will be manipulated and Prisma will receive this input:

Test Output
{
    where: {
        id: 2,
        posts: {
            every: {
                OR: [{ id: 2 }, { id: 3 }]
            }
        }
    }
}

Last updated