core icon indicating copy to clipboard operation
core copied to clipboard

Query on select field with integer values doesn't work anymore

Open jordanaubert opened this issue 3 years ago • 1 comments

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 :

Capture d’écran 2021-12-16 à 11 28 59

It's possible to fetch data when values are stored as string instead of integer : Capture d’écran 2021-12-16 à 11 30 59

It's a BC break because the query worked on Bolt 4.2.5

jordanaubert avatar Dec 16 '21 10:12 jordanaubert

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

jordanaubert avatar Jul 21 '22 11:07 jordanaubert

Issue fixed by #3302

jordanaubert avatar Sep 06 '22 12:09 jordanaubert

Thanks for the followup! This should indeed by fixed now! 😅

bobdenotter avatar Sep 06 '22 12:09 bobdenotter