fix casing for meilisearch filter string

This commit is contained in:
Scott Merchant 2024-06-09 22:00:44 +09:30
parent ac38f2d6eb
commit fec468401f

View File

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using Kyoo.Abstractions.Models.Utils;
using static System.Text.Json.JsonNamingPolicy;
namespace Kyoo.Meiliseach;
@ -13,13 +14,13 @@ public static class FilterExtensionMethods
=> $"({and.First.CreateMeilisearchFilter()}) AND ({and.Second.CreateMeilisearchFilter()})",
Filter<T>.Or or
=> $"({or.First.CreateMeilisearchFilter()}) OR ({or.Second.CreateMeilisearchFilter()})",
Filter<T>.Gt gt => $"{gt.Property} > {gt.Value}",
Filter<T>.Lt lt => $"{lt.Property} < {lt.Value}",
Filter<T>.Ge ge => $"{ge.Property} >= {ge.Value}",
Filter<T>.Le le => $"{le.Property} <= {le.Value}",
Filter<T>.Eq eq => $"{eq.Property} = {eq.Value}",
Filter<T>.Has has => $"{has.Property} = {has.Value}",
Filter<T>.Ne ne => $"{ne.Property} != {ne.Value}",
Filter<T>.Gt gt => $"{CamelCase.ConvertName(gt.Property)} > '{gt.Value}'",
Filter<T>.Lt lt => $"{CamelCase.ConvertName(lt.Property)} < '{lt.Value}'",
Filter<T>.Ge ge => $"{CamelCase.ConvertName(ge.Property)} >= '{ge.Value}'",
Filter<T>.Le le => $"{CamelCase.ConvertName(le.Property)} <= '{le.Value}'",
Filter<T>.Eq eq => $"{CamelCase.ConvertName(eq.Property)} = '{eq.Value}'",
Filter<T>.Has has => $"{CamelCase.ConvertName(has.Property)} = '{has.Value}'",
Filter<T>.Ne ne => $"{CamelCase.ConvertName(ne.Property)} != '{ne.Value}'",
Filter<T>.Not not => $"NOT ({not.Filter.CreateMeilisearchFilter()})",
Filter<T>.CmpRandom
=> throw new ValidationException("Random comparison is not supported."),