cms icon indicating copy to clipboard operation
cms copied to clipboard

[5.x]: issue with Dropdown and `:empty:`

Open Megafry opened this issue 2 months ago • 1 comments

What happened?

Description

Query with :empty: don't work as expected with CraftCMS 5.

Steps to reproduce

  1. Create a dropdown with following values: Image
  2. Add the field to a section, ex: users
  3. Create 2 entries
  4. Set all to admin
  5. run this query:
{% set users = craft
	.entries()
	.section('users')
	.userRole(['not', ':empty:'])
	.all()
%}

{% dd users | map( e => {
	title: e.title,
	userRole:e.userRole.value
}) %}

This will find all 2 entries set on to none and re run the query, the result is still 2

update the query to .userRole(['not', '']), now the result is only one.

Expected behavior

:empty: should also work if the value is an empty string

Actual behavior

:empty: and "" don't return the same result

Craft CMS version

5.8.21

PHP version

8.2.28

Operating system and version

No response

Database type and version

MySQL 8.0.40

Image driver and version

No response

Installed plugins and versions

No response

Megafry avatar Dec 09 '25 17:12 Megafry

CMS-1719

linear[bot] avatar Dec 09 '25 17:12 linear[bot]

Thanks for reporting that! Fixed for the next release.

brandonkelly avatar Dec 10 '25 23:12 brandonkelly