You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
azoom-dang-van-hoi
changed the title
Query Discrepancy with Selected Fields
Query Discrepancy with Selected Fields and InjectForRead Behavior in Relation Models
May 9, 2024
azoom-dang-van-hoi
changed the title
Query Discrepancy with Selected Fields and InjectForRead Behavior in Relation Models
[Bug] Query Discrepancy with Selected Fields and InjectForRead Behavior in Relation Models
May 9, 2024
azoom-dang-van-hoi
changed the title
[Bug] Query Discrepancy with Selected Fields and InjectForRead Behavior in Relation Models
[BUG] Query Discrepancy with Selected Fields and InjectForRead Behavior in Relation Models
May 9, 2024
azoom-dang-van-hoi
changed the title
[BUG] Query Discrepancy with Selected Fields and InjectForRead Behavior in Relation Models
[BUG] Query Discrepancy with Selected Relation Fields
May 9, 2024
Thanks for reporting this @azoom-dang-van-hoi ! Yes, there seems to be a problem when handling relation fields. I'll make a fix and include it in the upcoming 2.1.0 release.
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.
Environment:
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.
The text was updated successfully, but these errors were encountered: