Closed
Description
Description and expected behavior
When querying data with ZenStack and selecting fields with a value of false or undefined within relation models, ZenStack includes these fields in the query results, contrary to the expected behavior observed with Prisma. Prisma correctly excludes fields with these values from the returned data.
// Query with ZenStack (incorrect behavior)
const data = await enhanced.user.findFirst({
select: {
id: true,
name: true,
profile: false // This field should not be included in the result
}
})
// Actual Result
{
id: 1,
name: 'John Doe',
profile: {
id: 1,
}
}
// Expected result (observed with Prisma)
{
id: 1,
name: 'John Doe'
}
Environment:
- ZenStack version: 1.6.0
- Prisma version: 5.4.2
- Database type: Mysql
Additional context
The bug was identified within the code responsible for the injectForRead check. The automatic addition of the where clause to the field causes the extra data to be retrieved during the get operation.
I suggest filtering out fields with values of false or undefined in the select option before executing the query.