fix: add SQL JSON validity check to meta_data query

This commit is contained in:
Christoph Kluge 2024-05-06 13:15:15 +02:00
parent 72557fd0bf
commit 597bccc080

View File

@ -236,6 +236,9 @@ func buildStringCondition(field string, cond *model.StringInput, query sq.Select
}
func buildMetaJsonCondition(jsonField string, cond *model.StringInput, query sq.SelectBuilder) sq.SelectBuilder {
// Verify and Search Only in Valid Jsons
query = query.Where("JSON_VALID(meta_data)")
// add "AND" Sql query Block for field match
if cond.Eq != nil {
return query.Where("JSON_EXTRACT(meta_data, \"$."+jsonField+"\") = ?", *cond.Eq)
}