craftcms / craftcms/cms

[5.x]: Issue querying against checkbox fields

Open
#18,127 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

What happened?
Description

When trying to narrow a query via a checkbox field alone. Combined with other fields it seems to be okay.

{% extends '_/layouts/default' %}

{% block content %}
    {% set test = craft.entries().section('solutions').gender('male').all() %}
    {% dd test %}
{% endblock %}
Image
Steps to reproduce
  1. Create a section
  2. Add a checkbox field to it
  3. Create a few test entries with various values on the checkboxes
  4. Create simple template and try to query the section with a value passed to the checkbox field in the query
  5. It should throw an exception
Expected behavior

It should execute the query absolutely fine

Actual behavior

Throws am exception

Craft CMS version

5.8.20

PHP version

8.3.23

Operating system and version

Linux 6.17.8-orbstack-00308-g8f9c941121b1

Database type and version

MySQL 8.0.40

Image driver and version

Imagick 3.8.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

"craftcms/feed-me": "6.11.0",
"craftcms/postmark": "^3.1",
"nystudio107/craft-retour": "5.0.12",
"nystudio107/craft-seomatic": "5.1.19",
"nystudio107/craft-vite": "5.0.1",
"putyourlightson/craft-blitz": "5.12.5",
"putyourlightson/craft-sprig": "3.7.1",
"vaersaagod/dospaces": "3.2.1",
"verbb/hyper": "2.2.10",
"viget/craft-classnames": "3.0.0",
"vlucas/phpdotenv": "^5.6.0"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the checkbox-only query from the issue in a Craft CMS 5.8.20 section with several checkbox values, using the provided Twig template. Capture the exception and compare it with a query combining another field. Done means the checkbox-only query executes successfully and returns the entries matching the selected value.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.