diff --git a/examples/EdgeDB.Examples.CSharp/Examples/QueryBuilder.cs b/examples/EdgeDB.Examples.CSharp/Examples/QueryBuilder.cs index 916c6ae2..2e0cd350 100644 --- a/examples/EdgeDB.Examples.CSharp/Examples/QueryBuilder.cs +++ b/examples/EdgeDB.Examples.CSharp/Examples/QueryBuilder.cs @@ -166,7 +166,7 @@ private static async Task QueryBuilderDemo(EdgeDBClient client) // grouping by expressions query = QueryBuilder .Group() - .Using(person => new {StartsWithVowel = Regex.Matches(person.Name!, "(?i)^[aeiou]")}) + .Using(person => new {StartsWithVowel = Regex.IsMatch(person.Name!, "(?i)^[aeiou]")}) .By(ctx => ctx.Using.StartsWithVowel) .Compile(true); @@ -185,7 +185,7 @@ private static async Task QueryBuilderDemo(EdgeDBClient client) People = ctx.SubQuerySingle(QueryBuilder.Select()), Groups = ctx.SubQuerySingle( QueryBuilder - .Group(ctx => ctx.Local("People")) + .Group(ctx => ctx.Global("People")) .Using(person => new {Vowel = Regex.IsMatch(person.Name!, "(?i)^[aeiou]")}) .By(ctx => ctx.Using.Vowel) ) @@ -195,7 +195,7 @@ private static async Task QueryBuilderDemo(EdgeDBClient client) { StartsWithVowel = group.Key, Count = EdgeQL.Count(group.Elements), - NameLength = EdgeQL.Len(ctx.Ref(group.Elements).Name!) + NameLength = 1//EdgeQL.Len(ctx.Ref(group.Elements).Name!) }) ) .Compile(true); @@ -207,7 +207,7 @@ private static async Task QueryBuilderDemo(EdgeDBClient client) People = ctx.SubQuerySingle(QueryBuilder.Select()), Groups = ctx.SubQuerySingle( QueryBuilder - .Group(ctx => ctx.Local("People")) + .Group(ctx => ctx.Global("People")) .Using(person => new { Vowel = Regex.IsMatch(person.Name!, "(?i)^[aeiou]"), @@ -217,11 +217,11 @@ private static async Task QueryBuilderDemo(EdgeDBClient client) ) }) .SelectExpression(ctx => ctx.Variables.Groups, shape => shape - .Computeds((ctx, group) => new + .Explicitly((ctx, group) => new { - StartsWithVowel = group.Key, + group.Key, Count = EdgeQL.Count(group.Elements), - NameLength = EdgeQL.Len(ctx.Ref(group.Elements).Name!) + MeanNameLength = EdgeQL.Mean(ctx.Aggregate(group.Elements, element => (long)element.Name!.Length)) }) ) .Compile(true); @@ -243,12 +243,12 @@ private static async Task QueryBuilderDemo(EdgeDBClient client) ) }) .SelectExpression(ctx => ctx.Variables.Groups, shape => shape - .Computeds((ctx, group) => new + .Explicitly((ctx, group) => new { group.Key, group.Grouping, Count = EdgeQL.Count(group.Elements), - NameLength = EdgeQL.Len(ctx.Ref(group.Elements).Name!) + MeanNameLength = EdgeQL.Mean(ctx.Aggregate(group.Elements, element => (long)element.Name!.Length))//NameLength = 1//EdgeQL.Len(ctx.Ref(group.Elements).Name!) }) ) .OrderBy(x => EdgeQL.ArrayAgg(x.Grouping)) diff --git a/src/EdgeDB.Net.QueryBuilder/Attributes/EdgeQLFunctionAttribute.cs b/src/EdgeDB.Net.QueryBuilder/Attributes/EdgeQLFunctionAttribute.cs new file mode 100644 index 00000000..00c76e5a --- /dev/null +++ b/src/EdgeDB.Net.QueryBuilder/Attributes/EdgeQLFunctionAttribute.cs @@ -0,0 +1,21 @@ +namespace EdgeDB; + +public sealed class EdgeQLFunctionAttribute(string name, string module, string returns, bool returnsSetOf, bool returnsOptional) : Attribute +{ + public readonly string Name = name; + public readonly string Module = module; + public readonly string Returns = returns; + public readonly bool ReturnsSetOf = returnsSetOf; + public readonly bool ReturnsOptional = returnsOptional; + + public string GetFormattedReturnType() + { + if (ReturnsSetOf) + return $"set<{Returns}>"; + + if (ReturnsOptional) + return $"optional {Returns}"; + + return Returns; + } +} diff --git a/src/EdgeDB.Net.QueryBuilder/Builders/ShapeBuilder.cs b/src/EdgeDB.Net.QueryBuilder/Builders/ShapeBuilder.cs index 7d4cc30c..64144ee2 100644 --- a/src/EdgeDB.Net.QueryBuilder/Builders/ShapeBuilder.cs +++ b/src/EdgeDB.Net.QueryBuilder/Builders/ShapeBuilder.cs @@ -211,18 +211,14 @@ public ShapeBuilder Exclude(Expression> selecto } public ShapeBuilder Computeds(Expression> computedsSelector) - { - var computeds = FlattenAnonymousExpression(SelectedType, computedsSelector); - - foreach (var computed in computeds) - SelectedProperties[computed.Key.GetEdgeDBPropertyName()] = new(computed.Key, computed.Value); - - return this; - } + => ComputedsInternal(computedsSelector); public ShapeBuilder Computeds(Expression, T, TAnon>> computedsSelector) + => ComputedsInternal(computedsSelector); + + internal ShapeBuilder ComputedsInternal(LambdaExpression expression) { - var computeds = FlattenAnonymousExpression(SelectedType, computedsSelector); + var computeds = FlattenAnonymousExpression(SelectedType, expression); foreach (var computed in computeds) SelectedProperties[computed.Key.GetEdgeDBPropertyName()] = new(computed.Key, computed.Value); @@ -231,8 +227,15 @@ public ShapeBuilder Computeds(Expression, T, } public ShapeBuilder Explicitly(Expression> explicitSelector) + => ExplicitlyInternal(explicitSelector); + + public ShapeBuilder Explicitly(Expression, T, TAnon>> explicitSelector) + => ExplicitlyInternal(explicitSelector); + + + internal ShapeBuilder ExplicitlyInternal(LambdaExpression expression) { - var members = FlattenAnonymousExpression(SelectedType, explicitSelector); + var members = FlattenAnonymousExpression(SelectedType, expression); SelectedProperties.Clear(); diff --git a/src/EdgeDB.Net.QueryBuilder/Compiled/DebugCompiledQuery.cs b/src/EdgeDB.Net.QueryBuilder/Compiled/DebugCompiledQuery.cs index f10798f5..2eca24cd 100644 --- a/src/EdgeDB.Net.QueryBuilder/Compiled/DebugCompiledQuery.cs +++ b/src/EdgeDB.Net.QueryBuilder/Compiled/DebugCompiledQuery.cs @@ -57,41 +57,76 @@ private static string CreateDebugText(string query, Dictionary barText.Insert(size - 1, "\u255d"); // corner UL rowText.Insert(column.Range.Start.Value, barText); + char DrawVert(char prev) + { + return prev switch + { + ' ' => '\u2551', + // L: UR -> T: UDR + '\u255a' => '\u2560', + // L: UL -> T: UDL + '\u255d' => '\u2563', + // horizontal - + '\u2550' => '\u256c', + _ => prev + }; + } + foreach (var prevRowText in rows) { var prevStart = prevRowText[column.Range.Start.Value]; - - if (prevStart is ' ' or '\u255a') - { - prevRowText.Remove(column.Range.Start.Value, 1); - prevRowText.Insert(column.Range.Start.Value, prevStart == '\u255a' ? '\u2560' : '\u2551'); - } + prevRowText.Remove(column.Range.Start.Value, 1); + prevRowText.Insert(column.Range.Start.Value, DrawVert(prevStart)); prevStart = prevRowText[query.Length + 1 + column.Range.Start.Value]; - - if (prevStart is ' ' or '\u255a') - { - prevRowText.Remove(query.Length + 1 + column.Range.Start.Value, 1); - prevRowText.Insert(query.Length + 1 + column.Range.Start.Value, prevStart == '\u255a' ? '\u2560' : '\u2551'); - } + prevRowText.Remove(query.Length + 1 + column.Range.Start.Value, 1); + prevRowText.Insert(query.Length + 1 + column.Range.Start.Value, DrawVert(prevStart)); var prevEnd = prevRowText[column.Range.End.Value - 1]; - - if (prevEnd is ' ' or '\u255d') - { - prevRowText.Remove(column.Range.End.Value - 1, 1); - prevRowText.Insert(column.Range.End.Value - 1, prevEnd == '\u255d' ? '\u2563' : '\u2551'); - } + prevRowText.Remove(column.Range.End.Value - 1, 1); + prevRowText.Insert(column.Range.End.Value - 1, DrawVert(prevEnd)); prevEnd = prevRowText[query.Length + column.Range.End.Value]; - if (prevEnd is ' ' or '\u255d') - { - prevRowText.Remove(query.Length + column.Range.End.Value, 1); - prevRowText.Insert(query.Length + column.Range.End.Value, prevEnd == '\u255d' ? '\u2563' : '\u2551'); - } + prevRowText.Remove(query.Length + column.Range.End.Value, 1); + prevRowText.Insert(query.Length + column.Range.End.Value, DrawVert(prevEnd)); } + // foreach (var prevRowText in rows) + // { + // var prevStart = prevRowText[column.Range.Start.Value]; + // + // if (prevStart is ' ' or '\u255a') + // { + // prevRowText.Remove(column.Range.Start.Value, 1); + // prevRowText.Insert(column.Range.Start.Value, prevStart == '\u255a' ? '\u2560' : '\u2551'); + // } + // + // prevStart = prevRowText[query.Length + 1 + column.Range.Start.Value]; + // + // if (prevStart is ' ' or '\u255a') + // { + // prevRowText.Remove(query.Length + 1 + column.Range.Start.Value, 1); + // prevRowText.Insert(query.Length + 1 + column.Range.Start.Value, prevStart == '\u255a' ? '\u2560' : '\u2551'); + // } + // + // var prevEnd = prevRowText[column.Range.End.Value - 1]; + // + // if (prevEnd is ' ' or '\u255d') + // { + // prevRowText.Remove(column.Range.End.Value - 1, 1); + // prevRowText.Insert(column.Range.End.Value - 1, prevEnd == '\u255d' ? '\u2563' : '\u2551'); + // } + // + // prevEnd = prevRowText[query.Length + column.Range.End.Value]; + // + // if (prevEnd is ' ' or '\u255d') + // { + // prevRowText.Remove(query.Length + column.Range.End.Value, 1); + // prevRowText.Insert(query.Length + column.Range.End.Value, prevEnd == '\u255d' ? '\u2563' : '\u2551'); + // } + // } + // desc var icon = (markerTexts.Count + 1).ToString(); var desc = $"{icon} [{column.Marker.Type}] {column.Name}"; @@ -100,17 +135,17 @@ private static string CreateDebugText(string query, Dictionary desc += $": {column.Marker.DebugText.Get()}"; - if (desc.Length > size) + if (desc.Length + 2 > size) { desc = $"{icon} [{column.Marker.Type}] {column.Name}"; } - if (desc.Length > size) + if (desc.Length + 2 > size) { desc = $"{icon} {column.Name}"; } - if (desc.Length >= size) + if (desc.Length + 2 >= size) { desc = icon; } @@ -146,14 +181,18 @@ private static string CreateDebugText(string query, Dictionary { sb.AppendLine("Markers:"); - var markerTypePadding = Enum.GetValues().Max(x => Enum.GetName(x)!.Length) + 2; foreach (var (name, value) in markerTexts) { - var desc = $"{$"[{value.Marker.Type}]".PadRight(markerTypePadding)} {value.Name}"; + sb.AppendLine($" {name}. {value.Marker.Type} ({value.Range})"); + sb.AppendLine($" - Name: {value.Name}"); + sb.AppendLine($" - Position: {value.Marker.Position}, Size: {value.Marker.Size}"); + if (value.Marker.Metadata is not null) + sb.AppendLine($" - {value.Marker.Metadata}"); if (value.Marker.DebugText is not null) - desc += $": {value.Marker.DebugText.Get()}"; + sb.AppendLine($" - Context: {value.Marker.DebugText.Get()}"); + - sb.AppendLine($" - {name.PadRight(markerTexts.Count.ToString().Length)} {$"({value.Range})".PadRight(query.Length.ToString().Length*2+4)} {desc}"); + sb.AppendLine(); } } } diff --git a/src/EdgeDB.Net.QueryBuilder/EdgeDB.Net.QueryBuilder.csproj b/src/EdgeDB.Net.QueryBuilder/EdgeDB.Net.QueryBuilder.csproj index 8c5da00e..ca9a1ad5 100644 --- a/src/EdgeDB.Net.QueryBuilder/EdgeDB.Net.QueryBuilder.csproj +++ b/src/EdgeDB.Net.QueryBuilder/EdgeDB.Net.QueryBuilder.csproj @@ -19,7 +19,6 @@ - diff --git a/src/EdgeDB.Net.QueryBuilder/EdgeQL.cs b/src/EdgeDB.Net.QueryBuilder/EdgeQL.cs index 3d7890f9..3a0fc3f0 100644 --- a/src/EdgeDB.Net.QueryBuilder/EdgeQL.cs +++ b/src/EdgeDB.Net.QueryBuilder/EdgeQL.cs @@ -1,9 +1,54 @@ using EdgeDB.Interfaces; +using System.Diagnostics.CodeAnalysis; +using System.Reflection; namespace EdgeDB { public sealed partial class EdgeQL { + private static readonly Dictionary>> EdgeQLFunctions; + + static EdgeQL() + { + var methods = typeof(EdgeQL).GetMethods(); + EdgeQLFunctions = new(); + + foreach (var method in methods) + { + var edgeqlFuncAttribute = method.GetCustomAttribute(); + + if(edgeqlFuncAttribute is null) + continue; + + if (!EdgeQLFunctions.TryGetValue(edgeqlFuncAttribute.Module, out var moduleFunctions)) + moduleFunctions = EdgeQLFunctions[edgeqlFuncAttribute.Module] = new(); + + if (!moduleFunctions.TryGetValue(edgeqlFuncAttribute.Name, out var functions)) + functions = moduleFunctions[edgeqlFuncAttribute.Name] = new(); + + functions.Add(method); + } + } + + internal static bool TryGetMethods(string name, string module, [MaybeNullWhen(false)] out List methods) + { + methods = null; + return EdgeQLFunctions.TryGetValue(module, out var moduleFunctions) && moduleFunctions.TryGetValue(name, out methods); + } + + internal static List SearchMethods(string name) + { + var result = new List(); + + foreach (var (module, functions) in EdgeQLFunctions) + { + if (functions.TryGetValue(name, out var targetFunctions)) + result.AddRange(targetFunctions); + } + + return result; + } + public static T Rollup(T value) => default!; @@ -13,46 +58,5 @@ public static T Cube(T value) public static JsonReferenceVariable AsJson(T value) => new(value); public static long Count(IMultiCardinalityExecutable a) { return default!; } - - // /// - // /// A function that represents the EdgeQL version of: count() - // /// - // - // - // [EquivalentOperator(typeof(EdgeDB.Operators.LinksAddLink))] - // public static TType[] AddLink(IQuery element) - // => default!; - // - // [EquivalentOperator(typeof(EdgeDB.Operators.LinksAddLink))] - // public static TType[] AddLinkRef(TType element) - // => default!; - // - // [EquivalentOperator(typeof(EdgeDB.Operators.LinksAddLink))] - // public static TSource AddLink(TType element) - // where TSource : IEnumerable - // => default!; - // - // [EquivalentOperator(typeof(EdgeDB.Operators.LinksAddLink))] - // public static TSource AddLinkRef(IQuery element) - // where TSource : IEnumerable - // => default!; - // - // [EquivalentOperator(typeof(EdgeDB.Operators.LinksRemoveLink))] - // public static TType[] RemoveLinkRef(TType element) - // => default!; - // - // [EquivalentOperator(typeof(EdgeDB.Operators.LinksRemoveLink))] - // public static TType[] RemoveLink(IQuery element) - // => default!; - // - // [EquivalentOperator(typeof(EdgeDB.Operators.LinksRemoveLink))] - // public static TSource RemoveLinkRef(TType element) - // where TSource : IEnumerable - // => default!; - // - // [EquivalentOperator(typeof(EdgeDB.Operators.LinksRemoveLink))] - // public static TSource RemoveLink(IQuery element) - // where TSource : IEnumerable - // => default!; } } diff --git a/src/EdgeDB.Net.QueryBuilder/EdgeQL.g.cs b/src/EdgeDB.Net.QueryBuilder/EdgeQL.g.cs index 1a7d3bc8..6f9e63da 100644 --- a/src/EdgeDB.Net.QueryBuilder/EdgeQL.g.cs +++ b/src/EdgeDB.Net.QueryBuilder/EdgeQL.g.cs @@ -1,1729 +1,1356 @@ -// #nullable restore -// #pragma warning disable -// using EdgeDB.Operators; -// using EdgeDB.DataTypes; -// using EdgeDB.Interfaces; -// using System.Numerics; -// using DateTime = System.DateTime; -// -// namespace EdgeDB -// { -// public sealed partial class EdgeQL -// { -// #region Generic -// -// #region Equals -// /// -// /// A function that represents the EdgeQL version of: ?= -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.GenericEquals))] -// public static bool Equals(object? a, object? b) { return default!; } -// #endregion -// -// #region NotEqual -// /// -// /// A function that represents the EdgeQL version of: ?!= -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.GenericNotEqual))] -// public static bool NotEqual(object? a, object? b) { return default!; } -// #endregion -// -// #region LessThan -// /// -// /// A function that represents the EdgeQL version of: < -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.GenericLessThan))] -// public static bool LessThan(object? a, object? b) { return default!; } -// #endregion -// -// #region GreaterThan -// /// -// /// A function that represents the EdgeQL version of: > -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.GenericGreaterThan))] -// public static bool GreaterThan(object? a, object? b) { return default!; } -// #endregion -// -// #region LessThanOrEqual -// /// -// /// A function that represents the EdgeQL version of: <= -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.GenericLessThanOrEqual))] -// public static bool LessThanOrEqual(object? a, object? b) { return default!; } -// #endregion -// -// #region GreaterThanOrEqual -// /// -// /// A function that represents the EdgeQL version of: >= -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.GenericGreaterThanOrEqual))] -// public static bool GreaterThanOrEqual(object? a, object? b) { return default!; } -// #endregion -// -// #region Length -// /// -// /// A function that represents the EdgeQL version of: len() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.GenericLength))] -// public static long Length(object? a) { return default!; } -// #endregion -// -// #region Contains -// /// -// /// A function that represents the EdgeQL version of: contains(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.GenericContains))] -// public static bool Contains(object? source, object? element) { return default!; } -// #endregion -// -// #region Find -// /// -// /// A function that represents the EdgeQL version of: find(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.GenericFind))] -// public static long IndexOf(object? source, object? element) { return default!; } -// #endregion -// -// #endregion Generic -// -// #region string -// -// #region Index -// /// -// /// A function that represents the EdgeQL version of: [] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringIndex))] -// public static string? Index(string? a, long b) { return default!; } -// #endregion -// -// #region Slice -// /// -// /// A function that represents the EdgeQL version of: [:{2?}] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringSlice))] -// public static string? Slice(string? str, long startIndex) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: [:{2?}] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringSlice))] -// public static string? Slice(string? str, long startIndex, long endIndex) { return default!; } -// #endregion -// -// #region Concat -// /// -// /// A function that represents the EdgeQL version of: ++ -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringConcat))] -// public static string? Concat(string? a, string? b) { return default!; } -// #endregion -// -// #region Like -// /// -// /// A function that represents the EdgeQL version of: like -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringLike))] -// public static bool Like(string? a, string? b) { return default!; } -// #endregion -// -// #region ILike -// /// -// /// A function that represents the EdgeQL version of: ilike -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringILike))] -// public static bool ILike(string? a, string? b) { return default!; } -// #endregion -// -// #region ToString -// /// -// /// A function that represents the EdgeQL version of: to_str() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringToString))] -// public static string? ToString(object? a) { return default!; } -// #endregion -// -// #region Length -// /// -// /// A function that represents the EdgeQL version of: len() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringLength))] -// public static long Length(string? a) { return default!; } -// #endregion -// -// #region Contains -// /// -// /// A function that represents the EdgeQL version of: contains(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringContains))] -// public static bool Contains(string? a, string? b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: contains(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringContains))] -// public static bool Contains(string? a, char b) { return default!; } -// #endregion -// -// #region Find -// /// -// /// A function that represents the EdgeQL version of: find(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringFind))] -// public static long Find(string? a, string? b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: find(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringFind))] -// public static long Find(string? a, char b) { return default!; } -// #endregion -// -// #region ToLower -// /// -// /// A function that represents the EdgeQL version of: str_lower() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringToLower))] -// public static string? ToLower(string? a) { return default!; } -// #endregion -// -// #region ToUpper -// /// -// /// A function that represents the EdgeQL version of: str_upper() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringToUpper))] -// public static string? ToUpper(string? a) { return default!; } -// #endregion -// -// #region ToTitle -// /// -// /// A function that represents the EdgeQL version of: str_title() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringToTitle))] -// public static string? ToTitle(string? a) { return default!; } -// #endregion -// -// #region PadLeft -// /// -// /// A function that represents the EdgeQL version of: str_pad_start(, , {2?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringPadLeft))] -// public static string? PadLeft(string? a, long count) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: str_pad_start(, , {2?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringPadLeft))] -// public static string? PadLeft(string? a, long count, string? fill) { return default!; } -// #endregion -// -// #region PadRight -// /// -// /// A function that represents the EdgeQL version of: str_pad_end(, , {2?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringPadRight))] -// public static string? PadRight(string? a, long count) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: str_pad_end(, , {2?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringPadRight))] -// public static string? PadRight(string? a, long count, string? fill) { return default!; } -// #endregion -// -// #region Trim -// /// -// /// A function that represents the EdgeQL version of: str_trim(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringTrim))] -// public static string? Trim(string? a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: str_trim(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringTrim))] -// public static string? Trim(string? a, string? trimCharacters) { return default!; } -// #endregion -// -// #region TrimStart -// /// -// /// A function that represents the EdgeQL version of: str_trim_start(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringTrimStart))] -// public static string? TrimStart(string? a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: str_trim_start(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringTrimStart))] -// public static string? TrimStart(string? a, string? trimCharacters) { return default!; } -// #endregion -// -// #region TrimEnd -// /// -// /// A function that represents the EdgeQL version of: str_trim_end(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringTrimEnd))] -// public static string? TrimEnd(string? a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: str_trim_end(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringTrimEnd))] -// public static string? TrimEnd(string? a, string? trimCharacters) { return default!; } -// #endregion -// -// #region Repeat -// /// -// /// A function that represents the EdgeQL version of: str_repeat(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringRepeat))] -// public static string? Repeat(string? a, long count) { return default!; } -// #endregion -// -// #region Split -// /// -// /// A function that represents the EdgeQL version of: str_split(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringSplit))] -// public static string?[] Split(string? a, string? delimiter) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: str_split(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringSplit))] -// public static string?[] Split(string? a, char delimiter) { return default!; } -// #endregion -// -// #region Match -// /// -// /// A function that represents the EdgeQL version of: re_match(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringMatch))] -// public static string?[] Match(string? pattern, string? input) { return default!; } -// #endregion -// -// #region MatchAll -// /// -// /// A function that represents the EdgeQL version of: re_match_all(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringMatchAll))] -// public static IEnumerable MatchAll(string? pattern, string? input) { return default!; } -// #endregion -// -// #region Replace -// /// -// /// A function that represents the EdgeQL version of: re_replace(, , , <flags := {3?}>) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringReplace))] -// public static string? Replace(string? pattern, string? substitute, string? input, string? flags) { return default!; } -// #endregion -// -// #region IsMatch -// /// -// /// A function that represents the EdgeQL version of: re_test(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.StringIsMatch))] -// public static bool IsMatch(string? pattern, string? input) { return default!; } -// #endregion -// -// #endregion string -// -// #region boolean -// -// #region Or -// /// -// /// A function that represents the EdgeQL version of: or -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.BooleanOr))] -// public static bool Or(bool a, bool b) { return default!; } -// #endregion -// -// #region And -// /// -// /// A function that represents the EdgeQL version of: and -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.BooleanAnd))] -// public static bool And(bool a, bool b) { return default!; } -// #endregion -// -// #region Not -// /// -// /// A function that represents the EdgeQL version of: not -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.BooleanNot))] -// public static bool Not(bool a) { return default!; } -// #endregion -// -// #region All -// /// -// /// A function that represents the EdgeQL version of: all() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.BooleanAll))] -// public static bool All(IEnumerable a) { return default!; } -// #endregion -// -// #region Any -// /// -// /// A function that represents the EdgeQL version of: any() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.BooleanAny))] -// public static bool Any(IEnumerable a) { return default!; } -// #endregion -// -// #endregion boolean -// -// #region numbers -// -// #region Add -// /// -// /// A function that represents the EdgeQL version of: + -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersAdd))] -// public static long Add(long a, long b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: + -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersAdd))] -// public static short Add(short a, short b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: + -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersAdd))] -// public static int Add(int a, int b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: + -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersAdd))] -// public static double Add(double a, double b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: + -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersAdd))] -// public static float Add(float a, float b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: + -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersAdd))] -// public static decimal Add(decimal a, decimal b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: + -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersAdd))] -// public static byte Add(byte a, byte b) { return default!; } -// #endregion -// -// #region Subtract -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSubtract))] -// public static long Subtract(long a, long b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSubtract))] -// public static short Subtract(short a, short b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSubtract))] -// public static int Subtract(int a, int b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSubtract))] -// public static double Subtract(double a, double b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSubtract))] -// public static float Subtract(float a, float b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSubtract))] -// public static decimal Subtract(decimal a, decimal b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSubtract))] -// public static byte Subtract(byte a, byte b) { return default!; } -// #endregion -// -// #region Negative -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersNegative))] -// public static long Negative(long a, long b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersNegative))] -// public static short Negative(short a, short b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersNegative))] -// public static int Negative(int a, int b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersNegative))] -// public static double Negative(double a, double b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersNegative))] -// public static float Negative(float a, float b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersNegative))] -// public static decimal Negative(decimal a, decimal b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersNegative))] -// public static byte Negative(byte a, byte b) { return default!; } -// #endregion -// -// #region Multiply -// /// -// /// A function that represents the EdgeQL version of: * -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersMultiply))] -// public static long Multiply(long a, long b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: * -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersMultiply))] -// public static short Multiply(short a, short b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: * -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersMultiply))] -// public static int Multiply(int a, int b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: * -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersMultiply))] -// public static double Multiply(double a, double b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: * -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersMultiply))] -// public static float Multiply(float a, float b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: * -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersMultiply))] -// public static decimal Multiply(decimal a, decimal b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: * -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersMultiply))] -// public static byte Multiply(byte a, byte b) { return default!; } -// #endregion -// -// #region Divide -// /// -// /// A function that represents the EdgeQL version of: / -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersDivide))] -// public static long Divide(long a, long b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: / -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersDivide))] -// public static short Divide(short a, short b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: / -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersDivide))] -// public static int Divide(int a, int b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: / -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersDivide))] -// public static double Divide(double a, double b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: / -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersDivide))] -// public static float Divide(float a, float b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: / -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersDivide))] -// public static decimal Divide(decimal a, decimal b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: / -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersDivide))] -// public static byte Divide(byte a, byte b) { return default!; } -// #endregion -// -// #region Floor -// /// -// /// A function that represents the EdgeQL version of: // -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersFloor))] -// public static long Floor(long a, long b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: // -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersFloor))] -// public static short Floor(short a, short b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: // -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersFloor))] -// public static int Floor(int a, int b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: // -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersFloor))] -// public static double Floor(double a, double b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: // -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersFloor))] -// public static float Floor(float a, float b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: // -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersFloor))] -// public static decimal Floor(decimal a, decimal b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: // -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersFloor))] -// public static byte Floor(byte a, byte b) { return default!; } -// #endregion -// -// #region Modulo -// /// -// /// A function that represents the EdgeQL version of: % -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersModulo))] -// public static long Modulo(long a, long b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: % -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersModulo))] -// public static short Modulo(short a, short b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: % -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersModulo))] -// public static int Modulo(int a, int b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: % -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersModulo))] -// public static double Modulo(double a, double b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: % -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersModulo))] -// public static float Modulo(float a, float b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: % -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersModulo))] -// public static decimal Modulo(decimal a, decimal b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: % -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersModulo))] -// public static byte Modulo(byte a, byte b) { return default!; } -// #endregion -// -// #region Power -// /// -// /// A function that represents the EdgeQL version of: ^ -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersPower))] -// public static long Power(long a, long b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: ^ -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersPower))] -// public static short Power(short a, short b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: ^ -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersPower))] -// public static int Power(int a, int b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: ^ -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersPower))] -// public static double Power(double a, double b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: ^ -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersPower))] -// public static float Power(float a, float b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: ^ -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersPower))] -// public static decimal Power(decimal a, decimal b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: ^ -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersPower))] -// public static byte Power(byte a, byte b) { return default!; } -// #endregion -// -// #region Sum -// /// -// /// A function that represents the EdgeQL version of: sum() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSum))] -// public static long Sum(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: sum() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSum))] -// public static long Sum(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: sum() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSum))] -// public static decimal Sum(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: sum() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSum))] -// public static float Sum(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: sum() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSum))] -// public static double Sum(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: sum() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersSum))] -// public static BigInteger Sum(IEnumerable a) { return default!; } -// #endregion -// -// #region Round -// /// -// /// A function that represents the EdgeQL version of: round(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersRound))] -// public static long Round(long a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: round(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersRound))] -// public static long Round(double a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: round(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersRound))] -// public static long Round(BigInteger a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: round(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersRound))] -// public static long Round(decimal a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: round(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersRound))] -// public static long Round(decimal a, long decimalPoint) { return default!; } -// #endregion -// -// #region Random -// /// -// /// A function that represents the EdgeQL version of: random() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersRandom))] -// public static double Random() { return default!; } -// #endregion -// -// #region ToBigInteger -// /// -// /// A function that represents the EdgeQL version of: to_bigint(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToBigInteger))] -// public static BigInteger ToBigInteger(string? a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: to_bigint(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToBigInteger))] -// public static BigInteger ToBigInteger(string? a, string? format) { return default!; } -// #endregion -// -// #region ToDecimal -// /// -// /// A function that represents the EdgeQL version of: to_decimal(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToDecimal))] -// public static decimal ToDecimal(string? a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: to_decimal(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToDecimal))] -// public static decimal ToDecimal(string? a, string? format) { return default!; } -// #endregion -// -// #region ToShort -// /// -// /// A function that represents the EdgeQL version of: to_int16(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToShort))] -// public static short ToShort(string? a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: to_int16(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToShort))] -// public static short ToShort(string? a, string? format) { return default!; } -// #endregion -// -// #region ToInt -// /// -// /// A function that represents the EdgeQL version of: to_int32(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToInt))] -// public static int ToInt(string? a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: to_int32(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToInt))] -// public static int ToInt(string? a, string? format) { return default!; } -// #endregion -// -// #region ToLong -// /// -// /// A function that represents the EdgeQL version of: to_int64(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToLong))] -// public static long ToLong(string? a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: to_int64(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToLong))] -// public static long ToLong(string? a, string? format) { return default!; } -// #endregion -// -// #region ToFloat -// /// -// /// A function that represents the EdgeQL version of: to_float32(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToFloat))] -// public static float ToFloat(string? a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: to_float32(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToFloat))] -// public static float ToFloat(string? a, string? format) { return default!; } -// #endregion -// -// #region ToDouble -// /// -// /// A function that represents the EdgeQL version of: to_float64(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToDouble))] -// public static double ToDouble(string? a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: to_float64(, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.NumbersToDouble))] -// public static double ToDouble(string? a, string? format) { return default!; } -// #endregion -// -// #endregion numbers -// -// #region json -// -// #region Index -// /// -// /// A function that represents the EdgeQL version of: [] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.JsonIndex))] -// public static Json Index(Json a, long index) { return default!; } -// #endregion -// -// #region Slice -// /// -// /// A function that represents the EdgeQL version of: [:{2?}] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.JsonSlice))] -// public static Json Slice(Json a, long b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: [:{2?}] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.JsonSlice))] -// public static Json Slice(Json a, long b, long c) { return default!; } -// #endregion -// -// #region Concat -// /// -// /// A function that represents the EdgeQL version of: ++ -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.JsonConcat))] -// public static Json Concat(Json a, Json b) { return default!; } -// #endregion -// -// #region Index -// /// -// /// A function that represents the EdgeQL version of: [] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.JsonIndex))] -// public static Json Index(Json a, string? b) { return default!; } -// #endregion -// -// #region ToJson -// /// -// /// A function that represents the EdgeQL version of: to_json() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.JsonToJson))] -// public static Json ToJson(string? a) { return default!; } -// #endregion -// -// #region UnpackJsonArray -// /// -// /// A function that represents the EdgeQL version of: json_array_unpack() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.JsonUnpackJsonArray))] -// public static IEnumerable UnpackJsonArray(Json a) { return default!; } -// #endregion -// -// #region JsonGet -// /// -// /// A function that represents the EdgeQL version of: json_get(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.JsonJsonGet))] -// public static Json? JsonGet(Json a, params string[] path) { return default!; } -// #endregion -// -// #region UnpackJsonObject -// /// -// /// A function that represents the EdgeQL version of: json_object_unpack() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.JsonUnpackJsonObject))] -// public static IEnumerable> UnpackJsonObject(Json a) { return default!; } -// #endregion -// -// #region JsonTypeof -// /// -// /// A function that represents the EdgeQL version of: json_typeof() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.JsonJsonTypeof))] -// public static string? JsonTypeof(Json a) { return default!; } -// #endregion -// -// #endregion json -// -// #region uuid -// -// #region GenerateGuid -// /// -// /// A function that represents the EdgeQL version of: uuid_generate_v1mc() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.UuidGenerateGuid))] -// public static Guid GenerateGuid() { return default!; } -// #endregion -// -// #endregion uuid -// -// #region temporal -// -// #region Add -// /// -// /// A function that represents the EdgeQL version of: + -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalAdd))] -// public static DateTimeOffset Add(DateTimeOffset a, TimeSpan b) { return default!; } -// #endregion -// -// #region Subtract -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalSubtract))] -// public static TimeSpan Subtract(TimeSpan a, TimeSpan b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalSubtract))] -// public static DateTimeOffset Subtract(DateTimeOffset a, TimeSpan b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalSubtract))] -// public static DateTimeOffset Subtract(DateTimeOffset a, DateTimeOffset b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalSubtract))] -// public static DateTime Subtract(DateTime a, TimeSpan b) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: - -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalSubtract))] -// public static DateTimeOffset Subtract(DateTime a, DateTime b) { return default!; } -// #endregion -// -// #region GetCurrentDateTime -// /// -// /// A function that represents the EdgeQL version of: std::datetime_current() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalGetCurrentDateTime))] -// public static DateTimeOffset GetCurrentDateTime() { return default!; } -// #endregion -// -// #region GetTransactionDateTime -// /// -// /// A function that represents the EdgeQL version of: std::datetime_of_transaction() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalGetTransactionDateTime))] -// public static DateTimeOffset GetTransactionDateTime() { return default!; } -// #endregion -// -// #region GetStatementDateTime -// /// -// /// A function that represents the EdgeQL version of: std::datetime_of_statement() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalGetStatementDateTime))] -// public static DateTimeOffset GetStatementDateTime() { return default!; } -// #endregion -// -// #region GetDatetimeElement -// /// -// /// A function that represents the EdgeQL version of: datetime_get(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalGetDatetimeElement))] -// public static double GetDatetimeElement(DateTimeOffset a, DateTimeElement b) { return default!; } -// #endregion -// -// #region GetTimespanElement -// /// -// /// A function that represents the EdgeQL version of: cal::time_get(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalGetTimespanElement))] -// public static double GetTimespanElement(TimeSpan a, TimeSpanElement b) { return default!; } -// #endregion -// -// #region GetLocalDateElement -// /// -// /// A function that represents the EdgeQL version of: cal::date_get(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalGetLocalDateElement))] -// public static double GetLocalDateElement(DateTime a, LocalDateElement b) { return default!; } -// #endregion -// -// #region TruncateDateTimeOffset -// /// -// /// A function that represents the EdgeQL version of: datetime_truncate(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalTruncateDateTimeOffset))] -// public static DateTimeOffset TruncateDateTimeOffset(DateTimeOffset a, DateTimeTruncateUnit b) { return default!; } -// #endregion -// -// #region TruncateTimeSpan -// /// -// /// A function that represents the EdgeQL version of: duration_truncate(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalTruncateTimeSpan))] -// public static TimeSpan TruncateTimeSpan(TimeSpan a, DurationTruncateUnit b) { return default!; } -// #endregion -// -// #region ToDateTimeOffset -// /// -// /// A function that represents the EdgeQL version of: to_datetime(, {1?}, {2?}, {3?}, {4?}, {5?}, {6?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToDateTimeOffset))] -// public static DateTimeOffset ToDateTimeOffset(string? a, string? format) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: to_datetime(, {1?}, {2?}, {3?}, {4?}, {5?}, {6?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToDateTimeOffset))] -// public static DateTimeOffset ToDateTimeOffset(DateTime a, string? timezone) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: to_datetime(, {1?}, {2?}, {3?}, {4?}, {5?}, {6?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToDateTimeOffset))] -// public static DateTimeOffset ToDateTimeOffset(long year, long month, long day, long hour, long min, long sec, string? timezone) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: to_datetime(, {1?}, {2?}, {3?}, {4?}, {5?}, {6?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToDateTimeOffset))] -// public static DateTimeOffset ToDateTimeOffset(decimal unixSeconds) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: to_datetime(, {1?}, {2?}, {3?}, {4?}, {5?}, {6?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToDateTimeOffset))] -// public static DateTimeOffset ToDateTimeOffset(double unixSeconds) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: to_datetime(, {1?}, {2?}, {3?}, {4?}, {5?}, {6?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToDateTimeOffset))] -// public static DateTimeOffset ToDateTimeOffset(long unixSeconds) { return default!; } -// #endregion -// -// #region ToDateTime -// /// -// /// A function that represents the EdgeQL version of: cal::to_local_datetime(, {1?}, {2?}, {3?}, {4?}, {5?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToDateTime))] -// public static DateTime ToDateTime(string? a, string? format) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: cal::to_local_datetime(, {1?}, {2?}, {3?}, {4?}, {5?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToDateTime))] -// public static DateTime ToDateTime(DateTimeOffset a, string? timezone) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: cal::to_local_datetime(, {1?}, {2?}, {3?}, {4?}, {5?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToDateTime))] -// public static DateTime ToDateTime(long year, long month, long day, long hour, long min, long sec) { return default!; } -// #endregion -// -// #region ToLocalDate -// /// -// /// A function that represents the EdgeQL version of: cal::to_local_date(, {1?}, {2?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToLocalDate))] -// public static DateTime ToLocalDate(string? a, string? format) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: cal::to_local_date(, {1?}, {2?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToLocalDate))] -// public static DateTime ToLocalDate(DateTimeOffset a, string? timezone) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: cal::to_local_date(, {1?}, {2?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToLocalDate))] -// public static DateTime ToLocalDate(long year, long month, long day) { return default!; } -// #endregion -// -// #region ToLocalTime -// /// -// /// A function that represents the EdgeQL version of: cal::to_local_time(, {1?}, {2?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToLocalTime))] -// public static TimeSpan ToLocalTime(string? a, string? format) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: cal::to_local_time(, {1?}, {2?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToLocalTime))] -// public static TimeSpan ToLocalTime(DateTimeOffset a, string? timezone) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: cal::to_local_time(, {1?}, {2?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToLocalTime))] -// public static TimeSpan ToLocalTime(long hour, long minute, double second) { return default!; } -// #endregion -// -// #region ToTimeSpan -// /// -// /// A function that represents the EdgeQL version of: to_duration(<hours := {0?}>, <minutes := {1?}>, <seconds := {2?}> <microseconds := {3?}>) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToTimeSpan))] -// public static TimeSpan ToTimeSpan(long? hours = null, long? minutes = null, double? seconds = null, double? microseconds = null) { return default!; } -// #endregion -// -// #region TimeSpanToSeconds -// /// -// /// A function that represents the EdgeQL version of: std::duration_to_seconds() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalTimeSpanToSeconds))] -// public static decimal TimeSpanToSeconds(TimeSpan a) { return default!; } -// #endregion -// -// #region ToRelativeDuration -// /// -// /// A function that represents the EdgeQL version of: cal::to_relative_duration(<years := {0?}>, <months := {1?}>, <days := {2?}>, <hours := {3?}>, <minutes := {4?}>, <seconds := {5?}>, <microseconds := {6?}>) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TemporalToRelativeDuration))] -// public static TimeSpan ToRelativeDuration(long? years = null, long? months = null, long? days = null, long? hours = null, long? minutes = null, long? seconds = null, long? microseconds = null) { return default!; } -// #endregion -// -// #endregion temporal -// -// #region bytes -// -// #region Index -// /// -// /// A function that represents the EdgeQL version of: [] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.BytesIndex))] -// public static byte[] Index(byte[] a, long index) { return default!; } -// #endregion -// -// #region Slice -// /// -// /// A function that represents the EdgeQL version of: [:{2?}] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.BytesSlice))] -// public static byte[] Slice(byte[] a, long startIndex) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: [:{2?}] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.BytesSlice))] -// public static byte[] Slice(byte[] a, long startIndex, long endIndex) { return default!; } -// #endregion -// -// #region Concat -// /// -// /// A function that represents the EdgeQL version of: ++ -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.BytesConcat))] -// public static byte[] Concat(byte[] a, byte[] b) { return default!; } -// #endregion -// -// #region GetBit -// /// -// /// A function that represents the EdgeQL version of: bytes_get_bit(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.BytesGetBit))] -// public static long GetBit(byte[] a, long bitIndex) { return default!; } -// #endregion -// -// #endregion bytes -// -// #region sequence -// -// #region IncrementSequence -// /// -// /// A function that represents the EdgeQL version of: sequence_next(<introspect typeof >) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SequenceIncrementSequence))] -// public static long IncrementSequence(long seq) { return default!; } -// #endregion -// -// #region ResetSequence -// /// -// /// A function that represents the EdgeQL version of: sequence_reset(<introspect typeof >, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SequenceResetSequence))] -// public static long ResetSequence(long seq) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: sequence_reset(<introspect typeof >, {1?}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SequenceResetSequence))] -// public static long ResetSequence(long seq, long resetTo) { return default!; } -// #endregion -// -// #endregion sequence -// -// #region array -// -// #region Index -// /// -// /// A function that represents the EdgeQL version of: [] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.ArrayIndex))] -// public static TType Index(IEnumerable a, long index) { return default!; } -// #endregion -// -// #region Slice -// /// -// /// A function that represents the EdgeQL version of: [:{2?}] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.ArraySlice))] -// public static IEnumerable Slice(IEnumerable a, long startIndex) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: [:{2?}] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.ArraySlice))] -// public static IEnumerable Slice(IEnumerable a, long startIndex, long endIndex) { return default!; } -// #endregion -// -// #region Concat -// /// -// /// A function that represents the EdgeQL version of: ++ -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.ArrayConcat))] -// public static IEnumerable Concat(IEnumerable a, IEnumerable b) { return default!; } -// #endregion -// -// #region Aggregate -// /// -// /// A function that represents the EdgeQL version of: array_agg() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.ArrayAggregate))] -// public static IEnumerable Aggregate(IEnumerable a) { return default!; } -// #endregion -// -// #region IndexOrDefault -// /// -// /// A function that represents the EdgeQL version of: array_get(, , <default := {2?}>) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.ArrayIndexOrDefault))] -// public static TType? IndexOrDefault(IEnumerable a, long index, TType? defaultValue = default) { return default!; } -// #endregion -// -// #region UnpackArray -// /// -// /// A function that represents the EdgeQL version of: array_unpack() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.ArrayUnpackArray))] -// public static IEnumerable UnpackArray(IEnumerable a) { return default!; } -// #endregion -// -// #region Join -// /// -// /// A function that represents the EdgeQL version of: array_join(, ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.ArrayJoin))] -// public static string? Join(IEnumerable a, string? delimiter) { return default!; } -// #endregion -// -// #endregion array -// -// #region sets -// -// #region Distinct -// /// -// /// A function that represents the EdgeQL version of: distinct -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsDistinct))] -// public static IEnumerable Distinct(IEnumerable a) { return default!; } -// #endregion -// -// #region Contains -// /// -// /// A function that represents the EdgeQL version of: in -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsContains))] -// public static bool Contains(IEnumerable a, TType element) { return default!; } -// #endregion -// -// #region Union -// /// -// /// A function that represents the EdgeQL version of: union -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsUnion))] -// public static IEnumerable Union(IEnumerable a, IEnumerable b) { return default!; } -// #endregion -// -// #region Conditional -// /// -// /// A function that represents the EdgeQL version of: if else -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsConditional))] -// public static TType Conditional(bool condition, TType trueReturn, TType falseReturn) { return default!; } -// #endregion -// -// #region Coalesce -// /// -// /// A function that represents the EdgeQL version of: ?? -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsCoalesce))] -// public static TType Coalesce(TType? a, TType b) { return default!; } -// #endregion -// -// #region Detached -// /// -// /// A function that represents the EdgeQL version of: detached -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsDetached))] -// public static TType Detached(TType a) { return default!; } -// #endregion -// -// #region NotNull -// /// -// /// A function that represents the EdgeQL version of: exists -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsNotNull))] -// public static bool NotNull(TType value) { return default!; } -// #endregion -// -// #region CastIfTypeIs -// /// -// /// A function that represents the EdgeQL version of: [is ] -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsCastIfTypeIs))] -// [ParameterMap(1, "TDesired")] -// public static TDesired CastIfTypeIs(object? a) { return default!; } -// #endregion -// -// #region AssertDistinct -// /// -// /// A function that represents the EdgeQL version of: assert_distinct() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsAssertDistinct))] -// public static IEnumerable AssertDistinct(IEnumerable a) { return default!; } -// #endregion -// -// #region AssertSingle -// /// -// /// A function that represents the EdgeQL version of: assert_single() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsAssertSingle))] -// public static TType AssertSingle(IEnumerable a) { return default!; } -// #endregion -// -// #region AssertNotNull -// /// -// /// A function that represents the EdgeQL version of: assert_exists() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsAssertNotNull))] -// public static TType AssertNotNull(TType? a) { return default!; } -// #endregion -// -// #region Count -// /// -// /// A function that represents the EdgeQL version of: count() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsCount))] -// public static long Count(IEnumerable a) { return default!; } -// -// #endregion -// -// #region Enumerate -// /// -// /// A function that represents the EdgeQL version of: enumerate() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsEnumerate))] -// public static IEnumerable> Enumerate(IEnumerable a) { return default!; } -// #endregion -// -// #region Min -// /// -// /// A function that represents the EdgeQL version of: min() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsMin))] -// public static TType Min(IEnumerable a) { return default!; } -// #endregion -// -// #region Max -// /// -// /// A function that represents the EdgeQL version of: max() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.SetsMax))] -// public static TType Max(IEnumerable a) { return default!; } -// #endregion -// -// #endregion sets -// -// #region types -// -// #region Is -// /// -// /// A function that represents the EdgeQL version of: is -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TypesIs))] -// [ParameterMap(1, "TType")] -// public static bool Is(object? a) { return default!; } -// #endregion -// -// #region Is -// /// -// /// A function that represents the EdgeQL version of: is -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TypesIs))] -// public static bool Is(object? a, Type b) { return default!; } -// #endregion -// -// #region IsNot -// /// -// /// A function that represents the EdgeQL version of: is not -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TypesIsNot))] -// [ParameterMap(1, "TType")] -// public static bool IsNot(object? a) { return default!; } -// #endregion -// -// #region TypeUnion -// /// -// /// A function that represents the EdgeQL version of: ( | { | :2+}) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TypesTypeUnion))] -// public static Type TypeUnion(Type a, Type b, params Type[] additional) { return default!; } -// #endregion -// -// #region Cast -// /// -// /// A function that represents the EdgeQL version of: <> -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TypesCast))] -// [ParameterMap(0, "TType")] -// public static TType Cast(object? a) { return default!; } -// #endregion -// -// #region GetType -// /// -// /// A function that represents the EdgeQL version of: introspect (typeof ) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TypesGetType))] -// public static Type GetType(object? a) { return default!; } -// #endregion -// -// #region IsTypeOf -// /// -// /// A function that represents the EdgeQL version of: is typeof -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TypesIsTypeOf))] -// public static bool IsTypeOf(object? a, object? b) { return default!; } -// #endregion -// -// #region IsNotTypeOf -// /// -// /// A function that represents the EdgeQL version of: is not typeof -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TypesIsNotTypeOf))] -// public static bool IsNotTypeOf(object? a, object? b) { return default!; } -// #endregion -// -// #region Introspect -// /// -// /// A function that represents the EdgeQL version of: introspect -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.TypesIntrospect))] -// public static Type Introspect(Type a) { return default!; } -// #endregion -// -// #endregion types -// -// #region math -// -// #region Abs -// /// -// /// A function that represents the EdgeQL version of: math::abs() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathAbs))] -// public static short Abs(short a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::abs() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathAbs))] -// public static int Abs(int a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::abs() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathAbs))] -// public static long Abs(long a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::abs() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathAbs))] -// public static float Abs(float a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::abs() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathAbs))] -// public static double Abs(double a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::abs() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathAbs))] -// public static decimal Abs(decimal a) { return default!; } -// #endregion -// -// #region Ceil -// /// -// /// A function that represents the EdgeQL version of: math::ceil() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathCeil))] -// public static double Ceil(long a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::ceil() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathCeil))] -// public static double Ceil(double a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::ceil() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathCeil))] -// public static BigInteger Ceil(BigInteger a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::ceil() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathCeil))] -// public static decimal Ceil(decimal a) { return default!; } -// #endregion -// -// #region Floor -// /// -// /// A function that represents the EdgeQL version of: math::floor() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathFloor))] -// public static double Floor(long a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::floor() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathFloor))] -// public static double Floor(double a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::floor() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathFloor))] -// public static BigInteger Floor(BigInteger a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::floor() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathFloor))] -// public static decimal Floor(decimal a) { return default!; } -// #endregion -// -// #region NaturalLog -// /// -// /// A function that represents the EdgeQL version of: math::ln() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathNaturalLog))] -// public static double NaturalLog(long a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::ln() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathNaturalLog))] -// public static double NaturalLog(double a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::ln() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathNaturalLog))] -// public static decimal NaturalLog(decimal a) { return default!; } -// #endregion -// -// #region Logarithm -// /// -// /// A function that represents the EdgeQL version of: math::lg() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathLogarithm))] -// public static double Logarithm(long a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::lg() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathLogarithm))] -// public static double Logarithm(double a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::lg() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathLogarithm))] -// public static decimal Logarithm(decimal a) { return default!; } -// #endregion -// -// #region Logarithm -// /// -// /// A function that represents the EdgeQL version of: math::log( <base := >) -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathLogarithm))] -// public static decimal Logarithm(decimal a, decimal numericBase) { return default!; } -// #endregion -// -// #region Mean -// /// -// /// A function that represents the EdgeQL version of: math::mean() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathMean))] -// public static double Mean(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::mean() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathMean))] -// public static double Mean(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::mean() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathMean))] -// public static decimal Mean(IEnumerable a) { return default!; } -// #endregion -// -// #region StandardDeviation -// /// -// /// A function that represents the EdgeQL version of: math::stddev() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathStandardDeviation))] -// public static double StandardDeviation(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::stddev() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathStandardDeviation))] -// public static double StandardDeviation(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::stddev() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathStandardDeviation))] -// public static decimal StandardDeviation(IEnumerable a) { return default!; } -// #endregion -// -// #region StandardDeviationPop -// /// -// /// A function that represents the EdgeQL version of: math::stddev_pop() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathStandardDeviationPop))] -// public static double StandardDeviationPop(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::stddev_pop() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathStandardDeviationPop))] -// public static double StandardDeviationPop(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::stddev_pop() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathStandardDeviationPop))] -// public static decimal StandardDeviationPop(IEnumerable a) { return default!; } -// #endregion -// -// #region Variance -// /// -// /// A function that represents the EdgeQL version of: math::var() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathVariance))] -// public static double Variance(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::var() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathVariance))] -// public static double Variance(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::var() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathVariance))] -// public static decimal Variance(IEnumerable a) { return default!; } -// #endregion -// -// #region VariancePop -// /// -// /// A function that represents the EdgeQL version of: math::var_pop() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathVariancePop))] -// public static double VariancePop(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::var_pop() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathVariancePop))] -// public static double VariancePop(IEnumerable a) { return default!; } -// /// -// /// A function that represents the EdgeQL version of: math::var_pop() -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.MathVariancePop))] -// public static decimal VariancePop(IEnumerable a) { return default!; } -// #endregion -// -// #endregion math -// -// #region links -// -// #region AddLink -// /// -// /// A function that represents the EdgeQL version of: += -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.LinksAddLink))] -// public static TSource AddLink(TSource source, TType element) where TSource : IEnumerable? { return default!; } -// #endregion -// -// #region RemoveLink -// /// -// /// A function that represents the EdgeQL version of: -= -// /// -// [EquivalentOperator(typeof(EdgeDB.Operators.LinksRemoveLink))] -// public static TSource RemoveLink(TSource source, TType element) where TSource : IEnumerable? { return default!; } -// #endregion -// -// #endregion links -// -// #region variables -// -// #endregion variables -// -// internal static Dictionary FunctionOperators = new() -// { -// { "String.ToLower", new StringToLower()}, -// { "String.ToUpper", new StringToUpper()}, -// { "Enumerable.Concat", new SetsUnion()}, -// } -// ; -// } -// } -// #nullable restore -// #pragma warning restore +#nullable restore +#pragma warning disable +using EdgeDB.DataTypes; +using System.Numerics; +using EdgeDB.Models.DataTypes; +using DateTime = System.DateTime; + +namespace EdgeDB +{ + public sealed partial class EdgeQL + { + /// + /// Check that the input set contains at most one element, raise CardinalityViolationError otherwise. + /// + [EdgeQLFunction("assert_single", "std", "anytype", false, true)] + public static TType? AssertSingle(IEnumerable input, String? message = null) + => default!; + /// + /// Check that the input set contains at least one element, raise CardinalityViolationError otherwise. + /// + [EdgeQLFunction("assert_exists", "std", "anytype", true, false)] + public static IEnumerable AssertExists(IEnumerable input, String? message = null) + => default!; + /// + /// Check that the input set is a proper set, i.e. all elements are unique + /// + [EdgeQLFunction("assert_distinct", "std", "anytype", true, false)] + public static IEnumerable AssertDistinct(IEnumerable input, String? message = null) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("min", "std", "anytype", false, true)] + public static TType? Min(IEnumerable vals) + => default!; + /// + /// Return the greatest value of the input set. + /// + [EdgeQLFunction("max", "std", "anytype", false, true)] + public static TType? Max(IEnumerable vals) + => default!; + /// + /// Return the element of *array* at the specified *index*. + /// + [EdgeQLFunction("array_get", "std", "anytype", false, true)] + public static TType? ArrayGet(IEnumerable array, Int64 idx, TType? @default = default) + => default!; + /// + /// Return array elements as a set. + /// + [EdgeQLFunction("array_unpack", "std", "anytype", true, false)] + public static IEnumerable ArrayUnpack(IEnumerable array) + => default!; + [EdgeQLFunction("DISTINCT", "std", "anytype", true, false)] + public static IEnumerable Distinct(IEnumerable s = default) + => default!; + [EdgeQLFunction("UNION", "std", "anytype", true, false)] + public static IEnumerable Union(IEnumerable s1 = default, IEnumerable s2 = default) + => default!; + [EdgeQLFunction("EXCEPT", "std", "anytype", true, false)] + public static IEnumerable Except(IEnumerable s1 = default, IEnumerable s2 = default) + => default!; + [EdgeQLFunction("INTERSECT", "std", "anytype", true, false)] + public static IEnumerable Intersect(IEnumerable s1 = default, IEnumerable s2 = default) + => default!; + /// + /// Assert that a boolean value is true. + /// + [EdgeQLFunction("assert", "std", "std::bool", false, false)] + public static Boolean Assert(Boolean input, String? message = null) + => default!; + /// + /// Generalized boolean `AND` applied to the set of *values*. + /// + [EdgeQLFunction("all", "std", "std::bool", false, false)] + public static Boolean All(IEnumerable vals) + => default!; + /// + /// Generalized boolean `OR` applied to the set of *values*. + /// + [EdgeQLFunction("any", "std", "std::bool", false, false)] + public static Boolean Any(IEnumerable vals) + => default!; + /// + /// A polymorphic function to test if a sequence contains a certain element. + /// + [EdgeQLFunction("contains", "std", "std::bool", false, false)] + public static Boolean Contains(String haystack, String needle) + => default!; + /// + /// A polymorphic function to test if a sequence contains a certain element. + /// + [EdgeQLFunction("contains", "std", "std::bool", false, false)] + public static Boolean Contains(Byte[] haystack, Byte[] needle) + => default!; + /// + /// A polymorphic function to test if a sequence contains a certain element. + /// + [EdgeQLFunction("contains", "std", "std::bool", false, false)] + public static Boolean Contains(IEnumerable haystack, TType needle) + => default!; + /// + /// A polymorphic function to test if one JSON value contains another JSON value. + /// + [EdgeQLFunction("contains", "std", "std::bool", false, false)] + public static Boolean Contains(Json haystack, Json needle) + => default!; + [EdgeQLFunction("strictly_above", "std", "std::bool", false, false)] + public static Boolean StrictlyAbove(MultiRange l, MultiRange r) + where TPoint : struct + => default!; + /// + /// Test if a regular expression has a match in a string. + /// + [EdgeQLFunction("re_test", "std", "std::bool", false, false)] + public static Boolean ReTest(String pattern, String str) + => default!; + [EdgeQLFunction("range_is_empty", "std", "std::bool", false, false)] + public static Boolean RangeIsEmpty(Range val) + where TPoint : struct + => default!; + [EdgeQLFunction("range_is_inclusive_upper", "std", "std::bool", false, false)] + public static Boolean RangeIsInclusiveUpper(Range r) + where TPoint : struct + => default!; + [EdgeQLFunction("range_is_inclusive_lower", "std", "std::bool", false, false)] + public static Boolean RangeIsInclusiveLower(Range r) + where TPoint : struct + => default!; + [EdgeQLFunction("contains", "std", "std::bool", false, false)] + public static Boolean Contains(Range haystack, Range needle) + where TPoint : struct + => default!; + [EdgeQLFunction("overlaps", "std", "std::bool", false, false)] + public static Boolean Overlaps(Range l, Range r) + where TPoint : struct + => default!; + [EdgeQLFunction("strictly_below", "std", "std::bool", false, false)] + public static Boolean StrictlyBelow(Range l, Range r) + where TPoint : struct + => default!; + [EdgeQLFunction("bounded_above", "std", "std::bool", false, false)] + public static Boolean BoundedAbove(Range l, Range r) + where TPoint : struct + => default!; + [EdgeQLFunction("bounded_below", "std", "std::bool", false, false)] + public static Boolean BoundedBelow(Range l, Range r) + where TPoint : struct + => default!; + [EdgeQLFunction("adjacent", "std", "std::bool", false, false)] + public static Boolean Adjacent(Range l, Range r) + where TPoint : struct + => default!; + [EdgeQLFunction("contains", "std", "std::bool", false, false)] + public static Boolean Contains(Range haystack, DateOnly needle) + => default!; + [EdgeQLFunction("contains", "std", "std::bool", false, false)] + public static Boolean Contains(MultiRange haystack, DateOnly needle) + => default!; + [EdgeQLFunction("IN", "std", "std::bool", false, false)] + public static Boolean In(TType e = default, IEnumerable s = default) + => default!; + [EdgeQLFunction("NOT IN", "std", "std::bool", false, false)] + public static Boolean NotIn(TType e = default, IEnumerable s = default) + => default!; + [EdgeQLFunction("EXISTS", "std", "std::bool", false, false)] + public static Boolean Exists(IEnumerable s = default) + => default!; + [EdgeQLFunction("LIKE", "std", "std::bool", false, false)] + public static Boolean Like(String str = null, String pattern = null) + => default!; + [EdgeQLFunction("ILIKE", "std", "std::bool", false, false)] + public static Boolean ILike(String str = null, String pattern = null) + => default!; + [EdgeQLFunction("NOT LIKE", "std", "std::bool", false, false)] + public static Boolean NotLike(String str = null, String pattern = null) + => default!; + [EdgeQLFunction("NOT ILIKE", "std", "std::bool", false, false)] + public static Boolean NotILike(String str = null, String pattern = null) + => default!; + /// + /// A polymorphic function to calculate a "length" of its first argument. + /// + [EdgeQLFunction("len", "std", "std::int64", false, false)] + public static Int64 Len(String str) + => default!; + /// + /// A polymorphic function to calculate a "length" of its first argument. + /// + [EdgeQLFunction("len", "std", "std::int64", false, false)] + public static Int64 Len(Byte[] bytes) + => default!; + /// + /// A polymorphic function to calculate a "length" of its first argument. + /// + [EdgeQLFunction("len", "std", "std::int64", false, false)] + public static Int64 Len(IEnumerable array) + => default!; + /// + /// Return the sum of the set of numbers. + /// + [EdgeQLFunction("sum", "std", "std::int64", false, false)] + public static Int64 Sum(IEnumerable s) + => default!; + /// + /// Return the sum of the set of numbers. + /// + [EdgeQLFunction("sum", "std", "std::int64", false, false)] + public static Int64 Sum(IEnumerable s) + => default!; + /// + /// Return the number of elements in a set. + /// + [EdgeQLFunction("count", "std", "std::int64", false, false)] + public static Int64 Count(IEnumerable s) + => default!; + /// + /// Round to the nearest value. + /// + [EdgeQLFunction("round", "std", "std::int64", false, false)] + public static Int64 Round(Int64 val) + => default!; + /// + /// A polymorphic function to find index of an element in a sequence. + /// + [EdgeQLFunction("find", "std", "std::int64", false, false)] + public static Int64 Find(String haystack, String needle) + => default!; + /// + /// A polymorphic function to find index of an element in a sequence. + /// + [EdgeQLFunction("find", "std", "std::int64", false, false)] + public static Int64 Find(Byte[] haystack, Byte[] needle) + => default!; + /// + /// A polymorphic function to find index of an element in a sequence. + /// + [EdgeQLFunction("find", "std", "std::int64", false, false)] + public static Int64 Find(IEnumerable haystack, TType needle, Int64 from_pos = 0) + => default!; + /// + /// Bitwise AND operator for 64-bit integers. + /// + [EdgeQLFunction("bit_and", "std", "std::int64", false, false)] + public static Int64 BitAnd(Int64 l, Int64 r) + => default!; + /// + /// Bitwise OR operator for 64-bit integers. + /// + [EdgeQLFunction("bit_or", "std", "std::int64", false, false)] + public static Int64 BitOr(Int64 l, Int64 r) + => default!; + /// + /// Bitwise exclusive OR operator for 64-bit integers. + /// + [EdgeQLFunction("bit_xor", "std", "std::int64", false, false)] + public static Int64 BitXor(Int64 l, Int64 r) + => default!; + /// + /// Bitwise NOT operator for 64-bit integers. + /// + [EdgeQLFunction("bit_not", "std", "std::int64", false, false)] + public static Int64 BitNot(Int64 r) + => default!; + /// + /// Bitwise right-shift operator for 64-bit integers. + /// + [EdgeQLFunction("bit_rshift", "std", "std::int64", false, false)] + public static Int64 BitRshift(Int64 val, Int64 n) + => default!; + /// + /// Bitwise left-shift operator for 64-bit integers. + /// + [EdgeQLFunction("bit_lshift", "std", "std::int64", false, false)] + public static Int64 BitLshift(Int64 val, Int64 n) + => default!; + /// + /// Get the *nth* bit of the *bytes* value. + /// + [EdgeQLFunction("bytes_get_bit", "std", "std::int64", false, false)] + public static Int64 BytesGetBit(Byte[] bytes, Int64 num) + => default!; + [EdgeQLFunction("range_unpack", "std", "std::int64", true, false)] + public static IEnumerable RangeUnpack(Range val) + => default!; + [EdgeQLFunction("range_unpack", "std", "std::int64", true, false)] + public static IEnumerable RangeUnpack(Range val, Int64 step) + => default!; + [EdgeQLFunction("sequence_reset", "std", "std::int64", false, false)] + public static Int64 SequenceReset(Type seq, Int64 value) + => default!; + /// + /// Create a `int64` value. + /// + [EdgeQLFunction("to_int64", "std", "std::int64", false, false)] + public static Int64 ToInt64(String s, String? fmt = null) + => default!; + [EdgeQLFunction("sequence_reset", "std", "std::int64", false, false)] + public static Int64 SequenceReset(Type seq) + => default!; + [EdgeQLFunction("sequence_next", "std", "std::int64", false, false)] + public static Int64 SequenceNext(Type seq) + => default!; + /// + /// Round up to the nearest integer. + /// + [EdgeQLFunction("ceil", "math", "std::int64", false, false)] + public static Int64 Ceil(Int64 x) + => default!; + /// + /// Round down to the nearest integer. + /// + [EdgeQLFunction("floor", "math", "std::int64", false, false)] + public static Int64 Floor(Int64 x) + => default!; + /// + /// Return the sum of the set of numbers. + /// + [EdgeQLFunction("sum", "std", "std::bigint", false, false)] + public static BigInteger Sum(IEnumerable s) + => default!; + /// + /// Round to the nearest value. + /// + [EdgeQLFunction("round", "std", "std::bigint", false, false)] + public static BigInteger Round(BigInteger val) + => default!; + /// + /// Create a `bigint` value. + /// + [EdgeQLFunction("to_bigint", "std", "std::bigint", false, false)] + public static BigInteger ToBigint(String s, String? fmt = null) + => default!; + /// + /// Round up to the nearest integer. + /// + [EdgeQLFunction("ceil", "math", "std::bigint", false, false)] + public static BigInteger Ceil(BigInteger x) + => default!; + /// + /// Round down to the nearest integer. + /// + [EdgeQLFunction("floor", "math", "std::bigint", false, false)] + public static BigInteger Floor(BigInteger x) + => default!; + /// + /// Return the sum of the set of numbers. + /// + [EdgeQLFunction("sum", "std", "std::decimal", false, false)] + public static Decimal Sum(IEnumerable s) + => default!; + /// + /// Round to the nearest value. + /// + [EdgeQLFunction("round", "std", "std::decimal", false, false)] + public static Decimal Round(Decimal val) + => default!; + /// + /// Round to the nearest value. + /// + [EdgeQLFunction("round", "std", "std::decimal", false, false)] + public static Decimal Round(Decimal val, Int64 d) + => default!; + /// + /// Return duration as total number of seconds in interval. + /// + [EdgeQLFunction("duration_to_seconds", "std", "std::decimal", false, false)] + public static Decimal DurationToSeconds(TimeSpan dur) + => default!; + [EdgeQLFunction("range_unpack", "std", "std::decimal", true, false)] + public static IEnumerable RangeUnpack(Range val, Decimal step) + => default!; + /// + /// Create a `decimal` value. + /// + [EdgeQLFunction("to_decimal", "std", "std::decimal", false, false)] + public static Decimal ToDecimal(String s, String? fmt = null) + => default!; + /// + /// Round up to the nearest integer. + /// + [EdgeQLFunction("ceil", "math", "std::decimal", false, false)] + public static Decimal Ceil(Decimal x) + => default!; + /// + /// Round down to the nearest integer. + /// + [EdgeQLFunction("floor", "math", "std::decimal", false, false)] + public static Decimal Floor(Decimal x) + => default!; + /// + /// Return the natural logarithm of the input value. + /// + [EdgeQLFunction("ln", "math", "std::decimal", false, false)] + public static Decimal Ln(Decimal x) + => default!; + /// + /// Return the base 10 logarithm of the input value. + /// + [EdgeQLFunction("lg", "math", "std::decimal", false, false)] + public static Decimal Lg(Decimal x) + => default!; + /// + /// Return the logarithm of the input value in the specified *base*. + /// + [EdgeQLFunction("log", "math", "std::decimal", false, false)] + public static Decimal Log(Decimal x, Decimal @base) + => default!; + /// + /// Return the square root of the input value. + /// + [EdgeQLFunction("sqrt", "math", "std::decimal", false, false)] + public static Decimal Sqrt(Decimal x) + => default!; + /// + /// Return the arithmetic mean of the input set. + /// + [EdgeQLFunction("mean", "math", "std::decimal", false, false)] + public static Decimal Mean(IEnumerable vals) + => default!; + /// + /// Return the sample standard deviation of the input set. + /// + [EdgeQLFunction("stddev", "math", "std::decimal", false, false)] + public static Decimal Stddev(IEnumerable vals) + => default!; + /// + /// Return the population standard deviation of the input set. + /// + [EdgeQLFunction("stddev_pop", "math", "std::decimal", false, false)] + public static Decimal StddevPop(IEnumerable vals) + => default!; + /// + /// Return the sample variance of the input set. + /// + [EdgeQLFunction("var", "math", "std::decimal", false, true)] + public static Decimal? Var(IEnumerable vals) + => default!; + /// + /// Return the population variance of the input set. + /// + [EdgeQLFunction("var_pop", "math", "std::decimal", false, true)] + public static Decimal? VarPop(IEnumerable vals) + => default!; + /// + /// Return the sum of the set of numbers. + /// + [EdgeQLFunction("sum", "std", "std::float32", false, false)] + public static Single Sum(IEnumerable s) + => default!; + [EdgeQLFunction("range_unpack", "std", "std::float32", true, false)] + public static IEnumerable RangeUnpack(Range val, Single step) + => default!; + /// + /// Create a `float32` value. + /// + [EdgeQLFunction("to_float32", "std", "std::float32", false, false)] + public static Single ToFloat32(String s, String? fmt = null) + => default!; + /// + /// Return the sum of the set of numbers. + /// + [EdgeQLFunction("sum", "std", "std::float64", false, false)] + public static Double Sum(IEnumerable s) + => default!; + /// + /// Return a pseudo-random number in the range `0.0 <= x < 1.0` + /// + [EdgeQLFunction("random", "std", "std::float64", false, false)] + public static Double Random() + => default!; + /// + /// Round to the nearest value. + /// + [EdgeQLFunction("round", "std", "std::float64", false, false)] + public static Double Round(Double val) + => default!; + /// + /// Extract a specific element of input datetime by name. + /// + [EdgeQLFunction("datetime_get", "std", "std::float64", false, false)] + public static Double DatetimeGet(DateTimeOffset dt, String el) + => default!; + /// + /// Extract a specific element of input duration by name. + /// + [EdgeQLFunction("duration_get", "std", "std::float64", false, false)] + public static Double DurationGet(TimeSpan dt, String el) + => default!; + [EdgeQLFunction("range_unpack", "std", "std::float64", true, false)] + public static IEnumerable RangeUnpack(Range val, Double step) + => default!; + /// + /// Create a `float64` value. + /// + [EdgeQLFunction("to_float64", "std", "std::float64", false, false)] + public static Double ToFloat64(String s, String? fmt = null) + => default!; + /// + /// Round up to the nearest integer. + /// + [EdgeQLFunction("ceil", "math", "std::float64", false, false)] + public static Double Ceil(Double x) + => default!; + /// + /// Round down to the nearest integer. + /// + [EdgeQLFunction("floor", "math", "std::float64", false, false)] + public static Double Floor(Double x) + => default!; + /// + /// Return the natural logarithm of the input value. + /// + [EdgeQLFunction("ln", "math", "std::float64", false, false)] + public static Double Ln(Int64 x) + => default!; + /// + /// Return the natural logarithm of the input value. + /// + [EdgeQLFunction("ln", "math", "std::float64", false, false)] + public static Double Ln(Double x) + => default!; + /// + /// Return the base 10 logarithm of the input value. + /// + [EdgeQLFunction("lg", "math", "std::float64", false, false)] + public static Double Lg(Int64 x) + => default!; + /// + /// Return the base 10 logarithm of the input value. + /// + [EdgeQLFunction("lg", "math", "std::float64", false, false)] + public static Double Lg(Double x) + => default!; + /// + /// Return the square root of the input value. + /// + [EdgeQLFunction("sqrt", "math", "std::float64", false, false)] + public static Double Sqrt(Int64 x) + => default!; + /// + /// Return the square root of the input value. + /// + [EdgeQLFunction("sqrt", "math", "std::float64", false, false)] + public static Double Sqrt(Double x) + => default!; + /// + /// Return the arithmetic mean of the input set. + /// + [EdgeQLFunction("mean", "math", "std::float64", false, false)] + public static Double Mean(IEnumerable vals) + => default!; + /// + /// Return the arithmetic mean of the input set. + /// + [EdgeQLFunction("mean", "math", "std::float64", false, false)] + public static Double Mean(IEnumerable vals) + => default!; + /// + /// Return the sample standard deviation of the input set. + /// + [EdgeQLFunction("stddev", "math", "std::float64", false, false)] + public static Double Stddev(IEnumerable vals) + => default!; + /// + /// Return the sample standard deviation of the input set. + /// + [EdgeQLFunction("stddev", "math", "std::float64", false, false)] + public static Double Stddev(IEnumerable vals) + => default!; + /// + /// Return the population standard deviation of the input set. + /// + [EdgeQLFunction("stddev_pop", "math", "std::float64", false, false)] + public static Double StddevPop(IEnumerable vals) + => default!; + /// + /// Return the population standard deviation of the input set. + /// + [EdgeQLFunction("stddev_pop", "math", "std::float64", false, false)] + public static Double StddevPop(IEnumerable vals) + => default!; + /// + /// Return the sample variance of the input set. + /// + [EdgeQLFunction("var", "math", "std::float64", false, true)] + public static Double? Var(IEnumerable vals) + => default!; + /// + /// Return the sample variance of the input set. + /// + [EdgeQLFunction("var", "math", "std::float64", false, true)] + public static Double? Var(IEnumerable vals) + => default!; + /// + /// Return the population variance of the input set. + /// + [EdgeQLFunction("var_pop", "math", "std::float64", false, true)] + public static Double? VarPop(IEnumerable vals) + => default!; + /// + /// Return the population variance of the input set. + /// + [EdgeQLFunction("var_pop", "math", "std::float64", false, true)] + public static Double? VarPop(IEnumerable vals) + => default!; + /// + /// Extract a specific element of input time by name. + /// + [EdgeQLFunction("time_get", "cal", "std::float64", false, false)] + public static Double TimeGet(TimeSpan dt, String el) + => default!; + /// + /// Extract a specific element of input date by name. + /// + [EdgeQLFunction("date_get", "cal", "std::float64", false, false)] + public static Double DateGet(DateOnly dt, String el) + => default!; + /// + /// Extract a specific element of input datetime by name. + /// + [EdgeQLFunction("datetime_get", "std", "std::float64", false, false)] + public static Double DatetimeGet(DateTime dt, String el) + => default!; + /// + /// Return the absolute value of the input *x*. + /// + [EdgeQLFunction("abs", "math", "std::anyreal", false, false)] + public static TReal Abs(TReal x) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("min", "std", "std::str", false, true)] + public static String? Min(IEnumerable vals) + => default!; + /// + /// Return the greatest value of the input set. + /// + [EdgeQLFunction("max", "std", "std::str", false, true)] + public static String? Max(IEnumerable vals) + => default!; + /// + /// Render an array to a string. + /// + [EdgeQLFunction("array_join", "std", "std::str", false, false)] + public static String ArrayJoin(IEnumerable array, String delimiter) + => default!; + /// + /// Return the type of the outermost JSON value as a string. + /// + [EdgeQLFunction("json_typeof", "std", "std::str", false, false)] + public static String JsonTypeof(Json json) + => default!; + /// + /// Replace matching substrings in a given string. + /// + [EdgeQLFunction("re_replace", "std", "std::str", false, false)] + public static String ReReplace(String pattern, String sub, String str, String flags = "") + => default!; + /// + /// Repeat the input *string* *n* times. + /// + [EdgeQLFunction("str_repeat", "std", "std::str", false, false)] + public static String StrRepeat(String s, Int64 n) + => default!; + /// + /// Return a lowercase copy of the input *string*. + /// + [EdgeQLFunction("str_lower", "std", "std::str", false, false)] + public static String StrLower(String s) + => default!; + /// + /// Return an uppercase copy of the input *string*. + /// + [EdgeQLFunction("str_upper", "std", "std::str", false, false)] + public static String StrUpper(String s) + => default!; + /// + /// Return a titlecase copy of the input *string*. + /// + [EdgeQLFunction("str_title", "std", "std::str", false, false)] + public static String StrTitle(String s) + => default!; + /// + /// Return the input string padded at the start to the length *n*. + /// + [EdgeQLFunction("str_pad_start", "std", "std::str", false, false)] + public static String StrPadStart(String s, Int64 n, String fill = " ") + => default!; + /// + /// Return the input string left-padded to the length *n*. + /// + [EdgeQLFunction("str_lpad", "std", "std::str", false, false)] + public static String StrLpad(String s, Int64 n, String fill = " ") + => default!; + /// + /// Return the input string padded at the end to the length *n*. + /// + [EdgeQLFunction("str_pad_end", "std", "std::str", false, false)] + public static String StrPadEnd(String s, Int64 n, String fill = " ") + => default!; + /// + /// Return the input string right-padded to the length *n*. + /// + [EdgeQLFunction("str_rpad", "std", "std::str", false, false)] + public static String StrRpad(String s, Int64 n, String fill = " ") + => default!; + /// + /// Return the input string with all *trim* characters removed from its start. + /// + [EdgeQLFunction("str_trim_start", "std", "std::str", false, false)] + public static String StrTrimStart(String s, String tr = " ") + => default!; + /// + /// Return the input string with all leftmost *trim* characters removed. + /// + [EdgeQLFunction("str_ltrim", "std", "std::str", false, false)] + public static String StrLtrim(String s, String tr = " ") + => default!; + /// + /// Return the input string with all *trim* characters removed from its end. + /// + [EdgeQLFunction("str_trim_end", "std", "std::str", false, false)] + public static String StrTrimEnd(String s, String tr = " ") + => default!; + /// + /// Return the input string with all rightmost *trim* characters removed. + /// + [EdgeQLFunction("str_rtrim", "std", "std::str", false, false)] + public static String StrRtrim(String s, String tr = " ") + => default!; + /// + /// Return the input string with *trim* characters removed from both ends. + /// + [EdgeQLFunction("str_trim", "std", "std::str", false, false)] + public static String StrTrim(String s, String tr = " ") + => default!; + /// + /// Given a string, find a matching substring and replace all its occurrences with a new substring. + /// + [EdgeQLFunction("str_replace", "std", "std::str", false, false)] + public static String StrReplace(String s, String old, String @new) + => default!; + /// + /// Reverse the order of the characters in the string. + /// + [EdgeQLFunction("str_reverse", "std", "std::str", false, false)] + public static String StrReverse(String s) + => default!; + /// + /// Return string representation of the input value. + /// + [EdgeQLFunction("to_str", "std", "std::str", false, false)] + public static String ToStr(DateTimeOffset dt, String? fmt = null) + => default!; + /// + /// Return string representation of the input value. + /// + [EdgeQLFunction("to_str", "std", "std::str", false, false)] + public static String ToStr(TimeSpan td, String? fmt = null) + => default!; + /// + /// Return string representation of the input value. + /// + [EdgeQLFunction("to_str", "std", "std::str", false, false)] + public static String ToStr(Int64 i, String? fmt = null) + => default!; + /// + /// Return string representation of the input value. + /// + [EdgeQLFunction("to_str", "std", "std::str", false, false)] + public static String ToStr(Double f, String? fmt = null) + => default!; + /// + /// Return string representation of the input value. + /// + [EdgeQLFunction("to_str", "std", "std::str", false, false)] + public static String ToStr(BigInteger d, String? fmt = null) + => default!; + /// + /// Return string representation of the input value. + /// + [EdgeQLFunction("to_str", "std", "std::str", false, false)] + public static String ToStr(Decimal d, String? fmt = null) + => default!; + /// + /// Return string representation of the input value. + /// + [EdgeQLFunction("to_str", "std", "std::str", false, false)] + public static String ToStr(IEnumerable array, String delimiter) + => default!; + /// + /// Return string representation of the input value. + /// + [EdgeQLFunction("to_str", "std", "std::str", false, false)] + public static String ToStr(Json json, String? fmt = null) + => default!; + /// + /// Convert a binary UTF-8 string to a text value. + /// + [EdgeQLFunction("to_str", "std", "std::str", false, false)] + public static String ToStr(Byte[] b) + => default!; + /// + /// Return the server version as a string. + /// + [EdgeQLFunction("get_version_as_str", "sys", "std::str", false, false)] + public static String GetVersionAsStr() + => default!; + /// + /// Return the server instance name. + /// + [EdgeQLFunction("get_instance_name", "sys", "std::str", false, false)] + public static String GetInstanceName() + => default!; + /// + /// Return the name of the current database as a string. + /// + [EdgeQLFunction("get_current_database", "sys", "std::str", false, false)] + public static String GetCurrentDatabase() + => default!; + /// + /// Return string representation of the input value. + /// + [EdgeQLFunction("to_str", "std", "std::str", false, false)] + public static String ToStr(DateTime dt, String? fmt = null) + => default!; + /// + /// Return string representation of the input value. + /// + [EdgeQLFunction("to_str", "std", "std::str", false, false)] + public static String ToStr(DateOnly d, String? fmt = null) + => default!; + /// + /// Encode given data as a base64 string + /// + [EdgeQLFunction("base64_encode", "std::enc", "std::str", false, false)] + public static String Base64Encode(Byte[] data, Base64Alphabet alphabet = Base64Alphabet.standard, Boolean padding = true) + => default!; + [EdgeQLFunction("CONCAT", "std", "std::str", false, false)] + public static String Concat(String l = null, String r = null) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("min", "std", "std::datetime", false, true)] + public static DateTimeOffset? Min(IEnumerable vals) + => default!; + /// + /// Return the greatest value of the input set. + /// + [EdgeQLFunction("max", "std", "std::datetime", false, true)] + public static DateTimeOffset? Max(IEnumerable vals) + => default!; + /// + /// Return the current server date and time. + /// + [EdgeQLFunction("datetime_current", "std", "std::datetime", false, false)] + public static DateTimeOffset DatetimeCurrent() + => default!; + /// + /// Return the date and time of the start of the current transaction. + /// + [EdgeQLFunction("datetime_of_transaction", "std", "std::datetime", false, false)] + public static DateTimeOffset DatetimeOfTransaction() + => default!; + /// + /// Return the date and time of the start of the current statement. + /// + [EdgeQLFunction("datetime_of_statement", "std", "std::datetime", false, false)] + public static DateTimeOffset DatetimeOfStatement() + => default!; + /// + /// Truncate the input datetime to a particular precision. + /// + [EdgeQLFunction("datetime_truncate", "std", "std::datetime", false, false)] + public static DateTimeOffset DatetimeTruncate(DateTimeOffset dt, String unit) + => default!; + [EdgeQLFunction("range_unpack", "std", "std::datetime", true, false)] + public static IEnumerable RangeUnpack(Range val, TimeSpan step) + => default!; + /// + /// Create a `datetime` value. + /// + [EdgeQLFunction("to_datetime", "std", "std::datetime", false, false)] + public static DateTimeOffset ToDatetime(String s, String? fmt = null) + => default!; + /// + /// Create a `datetime` value. + /// + [EdgeQLFunction("to_datetime", "std", "std::datetime", false, false)] + public static DateTimeOffset ToDatetime(Int64 year, Int64 month, Int64 day, Int64 hour, Int64 min, Double sec, String timezone) + => default!; + /// + /// Create a `datetime` value. + /// + [EdgeQLFunction("to_datetime", "std", "std::datetime", false, false)] + public static DateTimeOffset ToDatetime(Double epochseconds) + => default!; + /// + /// Create a `datetime` value. + /// + [EdgeQLFunction("to_datetime", "std", "std::datetime", false, false)] + public static DateTimeOffset ToDatetime(Int64 epochseconds) + => default!; + /// + /// Create a `datetime` value. + /// + [EdgeQLFunction("to_datetime", "std", "std::datetime", false, false)] + public static DateTimeOffset ToDatetime(Decimal epochseconds) + => default!; + /// + /// Create a `datetime` value. + /// + [EdgeQLFunction("to_datetime", "std", "std::datetime", false, false)] + public static DateTimeOffset ToDatetime(DateTime local, String zone) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("min", "std", "std::duration", false, true)] + public static TimeSpan? Min(IEnumerable vals) + => default!; + /// + /// Return the greatest value of the input set. + /// + [EdgeQLFunction("max", "std", "std::duration", false, true)] + public static TimeSpan? Max(IEnumerable vals) + => default!; + /// + /// Truncate the input duration to a particular precision. + /// + [EdgeQLFunction("duration_truncate", "std", "std::duration", false, false)] + public static TimeSpan DurationTruncate(TimeSpan dt, String unit) + => default!; + /// + /// Create a `duration` value. + /// + [EdgeQLFunction("to_duration", "std", "std::duration", false, false)] + public static TimeSpan ToDuration(Int64 hours = 0, Int64 minutes = 0, Double seconds = 0, Int64 microseconds = 0) + => default!; + /// + /// Return a set of tuples of the form `(index, element)`. + /// + [EdgeQLFunction("enumerate", "std", "tuple", true, false)] + public static IEnumerable> Enumerate(IEnumerable vals) + => default!; + /// + /// Return set of key/value tuples that make up the JSON object. + /// + [EdgeQLFunction("json_object_unpack", "std", "tuple", true, false)] + public static IEnumerable> JsonObjectUnpack(Json obj) + => default!; + /// + /// Return the server version as a tuple. + /// + [EdgeQLFunction("get_version", "sys", "tuple>", false, false)] + public static ValueTuple> GetVersion() + => default!; + /// + /// Search an object using its fts::index index. Returns objects that match the specified query and the matching score. + /// + [EdgeQLFunction("search", "fts", "tuple", false, true)] + public static ValueTuple? Search(TObject @object, String query, String language = "eng", IEnumerable? weights = null) + => default!; + /// + /// Bitwise AND operator for 16-bit integers. + /// + [EdgeQLFunction("bit_and", "std", "std::int16", false, false)] + public static Int16 BitAnd(Int16 l, Int16 r) + => default!; + /// + /// Bitwise OR operator for 16-bit integers. + /// + [EdgeQLFunction("bit_or", "std", "std::int16", false, false)] + public static Int16 BitOr(Int16 l, Int16 r) + => default!; + /// + /// Bitwise exclusive OR operator for 16-bit integers. + /// + [EdgeQLFunction("bit_xor", "std", "std::int16", false, false)] + public static Int16 BitXor(Int16 l, Int16 r) + => default!; + /// + /// Bitwise NOT operator for 16-bit integers. + /// + [EdgeQLFunction("bit_not", "std", "std::int16", false, false)] + public static Int16 BitNot(Int16 r) + => default!; + /// + /// Bitwise right-shift operator for 16-bit integers. + /// + [EdgeQLFunction("bit_rshift", "std", "std::int16", false, false)] + public static Int16 BitRshift(Int16 val, Int64 n) + => default!; + /// + /// Bitwise left-shift operator for 16-bit integers. + /// + [EdgeQLFunction("bit_lshift", "std", "std::int16", false, false)] + public static Int16 BitLshift(Int16 val, Int64 n) + => default!; + /// + /// Create a `int16` value. + /// + [EdgeQLFunction("to_int16", "std", "std::int16", false, false)] + public static Int16 ToInt16(String s, String? fmt = null) + => default!; + /// + /// Bitwise AND operator for 32-bit integers. + /// + [EdgeQLFunction("bit_and", "std", "std::int32", false, false)] + public static Int32 BitAnd(Int32 l, Int32 r) + => default!; + /// + /// Bitwise OR operator for 32-bit integers. + /// + [EdgeQLFunction("bit_or", "std", "std::int32", false, false)] + public static Int32 BitOr(Int32 l, Int32 r) + => default!; + /// + /// Bitwise exclusive OR operator for 32-bit integers. + /// + [EdgeQLFunction("bit_xor", "std", "std::int32", false, false)] + public static Int32 BitXor(Int32 l, Int32 r) + => default!; + /// + /// Bitwise NOT operator for 32-bit integers. + /// + [EdgeQLFunction("bit_not", "std", "std::int32", false, false)] + public static Int32 BitNot(Int32 r) + => default!; + /// + /// Bitwise right-shift operator for 32-bit integers. + /// + [EdgeQLFunction("bit_rshift", "std", "std::int32", false, false)] + public static Int32 BitRshift(Int32 val, Int64 n) + => default!; + /// + /// Bitwise left-shift operator for 32-bit integers. + /// + [EdgeQLFunction("bit_lshift", "std", "std::int32", false, false)] + public static Int32 BitLshift(Int32 val, Int64 n) + => default!; + [EdgeQLFunction("range_unpack", "std", "std::int32", true, false)] + public static IEnumerable RangeUnpack(Range val) + => default!; + [EdgeQLFunction("range_unpack", "std", "std::int32", true, false)] + public static IEnumerable RangeUnpack(Range val, Int32 step) + => default!; + /// + /// Create a `int32` value. + /// + [EdgeQLFunction("to_int32", "std", "std::int32", false, false)] + public static Int32 ToInt32(String s, String? fmt = null) + => default!; + /// + /// Return the array made from all of the input set elements. + /// + [EdgeQLFunction("array_agg", "std", "array", false, false)] + public static IEnumerable ArrayAgg(IEnumerable s) + => default!; + /// + /// Return an array filled with the given value repeated as many times as specified. + /// + [EdgeQLFunction("array_fill", "std", "array", false, false)] + public static IEnumerable ArrayFill(TType val, Int64 n) + => default!; + /// + /// Replace each array element equal to the second argument with the third argument. + /// + [EdgeQLFunction("array_replace", "std", "array", false, false)] + public static IEnumerable ArrayReplace(IEnumerable array, TType old, TType @new) + => default!; + /// + /// Find the first regular expression match in a string. + /// + [EdgeQLFunction("re_match", "std", "array", false, false)] + public static IEnumerable ReMatch(String pattern, String str) + => default!; + /// + /// Find all regular expression matches in a string. + /// + [EdgeQLFunction("re_match_all", "std", "array", true, false)] + public static IEnumerable> ReMatchAll(String pattern, String str) + => default!; + /// + /// Split string into array elements using the supplied delimiter. + /// + [EdgeQLFunction("str_split", "std", "array", false, false)] + public static IEnumerable StrSplit(String s, String delimiter) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("max", "std", "array", false, true)] + public static IEnumerable? Max(IEnumerable> vals) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("min", "std", "array", false, true)] + public static IEnumerable? Min(IEnumerable> vals) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("min", "std", "array", false, true)] + public static IEnumerable? Min(IEnumerable> vals) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("min", "std", "array", false, true)] + public static IEnumerable? Min(IEnumerable> vals) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("max", "std", "array", false, true)] + public static IEnumerable? Max(IEnumerable> vals) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("max", "std", "array", false, true)] + public static IEnumerable? Max(IEnumerable> vals) + => default!; + /// + /// Return elements of JSON array as a set of `json`. + /// + [EdgeQLFunction("json_array_unpack", "std", "std::json", true, false)] + public static IEnumerable JsonArrayUnpack(Json array) + => default!; + /// + /// Return a JSON object with set key/value pairs. + /// + [EdgeQLFunction("json_object_pack", "std", "std::json", false, false)] + public static Json JsonObjectPack(IEnumerable> pairs) + => default!; + /// + /// Return the JSON value at the end of the specified path or an empty set. + /// + [EdgeQLFunction("json_get", "std", "std::json", false, true)] + public static Json? JsonGet(Json json, IEnumerable path, Json? @default = default) + => default!; + /// + /// Return an updated JSON target with a new value. + /// + [EdgeQLFunction("json_set", "std", "std::json", false, true)] + public static Json? JsonSet(Json target, IEnumerable path, Json? value = default, Boolean create_if_missing = true, JsonEmpty empty_treatment = JsonEmpty.ReturnEmpty) + => default!; + /// + /// Return JSON value represented by the input *string*. + /// + [EdgeQLFunction("to_json", "std", "std::json", false, false)] + public static Json ToJson(String str) + => default!; + [EdgeQLFunction("get_config_json", "cfg", "std::json", false, false)] + public static Json GetConfigJson(IEnumerable? sources = null, String? max_source = null) + => default!; + [EdgeQLFunction("CONCAT", "std", "std::json", false, false)] + public static Json Concat(Json l = default, Json r = default) + => default!; + /// + /// Return a version 1 UUID. + /// + [EdgeQLFunction("uuid_generate_v1mc", "std", "std::uuid", false, false)] + public static Guid UuidGenerateV1mc() + => default!; + /// + /// Return a version 4 UUID. + /// + [EdgeQLFunction("uuid_generate_v4", "std", "std::uuid", false, false)] + public static Guid UuidGenerateV4() + => default!; + [EdgeQLFunction("range", "std", "range", false, false)] + public static Range Range(TPoint? lower = default, TPoint? upper = default, Boolean inc_lower = true, Boolean inc_upper = false, Boolean empty = false) + where TPoint : struct + => default!; + [EdgeQLFunction("multirange_unpack", "std", "range", true, false)] + public static IEnumerable> MultirangeUnpack(MultiRange val) + => default!; + [EdgeQLFunction("multirange_unpack", "std", "range", true, false)] + public static IEnumerable> MultirangeUnpack(MultiRange val) + => default!; + [EdgeQLFunction("multirange_unpack", "std", "range", true, false)] + public static IEnumerable> MultirangeUnpack(MultiRange val) + => default!; + [EdgeQLFunction("multirange_unpack", "std", "range", true, false)] + public static IEnumerable> MultirangeUnpack(MultiRange val) + => default!; + [EdgeQLFunction("multirange_unpack", "std", "range", true, false)] + public static IEnumerable> MultirangeUnpack(MultiRange val) + => default!; + [EdgeQLFunction("multirange_unpack", "std", "range", true, false)] + public static IEnumerable> MultirangeUnpack(MultiRange val) + => default!; + [EdgeQLFunction("multirange_unpack", "std", "range", true, false)] + public static IEnumerable> MultirangeUnpack(MultiRange val) + => default!; + [EdgeQLFunction("multirange_unpack", "std", "range", true, false)] + public static IEnumerable> MultirangeUnpack(MultiRange val) + => default!; + [EdgeQLFunction("multirange", "std", "multirange", false, false)] + public static MultiRange Multirange(IEnumerable> ranges) + where TPoint : struct + => default!; + [EdgeQLFunction("range_get_upper", "std", "std::anypoint", false, true)] + public static TPoint? RangeGetUpper(Range r) + where TPoint : struct + => default!; + [EdgeQLFunction("range_get_lower", "std", "std::anypoint", false, true)] + public static TPoint? RangeGetLower(Range r) + where TPoint : struct + => default!; + /// + /// Convert a text string to a binary UTF-8 string. + /// + [EdgeQLFunction("to_bytes", "std", "std::bytes", false, false)] + public static Byte[] ToBytes(String s) + => default!; + /// + /// Decode the byte64-encoded byte string and return decoded bytes. + /// + [EdgeQLFunction("base64_decode", "std::enc", "std::bytes", false, false)] + public static Byte[] Base64Decode(String data, Base64Alphabet alphabet = Base64Alphabet.standard, Boolean padding = true) + => default!; + [EdgeQLFunction("CONCAT", "std", "std::bytes", false, false)] + public static Byte[] Concat(Byte[] l = null, Byte[] r = null) + => default!; + /// + /// Return the isolation level of the current transaction. + /// + [EdgeQLFunction("get_transaction_isolation", "sys", "sys::TransactionIsolation", false, false)] + public static TransactionIsolation GetTransactionIsolation() + => default!; + /// + /// Create a `cal::local_datetime` value. + /// + [EdgeQLFunction("to_local_datetime", "cal", "cal::local_datetime", false, false)] + public static DateTime ToLocalDatetime(String s, String? fmt = null) + => default!; + /// + /// Create a `cal::local_datetime` value. + /// + [EdgeQLFunction("to_local_datetime", "cal", "cal::local_datetime", false, false)] + public static DateTime ToLocalDatetime(Int64 year, Int64 month, Int64 day, Int64 hour, Int64 min, Double sec) + => default!; + /// + /// Create a `cal::local_datetime` value. + /// + [EdgeQLFunction("to_local_datetime", "cal", "cal::local_datetime", false, false)] + public static DateTime ToLocalDatetime(DateTimeOffset dt, String zone) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("min", "std", "cal::local_datetime", false, true)] + public static DateTime? Min(IEnumerable vals) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("max", "std", "cal::local_datetime", false, true)] + public static DateTime? Max(IEnumerable vals) + => default!; + [EdgeQLFunction("range_unpack", "std", "cal::local_datetime", true, false)] + public static IEnumerable RangeUnpack(Range val, TimeSpan step) + => default!; + /// + /// Create a `cal::local_date` value. + /// + [EdgeQLFunction("to_local_date", "cal", "cal::local_date", false, false)] + public static DateOnly ToLocalDate(String s, String? fmt = null) + => default!; + /// + /// Create a `cal::local_date` value. + /// + [EdgeQLFunction("to_local_date", "cal", "cal::local_date", false, false)] + public static DateOnly ToLocalDate(DateTimeOffset dt, String zone) + => default!; + /// + /// Create a `cal::local_date` value. + /// + [EdgeQLFunction("to_local_date", "cal", "cal::local_date", false, false)] + public static DateOnly ToLocalDate(Int64 year, Int64 month, Int64 day) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("min", "std", "cal::local_date", false, true)] + public static DateOnly? Min(IEnumerable vals) + => default!; + /// + /// Return the smallest value of the input set. + /// + [EdgeQLFunction("max", "std", "cal::local_date", false, true)] + public static DateOnly? Max(IEnumerable vals) + => default!; + [EdgeQLFunction("range_unpack", "std", "cal::local_date", true, false)] + public static IEnumerable RangeUnpack(Range val) + => default!; + [EdgeQLFunction("range_unpack", "std", "cal::local_date", true, false)] + public static IEnumerable RangeUnpack(Range val, TimeSpan step) + => default!; + /// + /// Create a `cal::local_time` value. + /// + [EdgeQLFunction("to_local_time", "cal", "cal::local_time", false, false)] + public static TimeSpan ToLocalTime(String s, String? fmt = null) + => default!; + /// + /// Create a `cal::local_time` value. + /// + [EdgeQLFunction("to_local_time", "cal", "cal::local_time", false, false)] + public static TimeSpan ToLocalTime(DateTimeOffset dt, String zone) + => default!; + /// + /// Create a `cal::local_time` value. + /// + [EdgeQLFunction("to_local_time", "cal", "cal::local_time", false, false)] + public static TimeSpan ToLocalTime(Int64 hour, Int64 min, Double sec) + => default!; + /// + /// Create a `cal::relative_duration` value. + /// + [EdgeQLFunction("to_relative_duration", "cal", "cal::relative_duration", false, false)] + public static TimeSpan ToRelativeDuration(Int64 years = 0, Int64 months = 0, Int64 days = 0, Int64 hours = 0, Int64 minutes = 0, Double seconds = 0, Int64 microseconds = 0) + => default!; + /// + /// Convert 24-hour chunks into days. + /// + [EdgeQLFunction("duration_normalize_hours", "cal", "cal::relative_duration", false, false)] + public static TimeSpan DurationNormalizeHours(TimeSpan dur) + => default!; + /// + /// Convert 30-day chunks into months. + /// + [EdgeQLFunction("duration_normalize_days", "cal", "cal::relative_duration", false, false)] + public static TimeSpan DurationNormalizeDays(TimeSpan dur) + => default!; + /// + /// Create a `cal::date_duration` value. + /// + [EdgeQLFunction("to_date_duration", "cal", "cal::date_duration", false, false)] + public static TimeSpan ToDateDuration(Int64 years = 0, Int64 months = 0, Int64 days = 0) + => default!; + /// + /// Adds language and weight category information to a string, so it be indexed with fts::index. + /// + [EdgeQLFunction("with_options", "fts", "fts::document", false, false)] + public static Document WithOptions(String text, TEnum language, Weight? weight_category = Weight.A) + => default!; + } +} diff --git a/src/EdgeDB.Net.QueryBuilder/EdgeQL.test.g.cs b/src/EdgeDB.Net.QueryBuilder/EdgeQL.test.g.cs deleted file mode 100644 index 5a891d98..00000000 --- a/src/EdgeDB.Net.QueryBuilder/EdgeQL.test.g.cs +++ /dev/null @@ -1,1110 +0,0 @@ -#nullable restore -#pragma warning disable -using EdgeDB.DataTypes; -using System.Numerics; -using EdgeDB.Models.DataTypes; -using DateTime = System.DateTime; - -namespace EdgeDB -{ - public sealed partial class EdgeQL - { - /// - /// Check that the input set contains at most one element, raise CardinalityViolationError otherwise. - /// - public static TType? AssertSingle(IEnumerable input, String? message = null) - => default!; - /// - /// Check that the input set contains at least one element, raise CardinalityViolationError otherwise. - /// - public static IEnumerable AssertExists(IEnumerable input, String? message = null) - => default!; - /// - /// Check that the input set is a proper set, i.e. all elements are unique - /// - public static IEnumerable AssertDistinct(IEnumerable input, String? message = null) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static TType? Min(IEnumerable vals) - => default!; - /// - /// Return the greatest value of the input set. - /// - public static TType? Max(IEnumerable vals) - => default!; - /// - /// Return the element of *array* at the specified *index*. - /// - public static TType? ArrayGet(IEnumerable array, Int64 idx, TType? @default = default) - => default!; - /// - /// Return array elements as a set. - /// - public static IEnumerable ArrayUnpack(IEnumerable array) - => default!; - public static IEnumerable Distinct(IEnumerable s = default) - => default!; - public static IEnumerable Union(IEnumerable s1 = default, IEnumerable s2 = default) - => default!; - public static IEnumerable Except(IEnumerable s1 = default, IEnumerable s2 = default) - => default!; - public static IEnumerable Intersect(IEnumerable s1 = default, IEnumerable s2 = default) - => default!; - /// - /// Assert that a boolean value is true. - /// - public static Boolean Assert(Boolean input, String? message = null) - => default!; - /// - /// Generalized boolean `AND` applied to the set of *values*. - /// - public static Boolean All(IEnumerable vals) - => default!; - /// - /// Generalized boolean `OR` applied to the set of *values*. - /// - public static Boolean Any(IEnumerable vals) - => default!; - /// - /// A polymorphic function to test if a sequence contains a certain element. - /// - public static Boolean Contains(String haystack, String needle) - => default!; - /// - /// A polymorphic function to test if a sequence contains a certain element. - /// - public static Boolean Contains(Byte[] haystack, Byte[] needle) - => default!; - /// - /// A polymorphic function to test if a sequence contains a certain element. - /// - public static Boolean Contains(IEnumerable haystack, TType needle) - => default!; - /// - /// A polymorphic function to test if one JSON value contains another JSON value. - /// - public static Boolean Contains(Json haystack, Json needle) - => default!; - public static Boolean StrictlyAbove(MultiRange l, MultiRange r) - where TPoint : struct - => default!; - /// - /// Test if a regular expression has a match in a string. - /// - public static Boolean ReTest(String pattern, String str) - => default!; - public static Boolean RangeIsEmpty(Range val) - where TPoint : struct - => default!; - public static Boolean RangeIsInclusiveUpper(Range r) - where TPoint : struct - => default!; - public static Boolean RangeIsInclusiveLower(Range r) - where TPoint : struct - => default!; - public static Boolean Contains(Range haystack, Range needle) - where TPoint : struct - => default!; - public static Boolean Overlaps(Range l, Range r) - where TPoint : struct - => default!; - public static Boolean StrictlyBelow(Range l, Range r) - where TPoint : struct - => default!; - public static Boolean BoundedAbove(Range l, Range r) - where TPoint : struct - => default!; - public static Boolean BoundedBelow(Range l, Range r) - where TPoint : struct - => default!; - public static Boolean Adjacent(Range l, Range r) - where TPoint : struct - => default!; - public static Boolean Contains(Range haystack, DateOnly needle) - => default!; - public static Boolean Contains(MultiRange haystack, DateOnly needle) - => default!; - public static Boolean Not(Boolean v = default) - => default!; - public static Boolean In(TType e = default, IEnumerable s = default) - => default!; - public static Boolean NotIn(TType e = default, IEnumerable s = default) - => default!; - public static Boolean Exists(IEnumerable s = default) - => default!; - public static Boolean Like(String str = null, String pattern = null) - => default!; - public static Boolean ILike(String str = null, String pattern = null) - => default!; - public static Boolean NotLike(String str = null, String pattern = null) - => default!; - public static Boolean NotILike(String str = null, String pattern = null) - => default!; - /// - /// A polymorphic function to calculate a "length" of its first argument. - /// - public static Int64 Len(String str) - => default!; - /// - /// A polymorphic function to calculate a "length" of its first argument. - /// - public static Int64 Len(Byte[] bytes) - => default!; - /// - /// A polymorphic function to calculate a "length" of its first argument. - /// - public static Int64 Len(IEnumerable array) - => default!; - /// - /// Return the sum of the set of numbers. - /// - public static Int64 Sum(IEnumerable s) - => default!; - /// - /// Return the sum of the set of numbers. - /// - public static Int64 Sum(IEnumerable s) - => default!; - /// - /// Return the number of elements in a set. - /// - public static Int64 Count(IEnumerable s) - => default!; - /// - /// Round to the nearest value. - /// - public static Int64 Round(Int64 val) - => default!; - /// - /// A polymorphic function to find index of an element in a sequence. - /// - public static Int64 Find(String haystack, String needle) - => default!; - /// - /// A polymorphic function to find index of an element in a sequence. - /// - public static Int64 Find(Byte[] haystack, Byte[] needle) - => default!; - /// - /// A polymorphic function to find index of an element in a sequence. - /// - public static Int64 Find(IEnumerable haystack, TType needle, Int64 from_pos = 0) - => default!; - /// - /// Bitwise AND operator for 64-bit integers. - /// - public static Int64 BitAnd(Int64 l, Int64 r) - => default!; - /// - /// Bitwise OR operator for 64-bit integers. - /// - public static Int64 BitOr(Int64 l, Int64 r) - => default!; - /// - /// Bitwise exclusive OR operator for 64-bit integers. - /// - public static Int64 BitXor(Int64 l, Int64 r) - => default!; - /// - /// Bitwise NOT operator for 64-bit integers. - /// - public static Int64 BitNot(Int64 r) - => default!; - /// - /// Bitwise right-shift operator for 64-bit integers. - /// - public static Int64 BitRshift(Int64 val, Int64 n) - => default!; - /// - /// Bitwise left-shift operator for 64-bit integers. - /// - public static Int64 BitLshift(Int64 val, Int64 n) - => default!; - /// - /// Get the *nth* bit of the *bytes* value. - /// - public static Int64 BytesGetBit(Byte[] bytes, Int64 num) - => default!; - public static IEnumerable RangeUnpack(Range val) - => default!; - public static IEnumerable RangeUnpack(Range val, Int64 step) - => default!; - public static Int64 SequenceReset(Type seq, Int64 value) - => default!; - /// - /// Create a `int64` value. - /// - public static Int64 ToInt64(String s, String? fmt = null) - => default!; - public static Int64 SequenceReset(Type seq) - => default!; - public static Int64 SequenceNext(Type seq) - => default!; - /// - /// Round up to the nearest integer. - /// - public static Int64 Ceil(Int64 x) - => default!; - /// - /// Round down to the nearest integer. - /// - public static Int64 Floor(Int64 x) - => default!; - /// - /// Return the sum of the set of numbers. - /// - public static BigInteger Sum(IEnumerable s) - => default!; - /// - /// Round to the nearest value. - /// - public static BigInteger Round(BigInteger val) - => default!; - /// - /// Create a `bigint` value. - /// - public static BigInteger ToBigint(String s, String? fmt = null) - => default!; - /// - /// Round up to the nearest integer. - /// - public static BigInteger Ceil(BigInteger x) - => default!; - /// - /// Round down to the nearest integer. - /// - public static BigInteger Floor(BigInteger x) - => default!; - /// - /// Return the sum of the set of numbers. - /// - public static Decimal Sum(IEnumerable s) - => default!; - /// - /// Round to the nearest value. - /// - public static Decimal Round(Decimal val) - => default!; - /// - /// Round to the nearest value. - /// - public static Decimal Round(Decimal val, Int64 d) - => default!; - /// - /// Return duration as total number of seconds in interval. - /// - public static Decimal DurationToSeconds(TimeSpan dur) - => default!; - public static IEnumerable RangeUnpack(Range val, Decimal step) - => default!; - /// - /// Create a `decimal` value. - /// - public static Decimal ToDecimal(String s, String? fmt = null) - => default!; - /// - /// Round up to the nearest integer. - /// - public static Decimal Ceil(Decimal x) - => default!; - /// - /// Round down to the nearest integer. - /// - public static Decimal Floor(Decimal x) - => default!; - /// - /// Return the natural logarithm of the input value. - /// - public static Decimal Ln(Decimal x) - => default!; - /// - /// Return the base 10 logarithm of the input value. - /// - public static Decimal Lg(Decimal x) - => default!; - /// - /// Return the logarithm of the input value in the specified *base*. - /// - public static Decimal Log(Decimal x, Decimal @base) - => default!; - /// - /// Return the square root of the input value. - /// - public static Decimal Sqrt(Decimal x) - => default!; - /// - /// Return the arithmetic mean of the input set. - /// - public static Decimal Mean(IEnumerable vals) - => default!; - /// - /// Return the sample standard deviation of the input set. - /// - public static Decimal Stddev(IEnumerable vals) - => default!; - /// - /// Return the population standard deviation of the input set. - /// - public static Decimal StddevPop(IEnumerable vals) - => default!; - /// - /// Return the sample variance of the input set. - /// - public static Decimal? Var(IEnumerable vals) - => default!; - /// - /// Return the population variance of the input set. - /// - public static Decimal? VarPop(IEnumerable vals) - => default!; - /// - /// Return the sum of the set of numbers. - /// - public static Single Sum(IEnumerable s) - => default!; - public static IEnumerable RangeUnpack(Range val, Single step) - => default!; - /// - /// Create a `float32` value. - /// - public static Single ToFloat32(String s, String? fmt = null) - => default!; - /// - /// Return the sum of the set of numbers. - /// - public static Double Sum(IEnumerable s) - => default!; - /// - /// Return a pseudo-random number in the range `0.0 <= x < 1.0` - /// - public static Double Random() - => default!; - /// - /// Round to the nearest value. - /// - public static Double Round(Double val) - => default!; - /// - /// Extract a specific element of input datetime by name. - /// - public static Double DatetimeGet(DateTimeOffset dt, String el) - => default!; - /// - /// Extract a specific element of input duration by name. - /// - public static Double DurationGet(TimeSpan dt, String el) - => default!; - public static IEnumerable RangeUnpack(Range val, Double step) - => default!; - /// - /// Create a `float64` value. - /// - public static Double ToFloat64(String s, String? fmt = null) - => default!; - /// - /// Round up to the nearest integer. - /// - public static Double Ceil(Double x) - => default!; - /// - /// Round down to the nearest integer. - /// - public static Double Floor(Double x) - => default!; - /// - /// Return the natural logarithm of the input value. - /// - public static Double Ln(Int64 x) - => default!; - /// - /// Return the natural logarithm of the input value. - /// - public static Double Ln(Double x) - => default!; - /// - /// Return the base 10 logarithm of the input value. - /// - public static Double Lg(Int64 x) - => default!; - /// - /// Return the base 10 logarithm of the input value. - /// - public static Double Lg(Double x) - => default!; - /// - /// Return the square root of the input value. - /// - public static Double Sqrt(Int64 x) - => default!; - /// - /// Return the square root of the input value. - /// - public static Double Sqrt(Double x) - => default!; - /// - /// Return the arithmetic mean of the input set. - /// - public static Double Mean(IEnumerable vals) - => default!; - /// - /// Return the arithmetic mean of the input set. - /// - public static Double Mean(IEnumerable vals) - => default!; - /// - /// Return the sample standard deviation of the input set. - /// - public static Double Stddev(IEnumerable vals) - => default!; - /// - /// Return the sample standard deviation of the input set. - /// - public static Double Stddev(IEnumerable vals) - => default!; - /// - /// Return the population standard deviation of the input set. - /// - public static Double StddevPop(IEnumerable vals) - => default!; - /// - /// Return the population standard deviation of the input set. - /// - public static Double StddevPop(IEnumerable vals) - => default!; - /// - /// Return the sample variance of the input set. - /// - public static Double? Var(IEnumerable vals) - => default!; - /// - /// Return the sample variance of the input set. - /// - public static Double? Var(IEnumerable vals) - => default!; - /// - /// Return the population variance of the input set. - /// - public static Double? VarPop(IEnumerable vals) - => default!; - /// - /// Return the population variance of the input set. - /// - public static Double? VarPop(IEnumerable vals) - => default!; - /// - /// Extract a specific element of input time by name. - /// - public static Double TimeGet(TimeSpan dt, String el) - => default!; - /// - /// Extract a specific element of input date by name. - /// - public static Double DateGet(DateOnly dt, String el) - => default!; - /// - /// Extract a specific element of input datetime by name. - /// - public static Double DatetimeGet(DateTime dt, String el) - => default!; - /// - /// Return the absolute value of the input *x*. - /// - public static TReal Abs(TReal x) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static String? Min(IEnumerable vals) - => default!; - /// - /// Return the greatest value of the input set. - /// - public static String? Max(IEnumerable vals) - => default!; - /// - /// Render an array to a string. - /// - public static String ArrayJoin(IEnumerable array, String delimiter) - => default!; - /// - /// Return the type of the outermost JSON value as a string. - /// - public static String JsonTypeof(Json json) - => default!; - /// - /// Replace matching substrings in a given string. - /// - public static String ReReplace(String pattern, String sub, String str, String flags = "") - => default!; - /// - /// Repeat the input *string* *n* times. - /// - public static String StrRepeat(String s, Int64 n) - => default!; - /// - /// Return a lowercase copy of the input *string*. - /// - public static String StrLower(String s) - => default!; - /// - /// Return an uppercase copy of the input *string*. - /// - public static String StrUpper(String s) - => default!; - /// - /// Return a titlecase copy of the input *string*. - /// - public static String StrTitle(String s) - => default!; - /// - /// Return the input string padded at the start to the length *n*. - /// - public static String StrPadStart(String s, Int64 n, String fill = " ") - => default!; - /// - /// Return the input string left-padded to the length *n*. - /// - public static String StrLpad(String s, Int64 n, String fill = " ") - => default!; - /// - /// Return the input string padded at the end to the length *n*. - /// - public static String StrPadEnd(String s, Int64 n, String fill = " ") - => default!; - /// - /// Return the input string right-padded to the length *n*. - /// - public static String StrRpad(String s, Int64 n, String fill = " ") - => default!; - /// - /// Return the input string with all *trim* characters removed from its start. - /// - public static String StrTrimStart(String s, String tr = " ") - => default!; - /// - /// Return the input string with all leftmost *trim* characters removed. - /// - public static String StrLtrim(String s, String tr = " ") - => default!; - /// - /// Return the input string with all *trim* characters removed from its end. - /// - public static String StrTrimEnd(String s, String tr = " ") - => default!; - /// - /// Return the input string with all rightmost *trim* characters removed. - /// - public static String StrRtrim(String s, String tr = " ") - => default!; - /// - /// Return the input string with *trim* characters removed from both ends. - /// - public static String StrTrim(String s, String tr = " ") - => default!; - /// - /// Given a string, find a matching substring and replace all its occurrences with a new substring. - /// - public static String StrReplace(String s, String old, String @new) - => default!; - /// - /// Reverse the order of the characters in the string. - /// - public static String StrReverse(String s) - => default!; - /// - /// Return string representation of the input value. - /// - public static String ToStr(DateTimeOffset dt, String? fmt = null) - => default!; - /// - /// Return string representation of the input value. - /// - public static String ToStr(TimeSpan td, String? fmt = null) - => default!; - /// - /// Return string representation of the input value. - /// - public static String ToStr(Int64 i, String? fmt = null) - => default!; - /// - /// Return string representation of the input value. - /// - public static String ToStr(Double f, String? fmt = null) - => default!; - /// - /// Return string representation of the input value. - /// - public static String ToStr(BigInteger d, String? fmt = null) - => default!; - /// - /// Return string representation of the input value. - /// - public static String ToStr(Decimal d, String? fmt = null) - => default!; - /// - /// Return string representation of the input value. - /// - public static String ToStr(IEnumerable array, String delimiter) - => default!; - /// - /// Return string representation of the input value. - /// - public static String ToStr(Json json, String? fmt = null) - => default!; - /// - /// Convert a binary UTF-8 string to a text value. - /// - public static String ToStr(Byte[] b) - => default!; - /// - /// Return the server version as a string. - /// - public static String GetVersionAsStr() - => default!; - /// - /// Return the server instance name. - /// - public static String GetInstanceName() - => default!; - /// - /// Return the name of the current database as a string. - /// - public static String GetCurrentDatabase() - => default!; - /// - /// Return string representation of the input value. - /// - public static String ToStr(DateTime dt, String? fmt = null) - => default!; - /// - /// Return string representation of the input value. - /// - public static String ToStr(DateOnly d, String? fmt = null) - => default!; - /// - /// Encode given data as a base64 string - /// - public static String Base64Encode(Byte[] data, Base64Alphabet alphabet = Base64Alphabet.standard, Boolean padding = true) - => default!; - public static String Concat(String l = null, String r = null) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static DateTimeOffset? Min(IEnumerable vals) - => default!; - /// - /// Return the greatest value of the input set. - /// - public static DateTimeOffset? Max(IEnumerable vals) - => default!; - /// - /// Return the current server date and time. - /// - public static DateTimeOffset DatetimeCurrent() - => default!; - /// - /// Return the date and time of the start of the current transaction. - /// - public static DateTimeOffset DatetimeOfTransaction() - => default!; - /// - /// Return the date and time of the start of the current statement. - /// - public static DateTimeOffset DatetimeOfStatement() - => default!; - /// - /// Truncate the input datetime to a particular precision. - /// - public static DateTimeOffset DatetimeTruncate(DateTimeOffset dt, String unit) - => default!; - public static IEnumerable RangeUnpack(Range val, TimeSpan step) - => default!; - /// - /// Create a `datetime` value. - /// - public static DateTimeOffset ToDatetime(String s, String? fmt = null) - => default!; - /// - /// Create a `datetime` value. - /// - public static DateTimeOffset ToDatetime(Int64 year, Int64 month, Int64 day, Int64 hour, Int64 min, Double sec, String timezone) - => default!; - /// - /// Create a `datetime` value. - /// - public static DateTimeOffset ToDatetime(Double epochseconds) - => default!; - /// - /// Create a `datetime` value. - /// - public static DateTimeOffset ToDatetime(Int64 epochseconds) - => default!; - /// - /// Create a `datetime` value. - /// - public static DateTimeOffset ToDatetime(Decimal epochseconds) - => default!; - /// - /// Create a `datetime` value. - /// - public static DateTimeOffset ToDatetime(DateTime local, String zone) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static TimeSpan? Min(IEnumerable vals) - => default!; - /// - /// Return the greatest value of the input set. - /// - public static TimeSpan? Max(IEnumerable vals) - => default!; - /// - /// Truncate the input duration to a particular precision. - /// - public static TimeSpan DurationTruncate(TimeSpan dt, String unit) - => default!; - /// - /// Create a `duration` value. - /// - public static TimeSpan ToDuration(Int64 hours = 0, Int64 minutes = 0, Double seconds = 0, Int64 microseconds = 0) - => default!; - /// - /// Return a set of tuples of the form `(index, element)`. - /// - public static IEnumerable> Enumerate(IEnumerable vals) - => default!; - /// - /// Return set of key/value tuples that make up the JSON object. - /// - public static IEnumerable> JsonObjectUnpack(Json obj) - => default!; - /// - /// Return the server version as a tuple. - /// - public static ValueTuple> GetVersion() - => default!; - /// - /// Search an object using its fts::index index. Returns objects that match the specified query and the matching score. - /// - public static ValueTuple? Search(TObject @object, String query, String language = "eng", IEnumerable? weights = null) - => default!; - /// - /// Bitwise AND operator for 16-bit integers. - /// - public static Int16 BitAnd(Int16 l, Int16 r) - => default!; - /// - /// Bitwise OR operator for 16-bit integers. - /// - public static Int16 BitOr(Int16 l, Int16 r) - => default!; - /// - /// Bitwise exclusive OR operator for 16-bit integers. - /// - public static Int16 BitXor(Int16 l, Int16 r) - => default!; - /// - /// Bitwise NOT operator for 16-bit integers. - /// - public static Int16 BitNot(Int16 r) - => default!; - /// - /// Bitwise right-shift operator for 16-bit integers. - /// - public static Int16 BitRshift(Int16 val, Int64 n) - => default!; - /// - /// Bitwise left-shift operator for 16-bit integers. - /// - public static Int16 BitLshift(Int16 val, Int64 n) - => default!; - /// - /// Create a `int16` value. - /// - public static Int16 ToInt16(String s, String? fmt = null) - => default!; - /// - /// Bitwise AND operator for 32-bit integers. - /// - public static Int32 BitAnd(Int32 l, Int32 r) - => default!; - /// - /// Bitwise OR operator for 32-bit integers. - /// - public static Int32 BitOr(Int32 l, Int32 r) - => default!; - /// - /// Bitwise exclusive OR operator for 32-bit integers. - /// - public static Int32 BitXor(Int32 l, Int32 r) - => default!; - /// - /// Bitwise NOT operator for 32-bit integers. - /// - public static Int32 BitNot(Int32 r) - => default!; - /// - /// Bitwise right-shift operator for 32-bit integers. - /// - public static Int32 BitRshift(Int32 val, Int64 n) - => default!; - /// - /// Bitwise left-shift operator for 32-bit integers. - /// - public static Int32 BitLshift(Int32 val, Int64 n) - => default!; - public static IEnumerable RangeUnpack(Range val) - => default!; - public static IEnumerable RangeUnpack(Range val, Int32 step) - => default!; - /// - /// Create a `int32` value. - /// - public static Int32 ToInt32(String s, String? fmt = null) - => default!; - /// - /// Return the array made from all of the input set elements. - /// - public static IEnumerable ArrayAgg(IEnumerable s) - => default!; - /// - /// Return an array filled with the given value repeated as many times as specified. - /// - public static IEnumerable ArrayFill(TType val, Int64 n) - => default!; - /// - /// Replace each array element equal to the second argument with the third argument. - /// - public static IEnumerable ArrayReplace(IEnumerable array, TType old, TType @new) - => default!; - /// - /// Find the first regular expression match in a string. - /// - public static IEnumerable ReMatch(String pattern, String str) - => default!; - /// - /// Find all regular expression matches in a string. - /// - public static IEnumerable> ReMatchAll(String pattern, String str) - => default!; - /// - /// Split string into array elements using the supplied delimiter. - /// - public static IEnumerable StrSplit(String s, String delimiter) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static IEnumerable? Max(IEnumerable> vals) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static IEnumerable? Min(IEnumerable> vals) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static IEnumerable? Min(IEnumerable> vals) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static IEnumerable? Min(IEnumerable> vals) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static IEnumerable? Max(IEnumerable> vals) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static IEnumerable? Max(IEnumerable> vals) - => default!; - /// - /// Return elements of JSON array as a set of `json`. - /// - public static IEnumerable JsonArrayUnpack(Json array) - => default!; - /// - /// Return a JSON object with set key/value pairs. - /// - public static Json JsonObjectPack(IEnumerable> pairs) - => default!; - /// - /// Return the JSON value at the end of the specified path or an empty set. - /// - public static Json? JsonGet(Json json, IEnumerable path, Json? @default = default) - => default!; - /// - /// Return an updated JSON target with a new value. - /// - public static Json? JsonSet(Json target, IEnumerable path, Json? value = default, Boolean create_if_missing = true, JsonEmpty empty_treatment = JsonEmpty.ReturnEmpty) - => default!; - /// - /// Return JSON value represented by the input *string*. - /// - public static Json ToJson(String str) - => default!; - public static Json GetConfigJson(IEnumerable? sources = null, String? max_source = null) - => default!; - public static Json Concat(Json l = default, Json r = default) - => default!; - /// - /// Return a version 1 UUID. - /// - public static Guid UuidGenerateV1mc() - => default!; - /// - /// Return a version 4 UUID. - /// - public static Guid UuidGenerateV4() - => default!; - public static Range Range(TPoint? lower = default, TPoint? upper = default, Boolean inc_lower = true, Boolean inc_upper = false, Boolean empty = false) - where TPoint : struct - => default!; - public static IEnumerable> MultirangeUnpack(MultiRange val) - => default!; - public static IEnumerable> MultirangeUnpack(MultiRange val) - => default!; - public static IEnumerable> MultirangeUnpack(MultiRange val) - => default!; - public static IEnumerable> MultirangeUnpack(MultiRange val) - => default!; - public static IEnumerable> MultirangeUnpack(MultiRange val) - => default!; - public static IEnumerable> MultirangeUnpack(MultiRange val) - => default!; - public static IEnumerable> MultirangeUnpack(MultiRange val) - => default!; - public static IEnumerable> MultirangeUnpack(MultiRange val) - => default!; - public static MultiRange Multirange(IEnumerable> ranges) - where TPoint : struct - => default!; - public static TPoint? RangeGetUpper(Range r) - where TPoint : struct - => default!; - public static TPoint? RangeGetLower(Range r) - where TPoint : struct - => default!; - /// - /// Convert a text string to a binary UTF-8 string. - /// - public static Byte[] ToBytes(String s) - => default!; - /// - /// Decode the byte64-encoded byte string and return decoded bytes. - /// - public static Byte[] Base64Decode(String data, Base64Alphabet alphabet = Base64Alphabet.standard, Boolean padding = true) - => default!; - public static Byte[] Concat(Byte[] l = null, Byte[] r = null) - => default!; - /// - /// Return the isolation level of the current transaction. - /// - public static TransactionIsolation GetTransactionIsolation() - => default!; - /// - /// Create a `cal::local_datetime` value. - /// - public static DateTime ToLocalDatetime(String s, String? fmt = null) - => default!; - /// - /// Create a `cal::local_datetime` value. - /// - public static DateTime ToLocalDatetime(Int64 year, Int64 month, Int64 day, Int64 hour, Int64 min, Double sec) - => default!; - /// - /// Create a `cal::local_datetime` value. - /// - public static DateTime ToLocalDatetime(DateTimeOffset dt, String zone) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static DateTime? Min(IEnumerable vals) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static DateTime? Max(IEnumerable vals) - => default!; - public static IEnumerable RangeUnpack(Range val, TimeSpan step) - => default!; - /// - /// Create a `cal::local_date` value. - /// - public static DateOnly ToLocalDate(String s, String? fmt = null) - => default!; - /// - /// Create a `cal::local_date` value. - /// - public static DateOnly ToLocalDate(DateTimeOffset dt, String zone) - => default!; - /// - /// Create a `cal::local_date` value. - /// - public static DateOnly ToLocalDate(Int64 year, Int64 month, Int64 day) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static DateOnly? Min(IEnumerable vals) - => default!; - /// - /// Return the smallest value of the input set. - /// - public static DateOnly? Max(IEnumerable vals) - => default!; - public static IEnumerable RangeUnpack(Range val) - => default!; - public static IEnumerable RangeUnpack(Range val, TimeSpan step) - => default!; - /// - /// Create a `cal::local_time` value. - /// - public static TimeSpan ToLocalTime(String s, String? fmt = null) - => default!; - /// - /// Create a `cal::local_time` value. - /// - public static TimeSpan ToLocalTime(DateTimeOffset dt, String zone) - => default!; - /// - /// Create a `cal::local_time` value. - /// - public static TimeSpan ToLocalTime(Int64 hour, Int64 min, Double sec) - => default!; - /// - /// Create a `cal::relative_duration` value. - /// - public static TimeSpan ToRelativeDuration(Int64 years = 0, Int64 months = 0, Int64 days = 0, Int64 hours = 0, Int64 minutes = 0, Double seconds = 0, Int64 microseconds = 0) - => default!; - /// - /// Convert 24-hour chunks into days. - /// - public static TimeSpan DurationNormalizeHours(TimeSpan dur) - => default!; - /// - /// Convert 30-day chunks into months. - /// - public static TimeSpan DurationNormalizeDays(TimeSpan dur) - => default!; - /// - /// Create a `cal::date_duration` value. - /// - public static TimeSpan ToDateDuration(Int64 years = 0, Int64 months = 0, Int64 days = 0) - => default!; - /// - /// Adds language and weight category information to a string, so it be indexed with fts::index. - /// - public static Document WithOptions(String text, TEnum language, Weight? weight_category = Weight.A) - => default!; - } -} diff --git a/src/EdgeDB.Net.QueryBuilder/Grammar/Reducers/ShapeReducer.cs b/src/EdgeDB.Net.QueryBuilder/Grammar/Reducers/GlobalReducer.cs similarity index 66% rename from src/EdgeDB.Net.QueryBuilder/Grammar/Reducers/ShapeReducer.cs rename to src/EdgeDB.Net.QueryBuilder/Grammar/Reducers/GlobalReducer.cs index 90d20c5f..a5e7f2a1 100644 --- a/src/EdgeDB.Net.QueryBuilder/Grammar/Reducers/ShapeReducer.cs +++ b/src/EdgeDB.Net.QueryBuilder/Grammar/Reducers/GlobalReducer.cs @@ -2,7 +2,7 @@ namespace EdgeDB; -internal sealed class ShapeReducer : IReducer +internal sealed class GlobalReducer : IReducer { // general rules for reducing shapes: // - Shapes are not included in function arguments @@ -10,22 +10,28 @@ public void Reduce(IQueryBuilder builder, QueryWriter writer) { foreach (var global in builder.Globals.ToArray()) { - if(!writer.TryGetMarker(global.Name, out var markers) || !CanReduce(global, builder)) + if(!writer.Markers.MarkersByName.TryGetValue(global.Name, out var markers) || !CanReduce(global, builder)) continue; Value[]? tokens = null; - foreach (var marker in markers.ToArray()) + foreach (var marker in markers.Where(x => x.Type is MarkerType.GlobalReference)) { Action? modifier = marker switch { - _ when marker.Parent?.Type is MarkerType.FunctionArg => ApplyShapeReducer, + _ when writer.Markers.GetDirectParents(marker).Any(x => x.Type is MarkerType.FunctionArg) => ApplyShapeReducer, _ => null }; marker.Replace(writer => writer - .AppendSpanned( - ref tokens, - writer => global.Compile(builder, writer, new CompileContext { PreFinalizerModifier = modifier, SchemaInfo = builder.SchemaInfo } ) + .LabelVerbose( + "global_reducer", + Defer.This(() => $"Global {global.Name} inlined; Shaped reduced?: {modifier is not null}"), + Value.Of(writer => writer + .AppendSpanned( + ref tokens, + writer => global.Compile(builder, writer, new CompileContext { PreFinalizerModifier = modifier, SchemaInfo = builder.SchemaInfo } ) + ) + ) ) ); } diff --git a/src/EdgeDB.Net.QueryBuilder/Grammar/Reducers/TypeCastReducer.cs b/src/EdgeDB.Net.QueryBuilder/Grammar/Reducers/TypeCastReducer.cs new file mode 100644 index 00000000..790bd30a --- /dev/null +++ b/src/EdgeDB.Net.QueryBuilder/Grammar/Reducers/TypeCastReducer.cs @@ -0,0 +1,94 @@ +using System.Diagnostics.CodeAnalysis; +using System.Linq.Expressions; +using System.Reflection; + +namespace EdgeDB; + +internal sealed class TypeCastReducer : IReducer +{ + public void Reduce(IQueryBuilder builder, QueryWriter writer) + { + foreach (var marker in writer.Markers) + { + if ( + marker.Type is not MarkerType.Cast || + marker.Metadata is not CastMetadata castMetadata || + !writer.Markers.TryGetNextNeighbours(marker, out var neighbours) + ) continue; + + foreach (var neighbour in neighbours) + { + switch (neighbour.Type) + { + case MarkerType.Function when neighbour.Metadata is FunctionMetadata functionMetadata: + if (!TryGetFunctionResultType(functionMetadata, out var resultType)) + continue; + + if (!EdgeDBTypeUtils.CompareEdgeDBTypes(castMetadata.Type, resultType)) + continue; + + marker.Remove(); + goto end_neighbour_search; + case MarkerType.GlobalReference when neighbour.Metadata is GlobalReferenceMetadata globalMetadata: + switch (globalMetadata.Global.Reference) + { + case Expression expression when EdgeDBTypeUtils.TryGetScalarType(expression.Type, out var scalar): + if(!EdgeDBTypeUtils.CompareEdgeDBTypes(castMetadata.Type, scalar.EdgeDBType)) + continue; + + marker.Remove(); + goto end_neighbour_search; + } + continue; + } + } + + end_neighbour_search: ; + } + } + + private static bool TryGetFunctionResultType(FunctionMetadata metadata, [MaybeNullWhen(false)] out string result) + { + result = null; + + if (metadata.Function is null) + { + List methods; + + if (metadata.FunctionName.Contains("::")) + { + var functionNameModule = metadata.FunctionName.Split("::"); + var functionName = functionNameModule[^1]; + var functionModule = string.Join("::", functionNameModule[..^1]); + + if (!EdgeQL.TryGetMethods(functionName, functionModule, out methods!)) + return false; + } + else methods = EdgeQL.SearchMethods(metadata.FunctionName); + + string? funcResult = null; + + foreach (var method in methods) + { + var functionInfo = method.GetCustomAttribute(); + + if(functionInfo is null) + continue; + + if (funcResult is null) + funcResult = functionInfo.GetFormattedReturnType(); + else if (funcResult != functionInfo.GetFormattedReturnType()) + return false; + } + + if (funcResult is null) + return false; + + result = funcResult; + return true; + } + + result = metadata.Function.GetCustomAttribute()?.GetFormattedReturnType(); + return result is not null; + } +} diff --git a/src/EdgeDB.Net.QueryBuilder/Grammar/Terms.cs b/src/EdgeDB.Net.QueryBuilder/Grammar/Terms.cs index b1afc4af..ed18e490 100644 --- a/src/EdgeDB.Net.QueryBuilder/Grammar/Terms.cs +++ b/src/EdgeDB.Net.QueryBuilder/Grammar/Terms.cs @@ -100,8 +100,13 @@ public static QueryWriter Shape(this QueryWriter writer, string name, params public static QueryWriter Assignment(this QueryWriter writer, Value name, Value value) => writer.Append(name, " := ", value); - public static QueryWriter TypeCast(this QueryWriter writer, Value type) - => writer.Append("<", type, ">"); + public static QueryWriter TypeCast(this QueryWriter writer, Value type, CastMetadata? metadata = null) + => writer.Marker( + MarkerType.Cast, + "cast", + Value.Of(writer => writer.Append('<', type, '>')), + metadata: metadata + ); public readonly struct FunctionArg { @@ -120,9 +125,10 @@ public FunctionArg(Value value, string? named = null) public static implicit operator FunctionArg(WriterProxy writerProxy) => new(writerProxy); } - public static QueryWriter Function(this QueryWriter writer, string name, params FunctionArg[] args) + public static QueryWriter Function(this QueryWriter writer, string name, Deferrable? debug, + FunctionMetadata? metadata, params FunctionArg[] args) { - return writer.Marker(MarkerType.Function, $"func_{name}", Value.Of( + return writer.Marker(MarkerType.Function, $"func_{name}", debug, new FunctionMetadata(name), Value.Of( writer => { writer.Append(name, '('); @@ -164,6 +170,13 @@ public static QueryWriter Function(this QueryWriter writer, string name, params )); } + public static QueryWriter Function(this QueryWriter writer, string name, Deferrable? debug, + params FunctionArg[] args) + => Function(writer, name, debug, new FunctionMetadata(name), args); + + public static QueryWriter Function(this QueryWriter writer, string name, params FunctionArg[] args) + => Function(writer, name, null, new FunctionMetadata(name), args); + public static QueryWriter SingleQuoted(this QueryWriter writer, Value value) => writer.Append('\'', value, '\''); diff --git a/src/EdgeDB.Net.QueryBuilder/Lexical/Marker.cs b/src/EdgeDB.Net.QueryBuilder/Lexical/Marker.cs index 2e57ad92..a946d819 100644 --- a/src/EdgeDB.Net.QueryBuilder/Lexical/Marker.cs +++ b/src/EdgeDB.Net.QueryBuilder/Lexical/Marker.cs @@ -2,67 +2,31 @@ internal sealed class Marker { + public string Name { get; } public MarkerType Type { get; } - public int Position { get; private set; } - public int Size { get; } - public Deferrable? DebugText { get; } - - public LooseLinkedList.Node Start { get; set; } - - /// - /// Gets the closest parent to this marker - /// - public Marker? Parent - { - get - { - Marker? bestMatch = null; - - foreach (var marker in _writer.Markers.Values.SelectMany(x => x)) - { - if(marker == this) - continue; - if (marker.Type is MarkerType.Verbose) - continue; + public int Position { get; private set; } - if (marker.Position > Position || marker.Size < Size) continue; - if (bestMatch is null) - { - bestMatch = marker; - continue; - } + public int Size { get; } - if (marker.Position > bestMatch.Position || marker.Size < bestMatch.Size) - bestMatch = marker; - } + public Deferrable? DebugText { get; } - return bestMatch; - } - } + public IMarkerMetadata? Metadata { get; } - /// - /// Gets a collection of parents of this marker, with the first being the closest parent; and so on. - /// - public IOrderedEnumerable Parents - { - get - { - return _writer.Markers.Values.SelectMany(x => x).Where(x => x.Type is not MarkerType.Verbose && x != this && x.Position <= Position && x.Size >= Size) - .OrderBy(x => Position - x.Position + x.Size); - } - } + public LooseLinkedList.Node Start { get; set; } private readonly QueryWriter _writer; - internal Marker(MarkerType type, QueryWriter writer, int size, int position, LooseLinkedList.Node start, Deferrable? debugText) + internal Marker(string name, MarkerType type, QueryWriter writer, int size, int position, LooseLinkedList.Node start, Deferrable? debugText, IMarkerMetadata? metadata) { + Name = name; Type = type; _writer = writer; Size = size; Position = position; Start = start; DebugText = debugText; + Metadata = metadata; } internal void Update(int delta) @@ -76,6 +40,9 @@ public void Replace(Value value) .Replace(Start, Position, Size, value); } + public void Remove() + => _writer.Remove(Position, Start, Size); + public void Replace(WriterProxy value) => Replace(new Value(value)); } diff --git a/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerCollection.cs b/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerCollection.cs new file mode 100644 index 00000000..083d76d3 --- /dev/null +++ b/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerCollection.cs @@ -0,0 +1,110 @@ + +using System.Collections; +using System.Diagnostics.CodeAnalysis; + +namespace EdgeDB; + +internal sealed class MarkerCollection : IEnumerable +{ + private readonly Dictionary> _markersByType = new(); + private readonly LinkedList _markers = new(); + private readonly SortedDictionary> _markersByPosition = new(); + public readonly Dictionary> MarkersByName = new(); + + public void Add(Marker marker) + { + _markers.AddLast(marker); + + if (!_markersByType.TryGetValue(marker.Type, out var markersByType)) + _markersByType[marker.Type] = markersByType = new(); + + if (!_markersByPosition.TryGetValue(marker.Position, out var markersByPosition)) + _markersByPosition[marker.Position] = markersByPosition = new(); + + if (!MarkersByName.TryGetValue(marker.Name, out var markersByName)) + MarkersByName[marker.Name] = markersByName = new(); + + markersByPosition.AddLast(marker); + markersByType.AddLast(marker); + markersByName.AddLast(marker); + } + + public void Update(int position, int delta) + { + foreach (var marker in _markers) + { + if(marker.Position <= position) + continue; + + _markersByPosition[marker.Position].Remove(marker); + marker.Update(delta); + if (!_markersByPosition.TryGetValue(marker.Position, out var markersByPosition)) + _markersByPosition[marker.Position] = markersByPosition = new(); + + markersByPosition.AddLast(marker); + } + } + + public IEnumerable GetSiblings(Marker marker) + => _markersByPosition[marker.Position].Where(x => x != marker && x.Size == marker.Size); + + public LinkedList GetDirectParents(Marker marker) + { + var result = new LinkedList(); + + var minStart = _markersByPosition[marker.Position].MinBy(x => + { + var cmp = x.Size - marker.Size; + return cmp <= 0 ? int.MaxValue : cmp; + }); + + if (minStart is not null) + { + foreach (var minStartMarker in _markersByPosition[marker.Position].Where(x => x.Size == minStart.Size)) + { + result.AddLast(minStartMarker); + } + } + + var minEnd = _markers + .Where(x => x.Position + x.Size == marker.Position + marker.Size) + .MinBy(x => x.Size); + + if (minEnd is not null) + { + foreach (var minEndMarker in _markersByPosition[minEnd.Position].Where(x => x.Size == minEnd.Size)) + { + result.AddLast(minEndMarker); + } + } + + return result; + } + + public IEnumerable GetParents(Marker marker) + => _markers.Where(x => x.Position < marker.Position && x.Size > marker.Size); + + public IEnumerable GetChildren(Marker marker) + => _markers.Where(x => x.Position > marker.Position && x.Size < marker.Size); + + public bool TryGetNextNeighbours(Marker marker, [MaybeNullWhen(false)] out LinkedList neighbours) + => _markersByPosition.TryGetValue(marker.Position + marker.Size, out neighbours); + + public bool TryGetPreviousNeighbours(Marker marker, [MaybeNullWhen(false)] out LinkedList neighbours) + => _markersByPosition.TryGetValue(marker.Position - 1, out neighbours); + + public bool TryGetMarkersByName(string name, [MaybeNullWhen(false)] out LinkedList markers) + => MarkersByName.TryGetValue(name, out markers); + + public void Clear() + { + _markers.Clear(); + _markersByPosition.Clear(); + _markersByType.Clear(); + MarkersByName.Clear(); + } + + public IEnumerator GetEnumerator() => _markers.GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)_markers).GetEnumerator(); +} diff --git a/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerMetadata/CastMetadata.cs b/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerMetadata/CastMetadata.cs new file mode 100644 index 00000000..23990262 --- /dev/null +++ b/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerMetadata/CastMetadata.cs @@ -0,0 +1,3 @@ +namespace EdgeDB; + +internal sealed record CastMetadata(EdgeDBTypeUtils.EdgeDBTypeInfo? TypeInfo, string Type) : IMarkerMetadata; diff --git a/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerMetadata/FunctionMetadata.cs b/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerMetadata/FunctionMetadata.cs new file mode 100644 index 00000000..16c92d70 --- /dev/null +++ b/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerMetadata/FunctionMetadata.cs @@ -0,0 +1,5 @@ +using System.Reflection; + +namespace EdgeDB; + +public sealed record FunctionMetadata(string FunctionName, MethodInfo? Function = null) : IMarkerMetadata; diff --git a/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerMetadata/GlobalReferenceMetadata.cs b/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerMetadata/GlobalReferenceMetadata.cs new file mode 100644 index 00000000..d5cfa93c --- /dev/null +++ b/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerMetadata/GlobalReferenceMetadata.cs @@ -0,0 +1,3 @@ +namespace EdgeDB; + +internal sealed record GlobalReferenceMetadata(QueryGlobal Global) : IMarkerMetadata; diff --git a/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerMetadata/IMarkerMetadata.cs b/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerMetadata/IMarkerMetadata.cs new file mode 100644 index 00000000..d57cf83e --- /dev/null +++ b/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerMetadata/IMarkerMetadata.cs @@ -0,0 +1,3 @@ +namespace EdgeDB; + +internal interface IMarkerMetadata{} diff --git a/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerType.cs b/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerType.cs index d25de0c7..466bc868 100644 --- a/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerType.cs +++ b/src/EdgeDB.Net.QueryBuilder/Lexical/MarkerType.cs @@ -8,5 +8,6 @@ public enum MarkerType FunctionArg, Shape, Variable, - Verbose + Verbose, + Cast } diff --git a/src/EdgeDB.Net.QueryBuilder/Lexical/QueryWriter.cs b/src/EdgeDB.Net.QueryBuilder/Lexical/QueryWriter.cs index 56bf4e7f..23a20f16 100644 --- a/src/EdgeDB.Net.QueryBuilder/Lexical/QueryWriter.cs +++ b/src/EdgeDB.Net.QueryBuilder/Lexical/QueryWriter.cs @@ -26,24 +26,23 @@ public void Dispose() } } - public readonly Dictionary> Markers; - - private readonly List _markersRef; + public readonly MarkerCollection Markers; private readonly LooseLinkedList _tokens; private readonly List _observers = []; private ValueNode? _track; + private readonly bool _debug; private int TailIndex => _tokens.Count - 1; - public QueryWriter() + public QueryWriter(bool debug = false) { _tokens = new(); Markers = new(); - _markersRef = new(); _track = null; + _debug = debug; } /// @@ -119,112 +118,37 @@ private int GetIndexOfNode(ValueNode node) return -1; } - private ValueNode? Traverse(ValueNode from, int count, bool dir) - { - var node = from; - while (count > 0 && node is not null) - { - node = dir ? node.Next : node.Previous; - count--; - } - return node; - } - - private ValueNode? FastGetNodeFromIndex(int index) - { - // check for start/end node - if (index == 0) - return _tokens.First; - - if (index == TailIndex) - return _tokens.Last; - - // get a distance we'll have to traverse in worst case scenario - var normalizedDistance = Math.Min(TailIndex - index, index); - - // check if searching through markers will be faster: - // binary search is log(n) but since we're searching for a range which can have jump distances, we'll add a - // small weight which can be tuned later to represent the jump distance within the span. - if (_markersRef.Count <= Math.Log(normalizedDistance) + normalizedDistance / 2.5) - { - // get a midpoint somewhere in the markers derived from the provided index - var i = (int)Math.Floor(_markersRef.Count * (_tokens.Count / (float)index)); - var minJump = normalizedDistance; - - // binary search - while (true) - { - var split = i / 2; - - if (split == 0 || split == i) - break; - - var delta = Math.Abs(_markersRef[i].Position - index); - - if (delta < minJump) - { - minJump = delta; - i -= split; - } - else if (delta > minJump) - { - i += split; - } - else - { - // last iter was same as this one, we can exit - break; - } - } - - var marker = _markersRef[i]; - var distance = Math.Abs(marker.Position - index); - - if(distance <= normalizedDistance) - return Traverse(marker.Start, Math.Abs(marker.Position - index), index > marker.Position); - } - - return normalizedDistance == index - ? Traverse(_tokens.First!, index, true) - : Traverse(_tokens.Last!, _tokens.Count - index, false); - } - - private void UpdateMarkers(int position, int delta) + public QueryWriter Marker(MarkerType type, string name, in Value value, Deferrable? debug = null, IMarkerMetadata? metadata = null) { - foreach (var marker in _markersRef.Where(x => x.Position > position)) + if (type is MarkerType.Verbose && !_debug) { - marker.Update(delta); + Append(in value); + return this; } - } - - public bool TryGetMarker(string name, [MaybeNullWhen(false)] out LinkedList markers) - => Markers.TryGetValue(name, out markers); - - public QueryWriter Marker(MarkerType type, string name, in Value value, Deferrable? debug = null) - { - if (!Markers.TryGetValue(name, out var markers)) - Markers[name] = markers = new(); var currentIndex = TailIndex; Append(in value, out var head); var size = TailIndex - currentIndex; - - var marker = new Marker(type, this, size, currentIndex + 1, head, debug); - _markersRef.Add(marker); - markers.AddLast(marker); + Markers.Add(new Marker(name, type, this, size, currentIndex + 1, head, debug, metadata)); return this; } - public QueryWriter Marker(MarkerType type, string name, Deferrable? debug = null) - => Marker(type, name, debug, name); + public QueryWriter Marker(MarkerType type, string name, Deferrable? debug = null, IMarkerMetadata? metadata = null) + => Marker(type, name, debug, metadata, name); public QueryWriter Marker(MarkerType type, string name, Deferrable? debug = null, params Value[] values) + => Marker(type, name, debug, null, values); + + public QueryWriter Marker(MarkerType type, string name, Deferrable? debug = null, IMarkerMetadata? metadata = null, params Value[] values) { - if (values.Length == 0) + if (type is MarkerType.Verbose && !_debug) + { + Append(values); return this; + } - if (!Markers.TryGetValue(name, out var markers)) - Markers[name] = markers = new(); + if (values.Length == 0) + return this; var currentIndex = TailIndex; @@ -232,17 +156,17 @@ public QueryWriter Marker(MarkerType type, string name, Deferrable? debu var count = TailIndex - currentIndex; - var marker = new Marker( + Markers.Add(new Marker( + name, type, this, count, currentIndex + 1, head, - debug - ); + debug, + metadata + )); - _markersRef.Add(marker); - markers.AddLast(marker); return this; } @@ -256,7 +180,7 @@ public QueryWriter Remove(int position, ValueNode head, int count = 1) _track = headPrev; }); - UpdateMarkers(position, -count); + Markers.Update(position, -count); return this; } @@ -287,7 +211,7 @@ public QueryWriter Prepend(ValueNode node, in Value value) OnNodeAdd(AddBeforeTracked(in value)); _track = oldTrack; - UpdateMarkers(index - 1, 1); + Markers.Update(index - 1, 1); return this; } @@ -297,7 +221,8 @@ public QueryWriter Append(in Value value, out ValueNode node) node = AddAfterTracked(in value); OnNodeAdd(node); - UpdateMarkers(TailIndex, 1); + + Markers.Update(TailIndex, 1); return this; } @@ -312,7 +237,7 @@ public QueryWriter Append(params Value[] values) OnNodeAdd(AddAfterTracked(in values[i])); } - UpdateMarkers(_tokens.Count - 1, values.Length); + Markers.Update(_tokens.Count - 1, values.Length); return this; } @@ -331,7 +256,7 @@ public QueryWriter Append(out ValueNode node, params Value[] values) for (var i = 1; i < values.Length; i++) OnNodeAdd(AddAfterTracked(in values[i])); - UpdateMarkers(_tokens.Count - 1, values.Length); + Markers.Update(_tokens.Count - 1, values.Length); return this; } @@ -392,7 +317,7 @@ public bool TryWrite(Value value) var query = new StringBuilder(); var activeMarkers = new List(); var spans = new LinkedList(); - var markers = new HashSet<(string, Marker)>(Markers.SelectMany(x => x.Value.Select(y => (x.Key, y)))); + var markers = new HashSet<(string, Marker)>(Markers.MarkersByName.SelectMany(x => x.Value.Select(y => (x.Key, y)))); var current = _tokens.First; @@ -435,6 +360,5 @@ public void Dispose() Markers.Clear(); _tokens.Clear(); _observers.Clear(); - _markersRef.Clear(); } } diff --git a/src/EdgeDB.Net.QueryBuilder/QueryBuilder.cs b/src/EdgeDB.Net.QueryBuilder/QueryBuilder.cs index ef42993e..d45cbe35 100644 --- a/src/EdgeDB.Net.QueryBuilder/QueryBuilder.cs +++ b/src/EdgeDB.Net.QueryBuilder/QueryBuilder.cs @@ -210,7 +210,7 @@ internal CompiledQuery CompileInternal(CompileContext? context = null) { context ??= new CompileContext(); - using var writer = new QueryWriter(); + using var writer = new QueryWriter(context.Debug); CompileInternal(writer, context); @@ -257,24 +257,26 @@ internal void CompileInternal(QueryWriter writer, CompileContext? context = null // create a with block if we have any globals if (context.IncludeGlobalsInQuery && QueryGlobals.Any()) { - var builder = new NodeBuilder(new WithContext(typeof(TType)) - { - Values = QueryGlobals, - }, QueryGlobals, nodes, QueryVariables); + var with = (WithNode?)Nodes.FirstOrDefault(x => x is WithNode); - var with = new WithNode(builder) + if (with is null) { - SchemaInfo = SchemaInfo - }; + var builder = new NodeBuilder(new WithContext(typeof(TType)), QueryGlobals, nodes, QueryVariables); - // visit the with node and add it to the front of our local collection of nodes. - using (var _ = writer.PositionalScopeFromStart()) - { - with.FinalizeQuery(writer); - writer.Append(' '); - } + with = new WithNode(builder) + { + SchemaInfo = SchemaInfo + }; - nodes = nodes.Prepend(with).ToList(); + // visit the with node and add it to the front of our local collection of nodes. + using (var _ = writer.PositionalScopeFromStart()) + { + with.FinalizeQuery(writer); + writer.Append(' '); + } + + nodes = nodes.Prepend(with).ToList(); + } } // flatten our parameters into a single collection and make it distinct. diff --git a/src/EdgeDB.Net.QueryBuilder/QueryBuilder/QueryBuilder.Insert.cs b/src/EdgeDB.Net.QueryBuilder/QueryBuilder/QueryBuilder.Insert.cs index b15abdfb..87c65d82 100644 --- a/src/EdgeDB.Net.QueryBuilder/QueryBuilder/QueryBuilder.Insert.cs +++ b/src/EdgeDB.Net.QueryBuilder/QueryBuilder/QueryBuilder.Insert.cs @@ -33,6 +33,12 @@ public static IInsertQuery> Insert(TType v public static IInsertQuery> Insert(Type type, IDictionary values) => new QueryBuilder().Insert(type, values); + public static IInsertQuery> Insert(Type type, TType value) + => new QueryBuilder().Insert(type, value, false); + + public static IInsertQuery> Insert(Type type, TType value, bool returnInsertedValue) + => new QueryBuilder().Insert(type, value, returnInsertedValue); + public static IInsertQuery> Insert(Type type, IDictionary values, bool returnInsertedValue) => new QueryBuilder().Insert(type, values, returnInsertedValue); @@ -83,6 +89,19 @@ public IInsertQuery Insert(TType value, bool returnInsertedValu return this; } + /// + public IInsertQuery Insert(Type type, object? value, bool returnInsertedValue = true) + { + var insertNode = AddNode(new InsertContext(type, value)); + + if (returnInsertedValue) + { + AddNode(new SelectContext(type), true, insertNode); + } + + return this; + } + /// public IInsertQuery Insert(TType value) => Insert(value, false); diff --git a/src/EdgeDB.Net.QueryBuilder/QueryBuilder/QueryBuilder.With.cs b/src/EdgeDB.Net.QueryBuilder/QueryBuilder/QueryBuilder.With.cs index 1b8bf15f..9f687de0 100644 --- a/src/EdgeDB.Net.QueryBuilder/QueryBuilder/QueryBuilder.With.cs +++ b/src/EdgeDB.Net.QueryBuilder/QueryBuilder/QueryBuilder.With.cs @@ -1,3 +1,4 @@ +using EdgeDB.QueryNodes; using EdgeDB.Translators.Expressions; using System; using System.Collections.Generic; @@ -43,14 +44,7 @@ internal QueryBuilder> WithIntern if (!typeof(TVariables).IsAnonymousType()) throw new ArgumentException("Variables must be an anonymous type"); - // pull the initialization expression - var initializations = InitializationTranslator.PullInitializationExpression(variables.Body); - - // add each as a global - foreach (var initialization in initializations) - { - QueryGlobals.Add(new QueryGlobal(initialization.Key.Name, initialization.Value, variables)); - } + AddNode(new WithContext(typeof(TType)) {ValuesExpression = variables}); return EnterNewContext>(); } diff --git a/src/EdgeDB.Net.QueryBuilder/QueryContext.cs b/src/EdgeDB.Net.QueryBuilder/QueryContext.cs index d3434f12..f816c28e 100644 --- a/src/EdgeDB.Net.QueryBuilder/QueryContext.cs +++ b/src/EdgeDB.Net.QueryBuilder/QueryContext.cs @@ -162,7 +162,7 @@ public abstract TCollection BackLink(Expression(IMultiCardinalityQuery query) where TCollection : IEnumerable; - public abstract T Ref(IEnumerable collection); + public abstract IEnumerable Aggregate(IEnumerable collection, Func operand); } public abstract class QueryContextSelf : QueryContext, IQueryContextSelf diff --git a/src/EdgeDB.Net.QueryBuilder/QueryNodes/Contexts/WithContext.cs b/src/EdgeDB.Net.QueryBuilder/QueryNodes/Contexts/WithContext.cs index c342b692..ae92d0f3 100644 --- a/src/EdgeDB.Net.QueryBuilder/QueryNodes/Contexts/WithContext.cs +++ b/src/EdgeDB.Net.QueryBuilder/QueryNodes/Contexts/WithContext.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; @@ -14,7 +15,9 @@ internal class WithContext : NodeContext /// /// Gets the global variables that are included in the 'WITH' statement. /// - public List? Values { get; init; } + public List? Values { get; set; } + + public LambdaExpression? ValuesExpression { get; init; } /// public WithContext(Type currentType) : base(currentType) diff --git a/src/EdgeDB.Net.QueryBuilder/QueryNodes/GroupNode.cs b/src/EdgeDB.Net.QueryBuilder/QueryNodes/GroupNode.cs index 68e7f4c9..bd60e5b8 100644 --- a/src/EdgeDB.Net.QueryBuilder/QueryNodes/GroupNode.cs +++ b/src/EdgeDB.Net.QueryBuilder/QueryNodes/GroupNode.cs @@ -12,23 +12,38 @@ internal sealed class GroupNode(NodeBuilder builder) : QueryNode(b { private WriterProxy? _by; private WriterProxy? _using; + private string? _usingReferenceName; public override void FinalizeQuery(QueryWriter writer) { if (_by is null) throw new InvalidOperationException("A 'by' expression is required for groups!"); - writer.Append("group ", OperatingType.GetEdgeDBTypeName()); + writer.Append("group "); - if (Context.IncludeShape) + if (Context.Selector is not null) { - (Context.Shape ?? BaseShapeBuilder.CreateDefault(GetOperatingType())) - .GetShape() - .Compile(writer.Append(' '), (writer, expression) => - { - using var consumer = NodeTranslationContext.CreateContextConsumer(expression.Root); - ExpressionTranslator.ContextualTranslate(expression.Expression, consumer, writer); - }); + if (_usingReferenceName is not null) + { + writer.Append(_usingReferenceName, " := "); + } + + writer.Append(ProxyExpression(Context.Selector)); + } + else + { + writer.Append(OperatingType.GetEdgeDBTypeName()); + + if (Context.IncludeShape) + { + (Context.Shape ?? BaseShapeBuilder.CreateDefault(GetOperatingType())) + .GetShape() + .Compile(writer.Append(' '), (writer, expression) => + { + using var consumer = NodeTranslationContext.CreateContextConsumer(expression.Root); + ExpressionTranslator.ContextualTranslate(expression.Expression, consumer, writer); + }); + } } _using?.Invoke(writer); @@ -42,11 +57,22 @@ public void By(LambdaExpression selector) public void Using(LambdaExpression expression) { + if (Context.Selector?.Body is MemberExpression) + { + // selecting out a property, create an alias + _usingReferenceName = QueryUtils.GenerateRandomVariableName(); + } + _using ??= writer => writer.Append(" using ", ProxyExpression(expression, ctx => { ctx.WrapNewExpressionInBrackets = false; - ctx.UseInitializationOperator = false; + + if (_usingReferenceName is not null) + { + ctx.ParameterAliases.Add(expression.Parameters.First(), _usingReferenceName); + } + //ctx.UseInitializationOperator = true; })); } } diff --git a/src/EdgeDB.Net.QueryBuilder/QueryNodes/InsertNode.Json.cs b/src/EdgeDB.Net.QueryBuilder/QueryNodes/InsertNode.Json.cs index 91f60f25..04ee55d5 100644 --- a/src/EdgeDB.Net.QueryBuilder/QueryNodes/InsertNode.Json.cs +++ b/src/EdgeDB.Net.QueryBuilder/QueryNodes/InsertNode.Json.cs @@ -14,12 +14,10 @@ private WriterProxy JsonSetterPath(PropertyInfo propertyInfo, string? parentRefe { return writer => writer .TypeCast(edgeqlType.ToString()) - .Append(Value.Of(writer => - writer.Function( - "json_get", - 'x', - Value.Of(writer => writer.SingleQuoted(propertyInfo.Name)) - )) + .Function( + "json_get", + 'x', + Value.Of(writer => writer.SingleQuoted(propertyInfo.Name)) ); } diff --git a/src/EdgeDB.Net.QueryBuilder/QueryNodes/InsertNode.cs b/src/EdgeDB.Net.QueryBuilder/QueryNodes/InsertNode.cs index 0bbfa1a2..4a4d790c 100644 --- a/src/EdgeDB.Net.QueryBuilder/QueryNodes/InsertNode.cs +++ b/src/EdgeDB.Net.QueryBuilder/QueryNodes/InsertNode.cs @@ -194,6 +194,14 @@ internal readonly struct InsertValue(Type type, IDictionary val public static InsertValue FromType(Type type, object value) { var map = EdgeDBPropertyMapInfo.Create(type); + + if (value is IDictionary vals) + return new InsertValue( + type, + vals, + map + ); + return new InsertValue( type, map.Properties.ToDictionary(x => x.EdgeDBName, x => x.PropertyInfo.GetValue(value)), @@ -281,7 +289,6 @@ private void WriteInsertStatement(QueryWriter writer) if (!SchemaInfo.TryGetObjectInfo(OperatingType, out var typeInfo)) throw new NotSupportedException($"Could not find type info for {OperatingType}"); - writer.Append(' '); ConflictUtils.GenerateExclusiveConflictStatement(writer, typeInfo, _elseStatement is not null); } @@ -320,6 +327,12 @@ private ShapeDefinition BuildInsertShape(Type? shapeType = null, Union writer.Assignment(name, proxy))); + continue; + } + if (insertValue.PropertyMapInfo is null) { setters.Add(new ShapeSetter(writer => @@ -491,27 +504,11 @@ private void BuildLinkResolver(QueryWriter writer, Type type, object? value) Defer.This(() => $"Built link resolver for {type}"), Value.Of(writer => writer.Wrapped(writer => { - var name = type.GetEdgeDBTypeName(); - var exclusiveProps = QueryGenerationUtils.GetProperties(info, type, true).ToArray(); - - writer.Append("insert ", name, " "); - - BuildInsertShape(type, Union.From(value, () => InsertValue.FromType(type, value))).Build(writer, info); - - if (!exclusiveProps.Any()) return; - - writer.Append("unless conflict on "); - - if (exclusiveProps.Length is 1) - writer.Append('.', exclusiveProps[0].GetEdgeDBPropertyName()); - else - writer.Shape( - $"shape_{type.GetEdgeDBTypeName()}_prop_{name}", - exclusiveProps, - (writer, x) => writer.Append('.', x.GetEdgeDBPropertyName()), - "()" - ); - writer.Append(" else (select ", name, ")"); + QueryBuilder + .Insert(type, value) + .UnlessConflict() + .ElseReturn() + .WriteTo(writer, this, new CompileContext { SchemaInfo = info}); })) ); }), value); diff --git a/src/EdgeDB.Net.QueryBuilder/QueryNodes/QueryNode.cs b/src/EdgeDB.Net.QueryBuilder/QueryNodes/QueryNode.cs index 3bec561b..725e29d9 100644 --- a/src/EdgeDB.Net.QueryBuilder/QueryNodes/QueryNode.cs +++ b/src/EdgeDB.Net.QueryBuilder/QueryNodes/QueryNode.cs @@ -135,11 +135,12 @@ protected void SetVariable(string name, object? value) /// The name of the global to set. /// The value of the global to set. /// The reference of the global to set. - protected void SetGlobal(string name, object? value, object? reference) + protected QueryGlobal SetGlobal(string name, object? value, object? reference) { var global = new QueryGlobal(name, value, reference); Builder.QueryGlobals.Add(global); ReferencedGlobals.Add(global); + return global; } /// @@ -204,44 +205,5 @@ protected void TranslateExpression(LambdaExpression root, Expression expression, using var consumer = NodeTranslationContext.CreateContextConsumer(root); ExpressionTranslator.ContextualTranslate(expression, consumer, writer); } - - internal void ReplaceSubqueryAsLiteral(QueryWriter writer, QueryGlobal global, Action compile) - { - if (!writer.TryGetMarker(global.Name, out var markers)) - return; - - foreach (var marker in markers) - { - marker.Replace(writer => - { - compile(global, writer); - }); - } - - - - // var index = writer.IndexOf(global.Name); - // - // if (index is -1) - // throw new InvalidOperationException("Global could not be found within the query string"); - // - // string? cached = null; - // - // while (index is not -1) - // { - // if (cached is null) - // { - // var globalWriter = writer.GetPositionalWriter(index); - // compile(global, globalWriter); - // cached = globalWriter.ToString(); - // } - // else - // { - // writer.Insert(index, cached); - // } - // - // index = writer.IndexOf(global.Name); - // } - } } } diff --git a/src/EdgeDB.Net.QueryBuilder/QueryNodes/SelectNode.cs b/src/EdgeDB.Net.QueryBuilder/QueryNodes/SelectNode.cs index a0bf4650..b45019fc 100644 --- a/src/EdgeDB.Net.QueryBuilder/QueryNodes/SelectNode.cs +++ b/src/EdgeDB.Net.QueryBuilder/QueryNodes/SelectNode.cs @@ -50,9 +50,6 @@ public override void Visit() if(Context.Shape is not null && Context.Expression is not null) { - // TODO: what..? figure out what this did - //Context.SelectName = FlattenTranslateExpression(Context.Expression); - _shape = Context.Shape.GetShape(); } @@ -64,77 +61,88 @@ public override void Visit() /// public override void FinalizeQuery(QueryWriter writer) { - if(SubNodes.Count > 1) - { - throw new NotSupportedException("Got more than one child node for select statement (this is a bug)"); - } - - // if parent is defined, our select logic was generated in the - // visit step, we can just return out. - if (SubNodes.Count == 1) + switch (SubNodes.Count) { - var node = SubNodes.First(); + case > 1: + throw new NotSupportedException("Got more than one child node for select statement (this is a bug)"); + // if parent is defined, our select logic was generated in the + // visit step, we can just return out. + case 1: + { + var node = SubNodes.First(); - // set introspection details & finalize - node.SchemaInfo = SchemaInfo; + // set introspection details & finalize + node.SchemaInfo = SchemaInfo; - writer.Append($"select ").Wrapped(writer => - { - if (writer.AppendIsEmpty(Value.Of(node.FinalizeQuery))) - return; + writer.Append($"select ").Wrapped(writer => + { + if (writer.AppendIsEmpty(Value.Of(node.FinalizeQuery))) + return; + + if(node.Context.SetAsGlobal && !string.IsNullOrEmpty(node.Context.GlobalName)) + { + // wrap global name + writer.Append(node.Context.GlobalName).Append(' '); + } + else + throw new InvalidOperationException($"Cannot resolve parent node {Parent}'s query"); + }); - if(node.Context.SetAsGlobal && !string.IsNullOrEmpty(node.Context.GlobalName)) + // append the shape of the parents node operating type if we should include ours + if (Context.IncludeShape && _shape is not null) { - // wrap global name - writer.Append(node.Context.GlobalName).Append(' '); + _shape.Compile(writer, (writer, expression) => + { + using var consumer = NodeTranslationContext.CreateContextConsumer(expression.Root); + ExpressionTranslator.ContextualTranslate(expression.Expression, consumer, writer); + }); } - else - throw new InvalidOperationException($"Cannot resolve parent node {Parent}'s query"); - }); - // append the shape of the parents node operating type if we should include ours - if (Context.IncludeShape && _shape is not null) - { - _shape.Compile(writer, (writer, expression) => - { - using var consumer = NodeTranslationContext.CreateContextConsumer(expression.Root); - ExpressionTranslator.ContextualTranslate(expression.Expression, consumer, writer); - }); + break; } - } - else if(!Context.IncludeShape) - { - if (Context.Expression is not null) + default: { - var expressionWriter = writer - .Append("select "); - - if (Context.SelectName is not null) - expressionWriter - .Append(Context.SelectName) - .Append(' '); + if(!Context.IncludeShape) + { + if (Context.Expression is not null) + { + var expressionWriter = writer + .Append("select "); + + if (Context.SelectName is not null) + expressionWriter + .Append(Context.SelectName) + .Append(' '); + + TranslateExpression(Context.Expression, expressionWriter); + } + else + writer.Append($"select {Context.SelectName ?? OperatingType.GetEdgeDBTypeName()}"); + } + else if (_shape is not null) + { + var shapeWriter = writer + .Append("select "); + + if (Context.Expression is not null) + { + writer.Append(ProxyExpression(Context.Expression), ' '); + } + else if (!Context.IsFreeObject) + shapeWriter + .Append(Context.SelectName ?? OperatingType.GetEdgeDBTypeName()) + .Append(' '); + + _shape.Compile(shapeWriter, (writer, expression) => + { + using var consumer = NodeTranslationContext.CreateContextConsumer(expression.Root); + ExpressionTranslator.ContextualTranslate(expression.Expression, consumer, writer); + }); + } - TranslateExpression(Context.Expression, expressionWriter); + break; } - else - writer.Append($"select {Context.SelectName ?? OperatingType.GetEdgeDBTypeName()}"); - } - else if (_shape is not null) - { - var shapeWriter = writer - .Append("select "); - - if (!Context.IsFreeObject) - shapeWriter - .Append(Context.SelectName ?? OperatingType.GetEdgeDBTypeName()) - .Append(' '); - - _shape.Compile(shapeWriter, (writer, expression) => - { - using var consumer = NodeTranslationContext.CreateContextConsumer(expression.Root); - ExpressionTranslator.ContextualTranslate(expression.Expression, consumer, writer); - }); } FilterProxy?.Invoke(writer); diff --git a/src/EdgeDB.Net.QueryBuilder/QueryNodes/WithNode.cs b/src/EdgeDB.Net.QueryBuilder/QueryNodes/WithNode.cs index a80fd2f8..567a8c60 100644 --- a/src/EdgeDB.Net.QueryBuilder/QueryNodes/WithNode.cs +++ b/src/EdgeDB.Net.QueryBuilder/QueryNodes/WithNode.cs @@ -1,3 +1,4 @@ +using EdgeDB.Translators.Expressions; using System.Linq.Expressions; namespace EdgeDB.QueryNodes @@ -10,24 +11,42 @@ internal class WithNode : QueryNode /// public WithNode(NodeBuilder builder) : base(builder) { } + public override void Visit() + { + if (Context.ValuesExpression is null) return; + + var inits = InitializationTranslator.PullInitializationExpression(Context.ValuesExpression.Body); + + Context.Values ??= inits.Any() ? new List() : null; + + foreach (var global in inits) + { + Context.Values!.Add(SetGlobal( + global.Key.Name, + new SubQuery(writer => TranslateExpression(Context.ValuesExpression, global.Value, writer)), + global.Value + )); + } + } + /// public override void FinalizeQuery(QueryWriter writer) { - if (Context.Values is null || !Context.Values.Any()) + if (!Builder.QueryGlobals.Any()) return; writer.Append("with "); - for (var i = 0; i != Context.Values.Count; i++) + for (var i = 0; i != Builder.QueryGlobals.Count; i++) { - var global = Context.Values[i]; + var global = Builder.QueryGlobals[i]; writer.Append(global.Name) .Append(" := "); global.Compile(this, writer, null, SchemaInfo); - if (i + 1 < Context.Values.Count) + if (i + 1 < Builder.QueryGlobals.Count) writer.Append(", "); } } diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/ExpressionContext.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/ExpressionContext.cs index 779e4b7f..303399f7 100644 --- a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/ExpressionContext.cs +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/ExpressionContext.cs @@ -30,6 +30,8 @@ internal class ExpressionContext /// public Dictionary Parameters { get; } + public Dictionary ParameterAliases { get; } = new(); + /// /// Gets or sets whether or not to serialize string without quotes. /// @@ -49,7 +51,7 @@ internal class ExpressionContext /// Gets or sets whether or not the current expression has an initialization /// operator, ex: ':=, +=, -='. /// - public bool UseInitializationOperator { get; set; } + public bool UseInitializationOperator { get; set; } = true; /// /// Gets or sets whether or not to include a self reference. @@ -63,6 +65,8 @@ internal class ExpressionContext /// public bool WrapNewExpressionInBrackets { get; set; } = true; + public Dictionary ParameterPrefixes { get; set; } = new(); + /// /// Gets whether or not the current expression tree is a free object. /// diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/ExpressionTranslator.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/ExpressionTranslator.cs index 6fca4d1a..c585d720 100644 --- a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/ExpressionTranslator.cs +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/ExpressionTranslator.cs @@ -60,6 +60,27 @@ static ExpressionTranslator() } } + public static string? UnsafeExpressionAsString(Expression expression) + { + if (expression is ConstantExpression constantExpression && + constantExpression.Type.IsAssignableTo(typeof(string))) + return (string?)constantExpression.Value; + + + var expressionResult = Expression + .Lambda(expression) + .Compile() + .DynamicInvoke(); + + if (expressionResult is not string strResult) + throw new ArgumentException( + $"Expected expression {expression} to evaluate to a string, but " + + $"got {expressionResult?.GetType().ToString() ?? "NULL"}" + ); + + return strResult; + } + public static WriterProxy Proxy(Expression expression, ExpressionContext expressionContext, string? label = null) { if (label is not null) diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/InitializationTranslator.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/InitializationTranslator.cs index 9a78e567..84e62aa8 100644 --- a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/InitializationTranslator.cs +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/InitializationTranslator.cs @@ -86,7 +86,7 @@ public static void Translate( { if (context.WrapNewExpressionInBrackets) { - writer.Wrapped(Value.Of(writer => TranslateInternal(expressions, context, writer)), "{}"); + writer.Wrapped(Value.Of(writer => TranslateInternal(expressions, context, writer)), "{}", true); return; } diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/LambdaExpressionTranslator.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/LambdaExpressionTranslator.cs index 232c902d..00618261 100644 --- a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/LambdaExpressionTranslator.cs +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/LambdaExpressionTranslator.cs @@ -19,6 +19,8 @@ public override void Translate(LambdaExpression expression, ExpressionContext co var newContext = new ExpressionContext(context.NodeContext, expression, context.QueryArguments, context.Globals); + newContext.ParameterPrefixes = context.ParameterPrefixes; + TranslateExpression(expression.Body, newContext, result); } } diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/MemberExpressionTranslator.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/MemberExpressionTranslator.cs index e950eb84..9950ea5d 100644 --- a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/MemberExpressionTranslator.cs +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/MemberExpressionTranslator.cs @@ -13,168 +13,148 @@ namespace EdgeDB.Translators.Expressions /// internal class MemberExpressionTranslator : ExpressionTranslator { + private (Expression BaseExpression, MemberExpression[] Path) DisassembleExpression(MemberExpression member) + { + var path = new List() { member }; + var current = member.Expression; + + while (current is MemberExpression element) + { + path.Add(element); + current = element.Expression; + } + + return ( + current ?? path.Last(), + path.ToArray() + ); + } + /// public override void Translate(MemberExpression expression, ExpressionContext context, QueryWriter writer) { // deconstruct the member access tree. - var deconstructed = ExpressionUtils.DisassembleExpression(expression).ToArray(); + var (baseExpression, path) = DisassembleExpression(expression); - var baseExpression = deconstructed.LastOrDefault(); + if (PropertyTranslationTable.TryGetTranslator(path[0], out var translator)) + { + translator(writer, path[0], context); + return; + } - // if the base class is context - if (baseExpression is not null && baseExpression.Type.IsAssignableTo(typeof(IQueryContext))) + switch (baseExpression) { - // switch the name of the accessed member - var accessExpression = deconstructed[^2]; - if(accessExpression is not MemberExpression memberExpression) - throw new NotSupportedException($"Cannot use expression type {accessExpression.NodeType} for a contextual member access"); - - switch (memberExpression.Member.Name) - { - case nameof(QueryContextUsing.Using): - // get the reference - if(deconstructed[^3] is not MemberExpression targetMemberExpression) - throw new NotSupportedException($"Cannot use expression type {deconstructed[^3] .NodeType} as a variable access"); - - writer.Append(targetMemberExpression.Member.GetEdgeDBPropertyName()); - break; - case nameof(QueryContextVars.Variables): - // get the reference - var target = deconstructed[^3]; - - // switch the type of the target - switch (target) - { - case MemberExpression targetMember: - // add a global reference to the current node with the expressions value - if (context.Node is not null && context.TryGetGlobal(targetMember.Member.Name, out var global)) - { - context.Node.ReferencedGlobals.Add(global); - } - - - if (targetMember.Type.IsAssignableTo(typeof(IJsonVariable))) - { - // pull the paths coming off of target member - var path = deconstructed[0].ToString()[(targetMember.ToString().Length + 6)..].Split('.', options: StringSplitOptions.RemoveEmptyEntries); - - // get the name of the json value - var jsonGlobal = context.Globals.FirstOrDefault(x => x.Name == targetMember.Member.Name); - - if (jsonGlobal is null) - throw new InvalidOperationException($"Cannot access json object \"{targetMember.Member.Name}\": No global found!"); - - // verify the global is json - if (jsonGlobal.Reference is not IJsonVariable jsonVariable) - throw new InvalidOperationException($"The global \"{jsonGlobal.Name}\" is not a json value"); - - // get the scalar type to cast to - if (!EdgeDBTypeUtils.TryGetScalarType(deconstructed[0].Type, out var scalarInfo)) - throw new InvalidOperationException($"json value access must be scalar, path: {deconstructed[0].ToString()}"); - - var arguments = new Terms.FunctionArg[path.Length + 1]; - - arguments[0] = jsonGlobal.Name; - for (var i = 0; i != path.Length; i++) - { - var element = path[i]; - arguments[i + 1] = new WriterProxy( - s => s.Append('\'').Append(element).Append('\'') - ); - } - - writer - .TypeCast(scalarInfo.ToString()) - .Function( - "json_get", - arguments - ); - return; - } - - if (deconstructed.Length != 3) - throw new NotSupportedException("Cannot use nested values for variable access"); - - // return the name of the member - writer.Append(targetMember.Member.Name); - return; - default: - throw new NotSupportedException($"Cannot use expression type {target.NodeType} as a variable access"); - } - case nameof(QueryContextSelf.Self): - var paths = deconstructed[..^2]; - writer.Append('.'); - for (var i = 0; i != paths.Length; i++) - { - if (paths[i] is not MemberExpression me) - throw new NotSupportedException( - $"Cannot use expression type {expression.NodeType} for a contextual member access" - ); + case { } contextParam when contextParam.Type.IsAssignableTo(typeof(IQueryContext)): + TranslateContextMember(writer, contextParam, path, context); + break; + case ParameterExpression param: + TranslateParameterMember(writer, param, path, context); + break; + case ConstantExpression constant: + TranslateConstantMember(writer, constant, path, context); + break; + } + } - writer.Append(me.Member.GetEdgeDBPropertyName()); - if (i + 1 != paths.Length) - writer.Append('.'); + private void TranslateConstantMember(QueryWriter writer, ConstantExpression constant, MemberExpression[] path, + ExpressionContext context) + { + if (!EdgeDBTypeUtils.TryGetScalarType(path[0].Type, out var edgeqlType)) + throw new NotSupportedException($"The type {path[0].Type} cannot be used as a query argument"); - } + var refHolder = constant.Value; - return; - } + for (var i = path.Length - 1; i >= 0; i--) + { + refHolder = path[i].Member.GetMemberValue(refHolder); } - // if the resolute expression is a constant expression, assume - // were in a set-like context and add it as a variable. - if (baseExpression is ConstantExpression constant) + writer.QueryArgument(edgeqlType.ToString(), context.AddVariable(refHolder)); + } + + private void TranslateParameterMember(QueryWriter writer, ParameterExpression parameter, MemberExpression[] path, ExpressionContext context) + { + if (context.ParameterPrefixes.TryGetValue(parameter, out var prefix)) + writer.Append(prefix); + else if (context.IncludeSelfReference) + writer.Append('.'); + + WritePath(writer, path); + } + + private void TranslateContextMember(QueryWriter writer, Expression contextExpression, MemberExpression[] path, ExpressionContext context) + { + var contextAccessor = path[^1]; + + switch (contextAccessor.Member.Name) { - // walk thru the reference tree, you can imagine this as a variac pointer resolution. - var refHolder = constant.Value; + case nameof(IQueryContextSelf.Self): + case nameof(IQueryContextUsing.Using): + WritePath(writer, path[..^1]); + break; + case nameof(IQueryContextVars.Variables): + var target = path[^2]; + if (!context.TryGetGlobal(target.Member.Name, out var global)) + throw new InvalidOperationException($"Unknown global in 'with' access of '{target.Member.Name}'"); - for(int i = deconstructed.Length - 2; i >= 0; i--) - { - // if the deconstructed node is not a member expression, we have something fishy... - if (deconstructed[i] is not MemberExpression memberExp) - throw new InvalidOperationException("Member tree does not contain all members. this is a bug, please file a github issue with the query that caused this exception."); + context.Node?.ReferencedGlobals.Add(global); - // gain the new reference holder to the value we're after - refHolder = memberExp.Member.GetMemberValue(refHolder); - } + if (target.Type.IsAssignableTo(typeof(IJsonVariable))) + { + // we go up to three because the real access looks like `ctx.Self.Value.XXXX.YY.ZZ...` + var jsonPath = path[..^3]; - // at this point, 'refHolder' is now a direct reference to the property the expression resolves to, - // we can add this as our variable. - var varName = context.AddVariable(refHolder); + if (global.Reference is not IJsonVariable) + throw new InvalidOperationException($"The global '{global.Name}' is not a json value"); - if (!EdgeDBTypeUtils.TryGetScalarType(expression.Type, out var type)) - throw new NotSupportedException($"Cannot use {expression.Type} as no edgeql equivalent can be found"); + if (!EdgeDBTypeUtils.TryGetScalarType(path[0].Type, out var edgeqlType)) + throw new InvalidOperationException("The json value must be a scalar type"); - writer.QueryArgument(type.ToString(), varName); - return; - } + var args = new Terms.FunctionArg[jsonPath.Length + 1]; + args[0] = new Terms.FunctionArg(global.Name); - // assume were in a access-like context and reference it in edgeql. - writer.Append(ParseMemberExpression(expression, expression.Expression is not ParameterExpression, context.IncludeSelfReference)); + for (var i = jsonPath.Length - 1; i >= 0; i--) + { + var pathRef = jsonPath[i].Member.Name; + args[i + 1] = Value.Of(writer => writer.SingleQuoted(pathRef)); + } + + writer + .TypeCast(edgeqlType.ToString()) + .Function( + "json_get", + args + ); + return; + } + + writer.Marker( + MarkerType.GlobalReference, + global.Name, + Defer.This(() => "Global referenced from member expression"), + new GlobalReferenceMetadata(global), + Value.Of(writer => + { + writer.Append(global.Name); + + if (path.Length < 3) return; + + writer.Append('.'); + WritePath(writer, path[..^2]); + }) + ); + break; + } } - /// - /// Parses a given member expression into a member access list. - /// - /// The expression to parse. - /// Whether or not to include the referenced parameter name. - /// Whether or not to include a self reference, ex: '.'. - /// - private static string ParseMemberExpression(MemberExpression expression, bool includeParameter = true, bool includeSelfReference = true) + private void WritePath(QueryWriter writer, MemberExpression[] path) { - List tree = new() + for (var i = path.Length - 1; i > 0; i--) { - expression.Member.GetEdgeDBPropertyName() - }; - - if (expression.Expression is MemberExpression innerExp) - tree.Add(ParseMemberExpression(innerExp)); - if (expression.Expression is ParameterExpression param) - if(includeSelfReference) - tree.Add(includeParameter ? param.Name : string.Empty); + writer.Append(path[i].Member.GetEdgeDBPropertyName(), '.'); + } - tree.Reverse(); - return string.Join('.', tree); + writer.Append(path[0].Member.GetEdgeDBPropertyName()); } } } diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/MethodCallExpressionTranslator.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/MethodCallExpressionTranslator.cs index a1a4a221..a12d94b6 100644 --- a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/MethodCallExpressionTranslator.cs +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/MethodCallExpressionTranslator.cs @@ -15,20 +15,34 @@ namespace EdgeDB.Translators.Expressions /// internal class MethodCallExpressionTranslator : ExpressionTranslator { - private static string ExpressionAsString(Expression exp) + private bool IsIllegalToInvoke(MethodCallExpression expression, ExpressionContext context) { - var expressionResult = Expression - .Lambda(exp) - .Compile() - .DynamicInvoke(); + // if any arguments reference context or json variables or root parameters + if (expression.Arguments.Any(x => + { + var disassembled = ExpressionUtils.DisassembleExpression(x); + + return disassembled.Any(y => + y.Type.IsAssignableTo(typeof(IQueryContext)) || y.Type.IsAssignableTo(typeof(IJsonVariable)) || + context.RootExpression.Parameters.Contains(y)); + })) + return true; + + if(expression.Object is not null) + { + var disassembledObject = ExpressionUtils.DisassembleExpression(expression.Object).ToArray(); - if (expressionResult is not string strResult) - throw new ArgumentException( - $"Expected expression {exp} to evaluate to a string, but " + - $"got {expressionResult?.GetType().ToString() ?? "NULL"}" - ); + // if instance references context or json variables + if (disassembledObject.Any(x => + x.Type.IsAssignableTo(typeof(IQueryContext)) || x.Type.IsAssignableTo(typeof(IJsonVariable)))) + return true; - return strResult; + // if instance references any root expression parameters. + if (context.RootExpression.Parameters.Any(x => disassembledObject.Contains(x))) + return true; + } + + return false; } public override void Translate(MethodCallExpression expression, ExpressionContext context, @@ -36,188 +50,36 @@ public override void Translate(MethodCallExpression expression, ExpressionContex { // figure out if the method is something we should translate or something that we should // call to pull the result from. - if (ShouldTranslate(expression, context)) + if (MethodTranslator.TryGetTranslator(expression, out var translator)) { - TranslateToEdgeQL(expression, context, writer); + translator.Translate(writer, expression, context); return; } - try - { - // invoke and translate the result - var expressionResult = Expression - .Lambda(expression, context.RootExpression.Parameters) - .Compile() - .DynamicInvoke(new object[context.RootExpression.Parameters.Count]); - - // attempt to get the scalar type of the result of the method. - if (!EdgeDBTypeUtils.TryGetScalarType(expression.Type, out var type)) - { - // if we can't, add it as a global - writer.Marker(MarkerType.GlobalReference, context.GetOrAddGlobal(expression, expressionResult)); - return; - //throw new InvalidOperationException("Expected a scalar type for "); - } - - // return the variable name containing the result of the method. - var varName = context.AddVariable(expressionResult); - writer - .Marker(MarkerType.GlobalReference, varName, Value.Of(writer => writer - .TypeCast(type.ToString()) - .Append(varName) - )); - } - catch(Exception x) - { - Console.Write(x); - } - } - - private bool ShouldTranslate(MethodCallExpression expression, ExpressionContext context) - { - // if the method references context or a parameter to our current root lambda - var disassembledInstance = expression.Object is null - ? Array.Empty() - : ExpressionUtils.DisassembleExpression(expression.Object).ToArray(); - - var isInstanceReferenceToContext = expression.Object?.Type == typeof(QueryContext) || - context.RootExpression.Parameters.Any(x => - disassembledInstance.Contains(x)); - - var isParameterReferenceToContext = expression.Arguments.Any(x => - x.Type == typeof(QueryContext) || - context.RootExpression.Parameters.Any(y => ExpressionUtils.DisassembleExpression(x).Contains(y))); - - var isExplicitTranslatorMethod = expression.Method.DeclaringType is not null && - MethodTranslator.TryGetTranslator(expression.Method.DeclaringType, - expression.Method.Name, out _); + if(IsIllegalToInvoke(expression, context)) + throw new InvalidOperationException($"Cannot invoke {expression.Method.Name} because it references mock-instances; and it has no translator"); - var isStdLib = expression.Method.DeclaringType == typeof(EdgeQL); - return isStdLib || isExplicitTranslatorMethod || isParameterReferenceToContext || - isInstanceReferenceToContext; - } + // invoke and translate the result + var expressionResult = Expression + .Lambda(expression, context.RootExpression.Parameters) + .Compile() + .DynamicInvoke(new object[context.RootExpression.Parameters.Count]); - private static void TranslateToEdgeQL(MethodCallExpression expression, ExpressionContext context, - QueryWriter writer) - { - // if our method is within the query context class - if (expression.Method.DeclaringType?.IsAssignableTo(typeof(IQueryContext)) ?? false) + // attempt to get the scalar type of the result of the method. + if (!EdgeDBTypeUtils.TryGetScalarType(expression.Type, out var type)) { - switch (expression.Method.Name) - { - case nameof(QueryContext.QueryArgument): - writer.QueryArgument( - EdgeDBTypeUtils.GetEdgeDBScalarOrTypeName(expression.Method.GetGenericArguments()[0]), - ExpressionAsString(expression.Arguments[0]) - ); - return; - case nameof(QueryContext.Global): - TranslateExpression(expression.Arguments[0], context.Enter(x => x.StringWithoutQuotes = true), - writer); - return; - case nameof(QueryContext.Local): - { - // get the path as a string and split it into segments - var path = ExpressionAsString(expression.Arguments[0]); - - var pathSegments = path.Split('.'); - - writer.Append('.'); - - for (int i = 0; i != pathSegments.Length; i++) - { - var prop = (MemberInfo?)context.LocalScope?.GetProperty(pathSegments[i]) ?? - context.LocalScope?.GetField(pathSegments[i]) ?? - (MemberInfo?)context.NodeContext.CurrentType.GetProperty(pathSegments[i]) ?? - context.NodeContext.CurrentType.GetField(pathSegments[i]); - - if (prop is null) - throw new InvalidOperationException( - $"The property \"{pathSegments[i]}\" within \"{path}\" is out of scope" - ); - - writer.Append(prop.GetEdgeDBPropertyName()); - - if (i + 1 != pathSegments.Length) - writer.Append('.'); - } - - return; - } - case nameof(QueryContext.UnsafeLocal): - { - // same thing as local except we dont validate anything here - writer - .Append('.') - .Append(ExpressionAsString(expression.Arguments[0])); - return; - } - case nameof(QueryContext.Raw): - { - // return the raw string as a constant expression and serialize it without quotes - writer.Append(ExpressionAsString(expression.Arguments[0])); - return; - } - case nameof(QueryContext.BackLink): - { - // depending on the backlink method called, we should set some flags: - // whether or not the called function is using the string form or the lambda form - var isRawPropertyName = expression.Arguments[0].Type == typeof(string); - - // whether or not a shape argument was supplied - var hasShape = !isRawPropertyName && expression.Arguments.Count > 1; - - writer.Append(".<"); - - // translate the backlink property accessor - TranslateExpression( - expression.Arguments[0], - isRawPropertyName - ? context.Enter(x => x.StringWithoutQuotes = true) - : context.Enter(x => x.IncludeSelfReference = false), - writer - ); - - // if its a lambda, add the corresponding generic type as a [is x] statement - if (!isRawPropertyName) - { - writer - .Append("[is ") - .Append(expression.Method.GetGenericArguments()[0].GetEdgeDBTypeName()) - .Append(']'); - } - - // if it has a shape, translate the shape and add it to the backlink - if (hasShape) - { - writer.Append('{'); - TranslateExpression(expression.Arguments[1], context, writer); - writer.Append('}'); - } - } - return; - case nameof(QueryContext.SubQuerySingle): - case nameof(QueryContext.SubQuery): - { - // pull the builder parameter and add it to a new lambda - // and execute it to get an instance of the builder - var builder = - (IQueryBuilder)Expression.Lambda(expression.Arguments[0]).Compile().DynamicInvoke()!; - - writer.Wrapped(writer => builder.WriteTo(writer, context)); - - return; - } - case nameof(QueryContext.Ref): - writer.Append('.', Proxy(expression.Arguments[0], context)); - break; - default: - throw new NotImplementedException( - $"{expression.Method.Name} does not have an implementation. This is a bug, please file a github issue with your query to reproduce this exception."); - } + // if we can't, add it as a global + writer.Marker(MarkerType.GlobalReference, context.GetOrAddGlobal(expression, expressionResult)); + return; + //throw new InvalidOperationException("Expected a scalar type for "); } - MethodTranslator.TranslateMethod(writer, expression, context); + // return the variable name containing the result of the method. + var varName = context.AddVariable(expressionResult); + writer.Marker(MarkerType.GlobalReference, varName, Value.Of(writer => writer + .TypeCast(type.ToString()) + .Append(varName) + )); } } } diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/ParameterExpressionTranslator.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/ParameterExpressionTranslator.cs index d28b0d21..8f80e763 100644 --- a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/ParameterExpressionTranslator.cs +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/ParameterExpressionTranslator.cs @@ -20,7 +20,15 @@ internal class ParameterExpressionTranslator : ExpressionTranslator public override void Translate(ParameterExpression expression, ExpressionContext context, QueryWriter writer) { - writer.Append(expression.Name!); + var name = expression.Name; + + if (context.ParameterAliases.TryGetValue(expression, out var alias)) + name = alias; + + if (context.ParameterPrefixes.TryGetValue(expression, out var prefix)) + writer.Append(prefix); + + writer.Append(name!); } } } diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/UnaryExpressionTranslator.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/UnaryExpressionTranslator.cs index 8335fd6f..bd9d1d87 100644 --- a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/UnaryExpressionTranslator.cs +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/UnaryExpressionTranslator.cs @@ -43,14 +43,16 @@ public override void Translate(UnaryExpression expression, ExpressionContext con : expression.Type.GetEdgeDBTypeName(); writer - .TypeCast(type) + .TypeCast(type, new CastMetadata(edgedbType, type)) .Append(Proxy(expression.Operand, context)); return; } case ExpressionType.ArrayLength: - writer.Append("len("); - TranslateExpression(expression.Operand, context, writer); - writer.Append(')'); + writer.Function( + "std::len", + Defer.This(() => $"ArrayLength expression implicit conversion"), + Value.Of(writer => TranslateExpression(expression.Operand, context, writer)) + ); return; // default case attempts to get an IEdgeQLOperator for the given diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Methods/EnumerableMethodTranslator.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Methods/EnumerableMethodTranslator.cs index dfdb2fc7..4a4e9286 100644 --- a/src/EdgeDB.Net.QueryBuilder/Translators/Methods/EnumerableMethodTranslator.cs +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Methods/EnumerableMethodTranslator.cs @@ -26,9 +26,9 @@ internal class EnumerableMethodTranslator : MethodTranslator public void Count(QueryWriter writer, TranslatedParameter source) { if (source.IsScalarArrayType || source.IsScalarType) - writer.Function("len", source); + writer.Function("std::len", source); else - writer.Function("count", source); + writer.Function("std::count", source); } /// @@ -42,7 +42,7 @@ public void Count(QueryWriter writer, TranslatedParameter source) public void Contains(QueryWriter writer, TranslatedParameter source, TranslatedParameter target) { if (source.IsScalarArrayType || source.IsScalarType) - writer.Function("contains", source); + writer.Function("std::contains", source); else writer.Append(target).Append(" in ").Append(source); } diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Methods/Generated/StdBool.g.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Methods/Generated/StdBool.g.cs index 1f7a93b0..a045ed04 100644 --- a/src/EdgeDB.Net.QueryBuilder/Translators/Methods/Generated/StdBool.g.cs +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Methods/Generated/StdBool.g.cs @@ -92,11 +92,6 @@ public void AdjacentTranslator(QueryWriter writer, TranslatedParameter lParam, T writer.Function("std::adjacent", lParam, rParam); } - [MethodName(nameof(EdgeQL.Not))] - public void Not(QueryWriter writer, TranslatedParameter vParam) - { - writer.Append("NOT").Append(vParam); - } [MethodName(nameof(EdgeQL.In))] public void In(QueryWriter writer, TranslatedParameter eParam, TranslatedParameter sParam) { diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Methods/MethodTranslator.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Methods/MethodTranslator.cs index 5708b156..9d4e9a71 100644 --- a/src/EdgeDB.Net.QueryBuilder/Translators/Methods/MethodTranslator.cs +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Methods/MethodTranslator.cs @@ -88,6 +88,8 @@ public MethodTranslator() _methodTranslators = new(tempDict); } + internal virtual bool CanTranslate(Type type) => type == TranslatorTargetType; + /// /// Statically initializes the abstract method translator and populates /// . @@ -122,16 +124,31 @@ internal static bool TryGetTranslator(string name, [NotNullWhen(true)] out Me null; } - internal static bool TryGetTranslator(Type type, string name, - [NotNullWhen(true)] out MethodTranslator? translator) + internal static bool TryGetTranslator(MethodCallExpression methodCall, + [MaybeNullWhen(false)] out MethodTranslator translator) { - translator = null; + var type = methodCall.Method.DeclaringType; + List? translators = null; - if (!_translators.TryGetValue(type, out var translators)) + while (type != null && !_translators.TryGetValue(type, out translators)) + { + type = type.BaseType; + } + + if (translators is null) + { + translator = null; return false; + } - return (translator = translators.FirstOrDefault(x => x._methodTranslators.TryGetValue(name, out _))) is not - null; + translators.AddRange(_translators + .FirstOrDefault(x => x.Value.Any(y => y.CanTranslate(methodCall.Method.DeclaringType!))) + .Value?.Where(x => x.CanTranslate(methodCall.Method.DeclaringType!)).ToArray() ?? Array.Empty()); + + translator = translators + .FirstOrDefault(x => x._methodTranslators.TryGetValue(methodCall.Method.Name, out _)); + + return translator is not null; } /// @@ -144,27 +161,14 @@ internal static bool TryGetTranslator(Type type, string name, public static void TranslateMethod(QueryWriter writer, MethodCallExpression methodCall, ExpressionContext context) { - var type = methodCall.Method.DeclaringType; - List? translators = null; - - - while (type != null && !_translators.TryGetValue(type, out translators)) - { - type = type.BaseType; - } - - if (translators is null) - throw new NotSupportedException( - $"Cannot use method {methodCall.Method} as there is no translator for it"); - - var translator = translators - .FirstOrDefault(x => x._methodTranslators.TryGetValue(methodCall.Method.Name, out _)); - - if (type is null || translator is null) - throw new NotSupportedException( - $"Cannot use method {methodCall.Method} as there is no translator for it"); - - translator.Translate(writer, methodCall, context); + if(!TryGetTranslator(methodCall, out var translator)) + throw new NotSupportedException($"Cannot use method {methodCall.Method} as there is no translator for it"); + + writer.LabelVerbose( + $"method_translation_{translator.GetType().Name}", + Defer.This(() => $"Translator type is {translator} picked for {methodCall.Method}"), + Value.Of(writer => translator.Translate(writer, methodCall, context)) + ); } /// @@ -192,7 +196,7 @@ protected Value OptionalArg(TranslatedParameter? arg) /// /// No translator could be found for the given method. /// - protected void Translate(QueryWriter writer, MethodCallExpression methodCall, ExpressionContext context) + public void Translate(QueryWriter writer, MethodCallExpression methodCall, ExpressionContext context) { // try to get a method for translating the expression if (!_methodTranslators.TryGetValue(methodCall.Method.Name, out var methodInfo)) @@ -224,6 +228,7 @@ protected void Translate(QueryWriter writer, MethodCallExpression methodCall, Ex var parsedParameters = new object?[methodParameters.Length]; // iterate over the parameters and parse them. + var methodCallArgsIndex = 0; for (var i = 0; i != methodParameters.Length; i++) { var parameterInfo = methodParameters[i]; @@ -232,26 +237,33 @@ protected void Translate(QueryWriter writer, MethodCallExpression methodCall, Ex // its value to the remaining arguments to the expression and break out of the loop if (parameterInfo.GetCustomAttribute() != null) { - parsedParameters[i] = methodCall.Arguments.Skip(i) + parsedParameters[i] = methodCall.Arguments.Skip(methodCallArgsIndex) .Select(x => new TranslatedParameter(x.Type, x, context)).ToArray(); break; } - else if (methodCall.Arguments.Count > i) - { - parsedParameters[i] = new TranslatedParameter( - methodCall.Arguments[i].Type, - methodCall.Arguments[i], - context - ); - } else if (parameterInfo.ParameterType == typeof(ExpressionContext)) { // set the context parsedParameters[i] = context; } + else if (parameterInfo.Name == "method" && parameterInfo.ParameterType == typeof(MethodCallExpression)) + { + parsedParameters[i] = methodCall; + } + else if (methodCall.Arguments.Count > methodCallArgsIndex) + { + parsedParameters[i] = new TranslatedParameter( + methodCall.Arguments[methodCallArgsIndex].Type, + methodCall.Arguments[methodCallArgsIndex], + context + ); + methodCallArgsIndex++; + } else // get the default value for the parameter type + { parsedParameters[i] = ReflectionUtils.GetDefault(parameterInfo.ParameterType); + } } // if its an instance reference, recreate our parsed array to include the instance parameter diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Methods/QueryContextTranslator.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Methods/QueryContextTranslator.cs new file mode 100644 index 00000000..bc30a46c --- /dev/null +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Methods/QueryContextTranslator.cs @@ -0,0 +1,133 @@ +using System.Linq.Expressions; +using System.Reflection; + +namespace EdgeDB.Translators.Methods; + +internal sealed class QueryContextTranslator : MethodTranslator +{ + internal override bool CanTranslate(Type type) => type.IsAssignableTo(typeof(IQueryContext)); + + [MethodName(nameof(QueryContext.QueryArgument))] + public void QueryArgument(QueryWriter writer, TranslatedParameter param) + { + writer.QueryArgument( + EdgeDBTypeUtils.GetEdgeDBScalarOrTypeName(param.RawValue.Type), + ExpressionTranslator.UnsafeExpressionAsString(param.RawValue) + ); + } + + [MethodName(nameof(QueryContext.Global))] + public void Global(QueryWriter writer, TranslatedParameter param, ExpressionContext context) + { + param.Context = context.Enter(x => x.StringWithoutQuotes = true); + writer.Append(param); + } + + [MethodName(nameof(QueryContext.Local))] + public void Local(QueryWriter writer, TranslatedParameter param, ExpressionContext context) + { + var path = ExpressionTranslator.UnsafeExpressionAsString(param.RawValue) + ?? throw new NullReferenceException("Expected parameter of 'local' to be notnull"); + + var pathSegments = path.Split('.'); + + writer.Append('.'); + + for (var i = 0; i != pathSegments.Length; i++) + { + var prop = (MemberInfo?)context.LocalScope?.GetProperty(pathSegments[i]) ?? + context.LocalScope?.GetField(pathSegments[i]) ?? + (MemberInfo?)context.NodeContext.CurrentType.GetProperty(pathSegments[i]) ?? + context.NodeContext.CurrentType.GetField(pathSegments[i]); + + if (prop is null) + throw new InvalidOperationException( + $"The property \"{pathSegments[i]}\" within \"{path}\" is out of scope" + ); + + writer.Append(prop.GetEdgeDBPropertyName()); + + if (i + 1 != pathSegments.Length) + writer.Append('.'); + } + } + + [MethodName(nameof(QueryContext.UnsafeLocal))] + public void UnsafeLocal(QueryWriter writer, TranslatedParameter param) + { + writer.Append('.', ExpressionTranslator.UnsafeExpressionAsString(param.RawValue)); + } + + [MethodName(nameof(QueryContext.Raw))] + public void Raw(QueryWriter writer, TranslatedParameter param) + { + writer.Append(ExpressionTranslator.UnsafeExpressionAsString(param.RawValue)); + } + + [MethodName(nameof(QueryContext.BackLink))] + public void Backlink(QueryWriter writer, MethodCallExpression method, ExpressionContext context, params TranslatedParameter[] args) + { + var property = args[0]; + + // depending on the backlink method called, we should set some flags: + // whether or not the called function is using the string form or the lambda form + var isRawPropertyName = property.ParameterType == typeof(string); + + // whether or not a shape argument was supplied + var hasShape = !isRawPropertyName && args.Length > 1; + + writer.Append(".<"); + + // translate the backlink property accessor + property.Context = context.Enter(x => + { + x.StringWithoutQuotes = isRawPropertyName; + x.IncludeSelfReference = false; + }); + + writer.Append(property); + + // if its a lambda, add the corresponding generic type as a [is x] statement + if (!isRawPropertyName) + { + writer + .Append("[is ") + .Append(method.Method.GetGenericArguments()[0].GetEdgeDBTypeName()) + .Append(']'); + } + + // if it has a shape, translate the shape and add it to the backlink + if (hasShape) + { + writer.Wrapped(args[1], "{}", true); + } + } + + [MethodName(nameof(QueryContext.SubQuery))] + [MethodName(nameof(QueryContext.SubQuerySingle))] + public void SubQuery(QueryWriter writer, TranslatedParameter param, ExpressionContext context) + { + var builder = (IQueryBuilder)Expression.Lambda(param.RawValue).Compile().DynamicInvoke()!; + writer.Wrapped(writer => builder.WriteTo(writer, context)); + } + + [MethodName(nameof(QueryContext.Aggregate))] + public void Aggregate(QueryWriter writer, TranslatedParameter source, TranslatedParameter expressive) + { + if (expressive.RawValue is not LambdaExpression lambda) + throw new NotSupportedException("The expressive operand of 'Ref' must be a lambda function"); + + // we just prefix all references of the parameter to the func with the source, example: + // Aggregate(People, (Person x) => EdgeQL.Count(x.Name)) + // will become + // std::count(.people.name) + // since .people is a set, .people.name returns a set + expressive.Context = expressive.Context.Enter(x => + { + x.ParameterPrefixes.Add(lambda.Parameters[0], writer => writer.Append(source, '.')); + x.IncludeSelfReference = true; + }); + + writer.Append(expressive); + } +} diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/PropertyTranslationTable.cs b/src/EdgeDB.Net.QueryBuilder/Translators/PropertyTranslationTable.cs new file mode 100644 index 00000000..81061c72 --- /dev/null +++ b/src/EdgeDB.Net.QueryBuilder/Translators/PropertyTranslationTable.cs @@ -0,0 +1,41 @@ +using System.Diagnostics.CodeAnalysis; +using System.Linq.Expressions; + +namespace EdgeDB.Translators; + +internal static class PropertyTranslationTable +{ + internal delegate void TableTranslator(QueryWriter writer, MemberExpression expression, ExpressionContext context); + + private static readonly Dictionary Table = new() + { + {nameof(string.Length), ([typeof(string), typeof(Array)], TranslateLength)} + }; + + public static bool TryGetTranslator(MemberExpression expression, [MaybeNullWhen(false)] out TableTranslator translator) + { + if (Table.TryGetValue(expression.Member.Name, out var entry)) + { + if (entry.ValidOn.Contains(expression.Member.DeclaringType!)) + { + translator = entry.Translator; + return true; + } + } + + translator = null; + return false; + } + + private static void TranslateLength(QueryWriter writer, MemberExpression expression, ExpressionContext context) + { + if (expression.Expression is null) + throw new InvalidOperationException("Missing target for 'len()'"); + + writer.Function( + "std::len", + Defer.This(() => $"Auto .Length access converted to std::len()"), + ExpressionTranslator.Proxy(expression.Expression, context) + ); + } +} diff --git a/src/EdgeDB.Net.QueryBuilder/Utils/ConflictUtils.cs b/src/EdgeDB.Net.QueryBuilder/Utils/ConflictUtils.cs index f37da621..f5e378ce 100644 --- a/src/EdgeDB.Net.QueryBuilder/Utils/ConflictUtils.cs +++ b/src/EdgeDB.Net.QueryBuilder/Utils/ConflictUtils.cs @@ -30,7 +30,7 @@ public static void GenerateExclusiveConflictStatement(QueryWriter writer, Object if (type.Constraints?.Any(x => x.IsExclusive) ?? false) { writer - .Append("unless conflict on ") + .Append(" unless conflict on ") .Append(type.Constraints?.First(x => x.IsExclusive).SubjectExpression); return; } @@ -39,7 +39,7 @@ public static void GenerateExclusiveConflictStatement(QueryWriter writer, Object if(type.Properties!.Count(x => x.Name != "id" && x.IsExclusive) == 1) { writer - .Append("unless conflict on .") + .Append(" unless conflict on .") .Append(type.Properties!.First(x => x.Name != "id" && x.IsExclusive).Name); return; @@ -48,7 +48,7 @@ public static void GenerateExclusiveConflictStatement(QueryWriter writer, Object // if it doesn't have an else statement we can simply add 'UNLESS CONFLICT' if (!hasElse) { - writer.Append("unless conflict"); + writer.Append(" unless conflict"); return; } diff --git a/src/EdgeDB.Net.QueryBuilder/Utils/EdgeDBTypeUtils.cs b/src/EdgeDB.Net.QueryBuilder/Utils/EdgeDBTypeUtils.cs index 6aea09b7..9acbc0b0 100644 --- a/src/EdgeDB.Net.QueryBuilder/Utils/EdgeDBTypeUtils.cs +++ b/src/EdgeDB.Net.QueryBuilder/Utils/EdgeDBTypeUtils.cs @@ -173,5 +173,22 @@ public static bool IsLink(EdgeDBPropertyInfo info, out bool isMultiLink, [MaybeN return IsLink(info.Type, out isMultiLink, out innerLinkType); } + + public static bool CompareEdgeDBTypes(string a, string b) + { + if (a == b) + return true; + + var aSpl = a.Split("::"); + var bSpl = b.Split("::"); + + if (aSpl.Length == 2 && bSpl.Length == 1 && aSpl[0] == "std") + return aSpl[1] == b; + + if (bSpl.Length == 2 && aSpl.Length == 1 && bSpl[0] == "std") + return bSpl[1] == a; + + return false; + } } } diff --git a/src/EdgeDB.Net.QueryBuilder/Utils/ExpressionUtils.cs b/src/EdgeDB.Net.QueryBuilder/Utils/ExpressionUtils.cs index daa3f0d5..06db2a1f 100644 --- a/src/EdgeDB.Net.QueryBuilder/Utils/ExpressionUtils.cs +++ b/src/EdgeDB.Net.QueryBuilder/Utils/ExpressionUtils.cs @@ -13,7 +13,7 @@ namespace EdgeDB internal static class ExpressionUtils { /// - /// Disassembles an arbitrary expression into a list of expression nodes. + /// Disassembles an arbitrary expression into a list of expression nodes. /// /// The expression to disassemble. /// diff --git a/tools/EdgeDB.QueryBuilder.StandardLibGenerator/FunctionGenerator.cs b/tools/EdgeDB.QueryBuilder.StandardLibGenerator/FunctionGenerator.cs index 8eb1cb91..5a79cfc7 100644 --- a/tools/EdgeDB.QueryBuilder.StandardLibGenerator/FunctionGenerator.cs +++ b/tools/EdgeDB.QueryBuilder.StandardLibGenerator/FunctionGenerator.cs @@ -12,6 +12,7 @@ namespace EdgeDB.StandardLibGenerator internal class RequiredMethodTranslator { public string? TargetName { get; init; } + public string? EdgeQLName { get; init; } public string? Group { get; init; } public string? Expression { get; init; } public Parameter[]? Parameters { get; init; } @@ -123,6 +124,10 @@ private static async ValueTask ProcessGroup(string groupType, IEnumerable"); } + _edgeqlClassWriter!.AppendLine($"[EdgeQLFunction(\"{funcCleanName}\", \"{funcModule}\", \"{func.ReturnType.Name}\", {(func.ReturnTypeModifier is TypeModifier.SetOfType).ToString().ToLower()}, {(func.ReturnTypeModifier is TypeModifier.OptionalType).ToString().ToLower()})]"); _edgeqlClassWriter!.AppendLine( $"public static {dotnetReturnType.Type} {funcName}{(formattedGenerics.Any() ? $"<{formattedGenerics}>" : "")}({strongMappedParameters})"); foreach (var c in parsedParameters.Where(x => x.GenericConditions.Any()) @@ -393,6 +399,11 @@ await TypeUtils.BuildType(_client!, node, TypeModifier.SingletonType, StdLibOutp $"{(dotnetReturnType.Generics.Any() ? "`1" : dotnetReturnType.Type)}{translator.TargetName}{(formattedGenerics.Any() ? $"<`{formattedGenerics.Count()}>" : "")}({string.Join(", ", parsedParameters.Select(x => x.Generics.Any() ? "`1" : x.Type))})"; if (!_generatedPublicFuncs.Contains(genKey)) { + var fSpl = translator.EdgeQLName.Split("::"); + var funcCleanName = fSpl[^1]; + var funcModule = string.Join("::", fSpl[..^1]); + + _edgeqlClassWriter!.AppendLine($"[EdgeQLFunction(\"{funcCleanName}\", \"{funcModule}\", \"{translator.Result.Name}\", {(translator.Modifier is TypeModifier.SetOfType).ToString().ToLower()}, {(translator.Modifier is TypeModifier.OptionalType).ToString().ToLower()})]"); _edgeqlClassWriter!.AppendLine( $"public static {dotnetReturnType.Type} {translator.TargetName}{(formattedGenerics.Any() ? $"<{formattedGenerics}>" : "")}({strongMappedParameters})"); foreach (var c in parsedParameters.Where(x => x.GenericConditions.Any()) diff --git a/tools/EdgeDB.QueryBuilder.StandardLibGenerator/OperatorGenerator.cs b/tools/EdgeDB.QueryBuilder.StandardLibGenerator/OperatorGenerator.cs index 2c2ff8a0..c4075cc5 100644 --- a/tools/EdgeDB.QueryBuilder.StandardLibGenerator/OperatorGenerator.cs +++ b/tools/EdgeDB.QueryBuilder.StandardLibGenerator/OperatorGenerator.cs @@ -94,6 +94,7 @@ private static async Task> ProcessGroupAsync(Edge Parameters = op.Parameters, Result = op.ReturnType, TargetName = FormatName(INamingStrategy.PascalNamingStrategy.Convert(op.Name!.Split("::")[1])), + EdgeQLName = opName, Modifier = op.ReturnTypeModifier }); } @@ -116,7 +117,8 @@ private static async Task> ProcessGroupAsync(Edge Parameters = op.Parameters, Result = op.ReturnType, TargetName = FormatName(INamingStrategy.PascalNamingStrategy.Convert(opName.Split("::")[1])), - Modifier = op.ReturnTypeModifier + Modifier = op.ReturnTypeModifier, + EdgeQLName = opName }); } else @@ -173,21 +175,21 @@ private static string BuildExpression(Operator op) return $"writer.Append({op.Parameters[0].Name + "Param"}).Wrapped({op.Parameters[1].Name + "Param"}, \"[]\")"; } - return $"writer.Append({op.Parameters[0].Name + "Param"}).Wrapped(\"{operation}\", \" \").Append({op.Parameters[1].Name + "Param"})"; + return $"writer.Append({op.Parameters[0].Name + "Param"}).Append(\" {operation} \").Append({op.Parameters[1].Name + "Param"})"; } case OperatorKind.Postfix: { if (op.Parameters!.Length != 1) throw new ArgumentException("Expected 1 parameter for Postfix"); - return $"writer.Append({op.Parameters[0].Name + "Param"}, {operation})"; + return $"writer.Append({op.Parameters[0].Name + "Param"}, \" {operation}\")"; } case OperatorKind.Prefix: { if (op.Parameters!.Length != 1) throw new ArgumentException("Expected 1 parameter for Prefix"); - return $"writer.Append(\"{operation}\", {op.Parameters[0].Name + "Param"})"; + return $"writer.Append(\"{operation} \", {op.Parameters[0].Name + "Param"})"; } case OperatorKind.Ternary: {