using System; using System.Collections.Generic; using SqlKata; namespace PluralKit.Core { internal class QueryPatchWrapper { private Dictionary _dict = new(); public QueryPatchWrapper With(string columnName, Partial partialValue) { if (partialValue.IsPresent) _dict.Add(columnName, partialValue); return this; } public Query ToQuery(Query q) => q.AsUpdate(_dict); } internal static class SqlKataExtensions { internal static Query ApplyPatch(this Query query, Func func) => func(new QueryPatchWrapper()).ToQuery(query); } }