Skip to content

MySqlContains filter doesn't work with a JsonColumn  #75

@CerzBbz

Description

@CerzBbz

When adding a Contains filter to a JsonColumn, the calculated value is json_encoded, so '%search-term%' is encoded to '"%search-term%"'. When this is inserted into the sql query we end up with the following:

WHERE JsonColumn LIKE '\"%search-term%\"'

This is due to the following method inside JsonColumn

    public function getTransformIntoRepository()
    {
        return function ($data) {
            return json_encode($data[$this->columnName]);
        };
    }

Either need to prevent Contains queries from running getTransformedComparisonValueForRepository or by modifying getTransformationIntoRepository to understand if it is transforming for storage or for searching.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions