#9494 Fixed custom data search

This commit is contained in:
Daniel Maya 2022-11-22 13:24:26 +01:00
parent dbe329f1de
commit 4e94976b9d

View File

@ -1102,27 +1102,27 @@ function events_get_all(
$sql_filters[] = sprintf( $sql_filters[] = sprintf(
' AND JSON_VALID(custom_data) = 1 ' AND JSON_VALID(custom_data) = 1
AND (JSON_EXTRACT(custom_data, "$.*") LIKE lower("%%%s%%") COLLATE utf8mb4_0900_ai_ci) ', AND (JSON_EXTRACT(custom_data, "$.*") LIKE lower("%%%s%%") COLLATE utf8mb4_0900_ai_ci) ',
$filter['custom_data'] io_safe_output($filter['custom_data'])
); );
} else { } else {
$sql_filters[] = sprintf( $sql_filters[] = sprintf(
' AND JSON_VALID(custom_data) = 1 ' AND JSON_VALID(custom_data) = 1
AND (JSON_SEARCH(JSON_KEYS(custom_data), "all", lower("%%%s%%") COLLATE utf8mb4_0900_ai_ci) IS NOT NULL) ', AND (JSON_SEARCH(JSON_KEYS(custom_data), "all", lower("%%%s%%") COLLATE utf8mb4_0900_ai_ci) IS NOT NULL) ',
$filter['custom_data'] io_safe_output($filter['custom_data'])
); );
} }
} else { } else {
if ($filter['custom_data_filter_type'] === '1') { if ($filter['custom_data_filter_type'] === '1') {
$sql_filters[] = sprintf( $sql_filters[] = sprintf(
' AND JSON_VALID(custom_data) = 1 AND JSON_EXTRACT(custom_data, "$.*") LIKE lower("%%%s%%") ', ' AND JSON_VALID(custom_data) = 1
$filter['custom_data'], AND cast(JSON_EXTRACT(custom_data, "$.*") as CHAR) LIKE lower("%%%s%%") ',
$filter['custom_data'] io_safe_output($filter['custom_data'])
); );
} else { } else {
$sql_filters[] = sprintf( $sql_filters[] = sprintf(
' AND JSON_VALID(custom_data) = 1 AND JSON_KEYS(custom_data) REGEXP "%s" ', ' AND JSON_VALID(custom_data) = 1
$filter['custom_data'], AND cast(JSON_KEYS(custom_data) as CHAR) REGEXP "%s" ',
$filter['custom_data'] io_safe_output($filter['custom_data'])
); );
} }
} }