Skip to content

[5.x]: Entry query by generated field 'approved' returns empty #17855

@chasegiunta

Description

@chasegiunta

What happened?

Description

When querying for entries with an approved generated field, the query will always return zero results. approved is a "binary" (stringified, of course) generated field, and accessing it on the elements themselves individually return the correct results.

When entries querying by this binary field, either by .approved('') or .approved('1') the results will always be [];

Changing the field handle from past tense to a present (approve) will fix the issue. Should approved be a reserved handle?

Steps to reproduce

  1. Create entry type with approved field handle which returns a "binary"
  2. Ensure you have multiple entries which have this generated field applied.
  3. Access a single entry, ideally with a truthy value, and ensure that approved returns "1"
  4. Query craft.entries.approved('').all() or craft.entries.approved('1').all() and observe [] response.
  5. Change generated field handle to approve.
  6. Repeat both 3 & 4 with adjusted field handle.
  7. Observe correctly returned results.

Expected behavior

Returns correct results.

Actual behavior

When entries querying by this binary field, either by .approved('') or .approved('1') the results will always be [];

Craft CMS version

5.8.17

PHP version

8.4

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions