core
core copied to clipboard
Query on select field with integer values doesn't work anymore
I can't fetch Content using Query service on select field with integer values.
Details
Question | Answer |
---|---|
Relevant Bolt Version | 5.0.7 |
Install type | composer install |
BC Break | yes |
PHP version | 7.4 |
Web server | Nginx |
Reproduction
I have this content type defined in my config file :
contenttype:
name: contenttype
fields:
select_field:
type: select
values:
0: value1
301: value2
302: value3
I want to fetch some data with following request using Query service :
private Bolt\Storage\Query $$query;
public function __construct(Bolt\Storage\Query $query) {
$this->query = $query;
}
$this->query->getContent('contenttype', ['select_field' => 301]);
No result returned while I can see existing value in database :

It's possible to fetch data when values are stored as string instead of integer :
It's a BC break because the query worked on Bolt 4.2.5
This is probably why we can't query json field with integer values :
JSON_SEARCH(json_doc, one_or_all, search_str[, escape_char[, path] ...]) Returns the path to the given string within a JSON document.
It seems that by design, JSON_SEARCH
works with strings only.
see also https://bugs.mysql.com/bug.php?id=79233
Issue fixed by #3302
Thanks for the followup! This should indeed by fixed now! 😅